Skip to content

Commit

Permalink
test: update TestBench to await shutdown before yielding for the next…
Browse files Browse the repository at this point in the history
… test (#1181)
  • Loading branch information
BenWhitehead committed Dec 20, 2021
1 parent 16c2aef commit c70513c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,30 @@ public boolean shouldRetry(
e.getCause());
} finally {
process.destroy();
// wait for the server to shutdown
runWithRetries(
() -> {
try {
listRetryTests();
} catch (SocketException e) {
// desired result
return null;
}
throw new NotShutdownException();
},
RetrySettings.newBuilder()
.setTotalTimeout(Duration.ofSeconds(30))
.setInitialRetryDelay(Duration.ofMillis(500))
.setRetryDelayMultiplier(1.5)
.setMaxRetryDelay(Duration.ofSeconds(5))
.build(),
new BasicResultRetryAlgorithm<List<?>>() {
@Override
public boolean shouldRetry(Throwable previousThrowable, List<?> previousResponse) {
return previousThrowable instanceof NotShutdownException;
}
},
NanoClock.getDefaultClock());
if (cleanupStrategy == CleanupStrategy.ALWAYS
|| (success && cleanupStrategy == CleanupStrategy.ONLY_ON_SUCCESS)) {
Files.delete(errPath);
Expand Down Expand Up @@ -388,4 +412,6 @@ public TestBench build() {
containerName);
}
}

private static final class NotShutdownException extends RuntimeException {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,7 @@ public final class ITBlobWriteChannelTest {

@ClassRule
public static final TestBench testBench =
TestBench.newBuilder()
.setContainerName("blob-write-channel-test")
// set a different base uri to prevent collision with conformance tests.
// It's possible for ITRetryConformanceTest to finish running and start shutting down
// when this test starts so the liveness check passes against the shutting down server.
.setBaseUri("http://localhost:9100")
.build();
TestBench.newBuilder().setContainerName("blob-write-channel-test").build();

@Rule public final TestName testName = new TestName();

Expand Down

0 comments on commit c70513c

Please sign in to comment.