diff --git a/plugin/src/main/java/com/google/tsunami/plugin/RemoteVulnDetectorImpl.java b/plugin/src/main/java/com/google/tsunami/plugin/RemoteVulnDetectorImpl.java index 6fe0be76..4b453cbb 100644 --- a/plugin/src/main/java/com/google/tsunami/plugin/RemoteVulnDetectorImpl.java +++ b/plugin/src/main/java/com/google/tsunami/plugin/RemoteVulnDetectorImpl.java @@ -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) diff --git a/plugin/src/test/java/com/google/tsunami/plugin/RemoteVulnDetectorImplTest.java b/plugin/src/test/java/com/google/tsunami/plugin/RemoteVulnDetectorImplTest.java index 42f4888f..3939e71c 100644 --- a/plugin/src/test/java/com/google/tsunami/plugin/RemoteVulnDetectorImplTest.java +++ b/plugin/src/test/java/com/google/tsunami/plugin/RemoteVulnDetectorImplTest.java @@ -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); @@ -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(); @@ -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);