From 3115bb72b40ca99306fd7221fcf9a95f0777d16d Mon Sep 17 00:00:00 2001 From: Marco Ziccardi Date: Mon, 24 Oct 2016 16:01:04 +0200 Subject: [PATCH] Fix flakey list log entries test --- .../java/com/google/cloud/logging/BaseSystemTest.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/google-cloud-logging/src/test/java/com/google/cloud/logging/BaseSystemTest.java b/google-cloud-logging/src/test/java/com/google/cloud/logging/BaseSystemTest.java index eb523b0dddcf..4e5d42ef9281 100644 --- a/google-cloud-logging/src/test/java/com/google/cloud/logging/BaseSystemTest.java +++ b/google-cloud-logging/src/test/java/com/google/cloud/logging/BaseSystemTest.java @@ -396,8 +396,13 @@ public void testWriteAndListLogEntries() throws InterruptedException { assertNull(entry.getHttpRequest()); assertNotNull(entry.getInsertId()); assertNotNull(entry.getTimestamp()); - page = logging().listLogEntries(EntryListOption.filter(filter), - EntryListOption.sortOrder(SortingField.TIMESTAMP, SortingOrder.DESCENDING)); + options = new EntryListOption[]{EntryListOption.filter(filter), + EntryListOption.sortOrder(SortingField.TIMESTAMP, SortingOrder.DESCENDING)}; + page = logging().listLogEntries(options); + while (Iterators.size(page.iterateAll()) < 2) { + Thread.sleep(500); + page = logging().listLogEntries(options); + } iterator = page.iterateAll(); Long lastTimestamp = iterator.next().getTimestamp(); while (iterator.hasNext()) {