Skip to content

Commit 829c7a4

Browse files
committed
Refactor ITComputeGoldenSignals to improve test resilience
1 parent 40132a2 commit 829c7a4

1 file changed

Lines changed: 18 additions & 3 deletions

File tree

java-compute/google-cloud-compute/src/test/java/com/google/cloud/compute/v1/integration/ITComputeGoldenSignals.java

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,11 +182,14 @@ public void setUp() throws Exception {
182182
.getTraceSettings()
183183
.setRetrySettings(
184184
RetrySettings.newBuilder()
185-
.setTotalTimeoutDuration(Duration.ofSeconds(60))
185+
.setTotalTimeoutDuration(Duration.ofMinutes(5))
186186
.setInitialRpcTimeoutDuration(Duration.ofSeconds(5))
187187
.setMaxRpcTimeoutDuration(Duration.ofSeconds(10))
188188
.build())
189-
.setRetryableCodes(StatusCode.Code.NOT_FOUND);
189+
.setRetryableCodes(
190+
StatusCode.Code.NOT_FOUND,
191+
StatusCode.Code.INTERNAL,
192+
StatusCode.Code.DEADLINE_EXCEEDED);
190193

191194
settingsBuilder.getStubSettingsBuilder().setTracerFactory(BaseApiTracerFactory.getInstance());
192195

@@ -299,7 +302,18 @@ public void testComputeOperationTracing_Error() throws Exception {
299302
}
300303

301304
private void fetchAndValidateTrace(String traceId, boolean expectError) throws Exception {
302-
Trace trace = traceClient.getTrace(DEFAULT_PROJECT, traceId);
305+
Trace trace = null;
306+
try {
307+
trace = traceClient.getTrace(DEFAULT_PROJECT, traceId);
308+
} catch (Exception e) {
309+
logger.error(
310+
"Exception occurred while fetching trace for project: "
311+
+ DEFAULT_PROJECT
312+
+ ", traceId: "
313+
+ traceId,
314+
e);
315+
throw e;
316+
}
303317
assertThat(trace).isNotNull();
304318

305319
for (TraceSpan span : trace.getSpansList()) {
@@ -506,6 +520,7 @@ private TimeSeries pollForTimeSeries(
506520
if (e.getStatus().getCode() == Status.Code.NOT_FOUND) {
507521
logger.info("Metric not found yet (gRPC NOT_FOUND): " + e.getMessage());
508522
} else {
523+
logger.error("Encountered unexpected StatusRuntimeException while polling for metrics", e);
509524
throw e;
510525
}
511526
}

0 commit comments

Comments
 (0)