Skip to content

Commit c5df475

Browse files
authored
chore: update job tests with retries (GoogleCloudPlatform#6861)
* chore: update job tests with retries * minor fixes * Update
1 parent 647af4b commit c5df475

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

run/jobs/src/test/java/com/example/JobsIntegrationTests.java

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,15 +104,23 @@ public void generatesLogs() throws Exception {
104104
+ "\" -protoPayload.serviceName=\"run.googleapis.com\"";
105105

106106
System.out.println(logFilter);
107-
Page<LogEntry> entries = logging.listLogEntries(EntryListOption.filter(logFilter));
108107
Boolean found = false;
109-
for (LogEntry logEntry : entries.iterateAll()) {
110-
if (!logEntry.getLogName().contains("cloudaudit")) {
111-
Payload<String> payload = logEntry.getPayload();
112-
if (payload.getData().contains("Task")) {
113-
found = true;
108+
// Retry up to 5 times
109+
for (int i = 1; i <= 5; i++) {
110+
Page<LogEntry> entries = logging.listLogEntries(EntryListOption.filter(logFilter));
111+
for (LogEntry logEntry : entries.iterateAll()) {
112+
if (!logEntry.getLogName().contains("cloudaudit")) {
113+
Payload<String> payload = logEntry.getPayload();
114+
if (payload.getData().contains("Task")) {
115+
found = true;
116+
break;
117+
}
114118
}
115119
}
120+
if (found) {
121+
break;
122+
}
123+
TimeUnit.SECONDS.sleep(i * 30);
116124
}
117125
assertTrue("Log was not found.", found);
118126
}

0 commit comments

Comments
 (0)