Skip to content

Commit

Permalink
Increase retry delay attempts to shake off flakey connection.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 609499695
Change-Id: I59750a9c9633eea9b1ebe2941b4717cedcaf615f
  • Loading branch information
nttran8 authored and copybara-github committed Feb 22, 2024
1 parent cac9e76 commit 0e199ba
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,13 @@ public final class RemoteVulnDetectorImpl implements RemoteVulnDetector {
private static final int INITIAL_WAIT_TIME_MS = 200;
private static final int MAX_WAIT_TIME_MS = 30000;
private static final int WAIT_TIME_MULTIPLIER = 3;
private static final int MAX_ATTEMPTS = 3;
private static final int MAX_ATTEMPTS = 5;
// Exponential delay attempts (>24 seconds before taking randomization factor into account):
// ~200ms
// ~600ms
// ~1800ms
// ~5400ms
// ~16200ms
private final ExponentialBackOff backoff =
new ExponentialBackOff.Builder()
.setInitialIntervalMillis(INITIAL_WAIT_TIME_MS)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public void detect_withServingServer_returnsSuccessfulDetectionReportList() thro
.build());
}

@Test(timeout = 11000L)
@Test
public void detect_withNonServingServer_returnsEmptyDetectionReportList() throws Exception {
registerHealthCheckWithStatus(ServingStatus.NOT_SERVING);

Expand All @@ -132,7 +132,7 @@ public void detect_withNonServingServer_returnsEmptyDetectionReportList() throws
.isEmpty();
}

@Test(timeout = 32000L)
@Test(timeout = 30000L)
public void detect_withRpcError_throwsLanguageServerException() throws Exception {
registerHealthCheckWithError();

Expand All @@ -158,23 +158,23 @@ public void listPlugins(
responseObserver.onCompleted();
}
});

assertThat(pluginToTest.getAllPlugins()).containsExactly(plugin);
}

@Test(timeout = 32000L)
@Test
public void getAllPlugins_withNonServingServer_returnsEmptyList() throws Exception {
registerHealthCheckWithStatus(ServingStatus.NOT_SERVING);
assertThat(getNewRemoteVulnDetectorInstance().getAllPlugins()).isEmpty();
}

@Test(timeout = 32000L)
@Test(timeout = 30000L)
public void getAllPlugins_withRpcError_throwsLanguageServerException() throws Exception {
registerHealthCheckWithError();
assertThrows(LanguageServerException.class, getNewRemoteVulnDetectorInstance()::getAllPlugins);
}

@Test(timeout = 32000L)
@Test(timeout = 30000L)
public void getAllPlugins_withUnregisteredHealthService_throwsLanguageServerException()
throws Exception {
assertThrows(LanguageServerException.class, getNewRemoteVulnDetectorInstance()::getAllPlugins);
Expand Down

0 comments on commit 0e199ba

Please sign in to comment.