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()) {