@@ -335,10 +335,13 @@ private static void verifyNoSubscribers(ControlPlaneRule rule) {
335
335
336
336
// This test takes a long time because of the 16 sec timeout for non-existent resource
337
337
@ Test
338
- public void connect_then_mainServerDown_fallbackServerUp () throws InterruptedException {
338
+ public void connect_then_mainServerDown_fallbackServerUp () throws Exception {
339
339
mainXdsServer .restartXdsServer ();
340
340
fallbackServer .restartXdsServer ();
341
- xdsClient = xdsClientPool .getObject ();
341
+ XdsClientImpl xdsClient = CommonBootstrapperTestUtils .createXdsClient (
342
+ new GrpcBootstrapperImpl ().bootstrap (defaultBootstrapOverride ()),
343
+ DEFAULT_XDS_TRANSPORT_FACTORY , fakeClock , new ExponentialBackoffPolicy .Provider (),
344
+ MessagePrinter .INSTANCE , xdsClientMetricReporter );
342
345
343
346
xdsClient .watchXdsResource (XdsListenerResource .getInstance (), MAIN_SERVER , ldsWatcher );
344
347
@@ -349,7 +352,12 @@ public void connect_then_mainServerDown_fallbackServerUp() throws InterruptedExc
349
352
verify (rdsWatcher , timeout (5000 )).onChanged (any ());
350
353
351
354
mainXdsServer .getServer ().shutdownNow ();
352
- TimeUnit .SECONDS .sleep (5 ); // TODO(lsafran) Use FakeClock so test runs faster
355
+ // Sleep for the ADS stream disconnect to be processed and for the retry to fail. Between those
356
+ // two sleeps we need the fakeClock to progress by 1 second to restart the ADS stream.
357
+ for (int i = 0 ; i < 5 ; i ++) {
358
+ fakeClock .forwardTime (1000 , TimeUnit .MILLISECONDS );
359
+ TimeUnit .SECONDS .sleep (1 );
360
+ }
353
361
354
362
// Shouldn't do fallback since all watchers are loaded
355
363
verify (ldsWatcher , never ()).onChanged (
@@ -372,7 +380,7 @@ public void connect_then_mainServerDown_fallbackServerUp() throws InterruptedExc
372
380
XdsListenerResource .LdsUpdate .forApiListener (FALLBACK_HTTP_CONNECTION_MANAGER ));
373
381
verify (ldsWatcher2 , timeout (5000 )).onChanged (
374
382
XdsListenerResource .LdsUpdate .forApiListener (FALLBACK_HTTP_CONNECTION_MANAGER ));
375
- verify (cdsWatcher , timeout (16000 )).onChanged (any ());
383
+ verify (cdsWatcher , timeout (5000 )).onChanged (any ());
376
384
377
385
xdsClient .watchXdsResource (
378
386
XdsRouteConfigureResource .getInstance (), FALLBACK_RDS_NAME , rdsWatcher3 );
@@ -381,7 +389,10 @@ public void connect_then_mainServerDown_fallbackServerUp() throws InterruptedExc
381
389
// Test that resource defined in main but not fallback is handled correctly
382
390
xdsClient .watchXdsResource (
383
391
XdsClusterResource .getInstance (), CLUSTER_NAME , cdsWatcher2 );
384
- verify (cdsWatcher2 , timeout (16000 )).onResourceDoesNotExist (eq (CLUSTER_NAME ));
392
+ verify (cdsWatcher2 , never ()).onResourceDoesNotExist (eq (CLUSTER_NAME ));
393
+ fakeClock .forwardTime (15000 , TimeUnit .MILLISECONDS ); // Does not exist timer
394
+ verify (cdsWatcher2 , timeout (5000 )).onResourceDoesNotExist (eq (CLUSTER_NAME ));
395
+ xdsClient .shutdown ();
385
396
}
386
397
387
398
@ Test
0 commit comments