36
36
import static org .mockito .Mockito .atLeastOnce ;
37
37
import static org .mockito .Mockito .mock ;
38
38
import static org .mockito .Mockito .never ;
39
- import static org .mockito .Mockito .timeout ;
39
+ import static org .mockito .Mockito .times ;
40
40
import static org .mockito .Mockito .verify ;
41
41
42
42
import com .google .common .collect .ImmutableMap ;
@@ -196,7 +196,7 @@ public void verify_basic_config() {
196
196
xdsDependencyManager = new XdsDependencyManager (xdsClient , xdsConfigWatcher , syncContext ,
197
197
serverName , serverName , nameResolverArgs , scheduler );
198
198
199
- verify (xdsConfigWatcher , timeout ( 1000 ) ).onUpdate (StatusOr .fromValue (defaultXdsConfig ));
199
+ verify (xdsConfigWatcher ).onUpdate (StatusOr .fromValue (defaultXdsConfig ));
200
200
testWatcher .verifyStats (1 , 0 );
201
201
}
202
202
@@ -206,13 +206,13 @@ public void verify_config_update() {
206
206
serverName , serverName , nameResolverArgs , scheduler );
207
207
208
208
InOrder inOrder = Mockito .inOrder (xdsConfigWatcher );
209
- inOrder .verify (xdsConfigWatcher , timeout ( 1000 ) ).onUpdate (StatusOr .fromValue (defaultXdsConfig ));
209
+ inOrder .verify (xdsConfigWatcher ).onUpdate (StatusOr .fromValue (defaultXdsConfig ));
210
210
testWatcher .verifyStats (1 , 0 );
211
211
assertThat (testWatcher .lastConfig ).isEqualTo (defaultXdsConfig );
212
212
213
213
XdsTestUtils .setAdsConfig (controlPlaneService , serverName , "RDS2" , "CDS2" , "EDS2" ,
214
214
ENDPOINT_HOSTNAME + "2" , ENDPOINT_PORT + 2 );
215
- inOrder .verify (xdsConfigWatcher , timeout ( 1000 ) ).onUpdate (ArgumentMatchers .notNull ());
215
+ inOrder .verify (xdsConfigWatcher ).onUpdate (ArgumentMatchers .notNull ());
216
216
testWatcher .verifyStats (2 , 0 );
217
217
assertThat (testWatcher .lastConfig ).isNotEqualTo (defaultXdsConfig );
218
218
}
@@ -222,7 +222,7 @@ public void verify_simple_aggregate() {
222
222
InOrder inOrder = Mockito .inOrder (xdsConfigWatcher );
223
223
xdsDependencyManager = new XdsDependencyManager (xdsClient , xdsConfigWatcher , syncContext ,
224
224
serverName , serverName , nameResolverArgs , scheduler );
225
- inOrder .verify (xdsConfigWatcher , timeout ( 1000 ) ).onUpdate (StatusOr .fromValue (defaultXdsConfig ));
225
+ inOrder .verify (xdsConfigWatcher ).onUpdate (StatusOr .fromValue (defaultXdsConfig ));
226
226
227
227
List <String > childNames = Arrays .asList ("clusterC" , "clusterB" , "clusterA" );
228
228
String rootName = "root_c" ;
@@ -233,7 +233,7 @@ public void verify_simple_aggregate() {
233
233
ADS_TYPE_URL_RDS , ImmutableMap .of (XdsTestUtils .RDS_NAME , routeConfig ));
234
234
235
235
XdsTestUtils .setAggregateCdsConfig (controlPlaneService , serverName , rootName , childNames );
236
- inOrder .verify (xdsConfigWatcher , timeout ( 1000 ) ).onUpdate (any ());
236
+ inOrder .verify (xdsConfigWatcher ).onUpdate (any ());
237
237
238
238
Map <String , StatusOr <XdsClusterConfig >> lastConfigClusters =
239
239
testWatcher .lastConfig .getClusters ();
@@ -281,13 +281,13 @@ public void testComplexRegisteredAggregate() throws IOException {
281
281
282
282
xdsDependencyManager = new XdsDependencyManager (xdsClient , xdsConfigWatcher , syncContext ,
283
283
serverName , serverName , nameResolverArgs , scheduler );
284
- inOrder .verify (xdsConfigWatcher , timeout ( 1000 ) ).onUpdate (any ());
284
+ inOrder .verify (xdsConfigWatcher ).onUpdate (any ());
285
285
286
286
Closeable subscription1 = xdsDependencyManager .subscribeToCluster (rootName1 );
287
- inOrder .verify (xdsConfigWatcher , timeout ( 1000 ) ).onUpdate (any ());
287
+ inOrder .verify (xdsConfigWatcher ).onUpdate (any ());
288
288
289
289
Closeable subscription2 = xdsDependencyManager .subscribeToCluster (rootName2 );
290
- inOrder .verify (xdsConfigWatcher , timeout ( 1000 ) ).onUpdate (xdsUpdateCaptor .capture ());
290
+ inOrder .verify (xdsConfigWatcher ).onUpdate (xdsUpdateCaptor .capture ());
291
291
testWatcher .verifyStats (3 , 0 );
292
292
ImmutableSet .Builder <String > builder = ImmutableSet .builder ();
293
293
Set <String > expectedClusters = builder .add (rootName1 ).add (rootName2 ).add (CLUSTER_NAME )
@@ -297,23 +297,23 @@ public void testComplexRegisteredAggregate() throws IOException {
297
297
298
298
// Close 1 subscription shouldn't affect the other or RDS subscriptions
299
299
subscription1 .close ();
300
- inOrder .verify (xdsConfigWatcher , timeout ( 1000 ) ).onUpdate (xdsUpdateCaptor .capture ());
300
+ inOrder .verify (xdsConfigWatcher ).onUpdate (xdsUpdateCaptor .capture ());
301
301
builder = ImmutableSet .builder ();
302
302
Set <String > expectedClusters2 =
303
303
builder .add (rootName2 ).add (CLUSTER_NAME ).addAll (childNames2 ).build ();
304
304
assertThat (xdsUpdateCaptor .getValue ().getValue ().getClusters ().keySet ())
305
305
.isEqualTo (expectedClusters2 );
306
306
307
307
subscription2 .close ();
308
- inOrder .verify (xdsConfigWatcher , timeout ( 1000 ) ).onUpdate (StatusOr .fromValue (defaultXdsConfig ));
308
+ inOrder .verify (xdsConfigWatcher ).onUpdate (StatusOr .fromValue (defaultXdsConfig ));
309
309
}
310
310
311
311
@ Test
312
312
public void testDelayedSubscription () {
313
313
InOrder inOrder = Mockito .inOrder (xdsConfigWatcher );
314
314
xdsDependencyManager = new XdsDependencyManager (xdsClient , xdsConfigWatcher , syncContext ,
315
315
serverName , serverName , nameResolverArgs , scheduler );
316
- inOrder .verify (xdsConfigWatcher , timeout ( 1000 ) ).onUpdate (StatusOr .fromValue (defaultXdsConfig ));
316
+ inOrder .verify (xdsConfigWatcher ).onUpdate (StatusOr .fromValue (defaultXdsConfig ));
317
317
318
318
String rootName1 = "root_c" ;
319
319
@@ -362,7 +362,7 @@ public void testMissingCdsAndEds() {
362
362
serverName , serverName , nameResolverArgs , scheduler );
363
363
364
364
fakeClock .forwardTime (16 , TimeUnit .SECONDS );
365
- verify (xdsConfigWatcher , timeout ( 1000 ) ).onUpdate (xdsUpdateCaptor .capture ());
365
+ verify (xdsConfigWatcher ).onUpdate (xdsUpdateCaptor .capture ());
366
366
367
367
List <StatusOr <XdsClusterConfig >> returnedClusters = new ArrayList <>();
368
368
for (String childName : childNames ) {
@@ -395,7 +395,7 @@ public void testMissingLds() {
395
395
serverName , ldsName , nameResolverArgs , scheduler );
396
396
397
397
fakeClock .forwardTime (16 , TimeUnit .SECONDS );
398
- verify (xdsConfigWatcher , timeout ( 1000 ) ).onUpdate (
398
+ verify (xdsConfigWatcher ).onUpdate (
399
399
argThat (StatusOrMatcher .hasStatus (statusHasCode (Status .Code .UNAVAILABLE )
400
400
.andDescriptionContains (ldsName ))));
401
401
@@ -411,7 +411,7 @@ public void testTcpListenerErrors() {
411
411
serverName , serverName , nameResolverArgs , scheduler );
412
412
413
413
fakeClock .forwardTime (16 , TimeUnit .SECONDS );
414
- verify (xdsConfigWatcher , timeout ( 1000 ) ).onUpdate (
414
+ verify (xdsConfigWatcher ).onUpdate (
415
415
argThat (StatusOrMatcher .hasStatus (
416
416
statusHasCode (Status .Code .UNAVAILABLE ).andDescriptionContains ("Not an API listener" ))));
417
417
@@ -429,7 +429,7 @@ public void testMissingRds() {
429
429
serverName , serverName , nameResolverArgs , scheduler );
430
430
431
431
fakeClock .forwardTime (16 , TimeUnit .SECONDS );
432
- verify (xdsConfigWatcher , timeout ( 1000 ) ).onUpdate (
432
+ verify (xdsConfigWatcher ).onUpdate (
433
433
argThat (StatusOrMatcher .hasStatus (statusHasCode (Status .Code .UNAVAILABLE )
434
434
.andDescriptionContains (rdsName ))));
435
435
@@ -446,7 +446,7 @@ public void testUpdateToMissingVirtualHost() {
446
446
serverName , serverName , nameResolverArgs , scheduler );
447
447
448
448
// Update with a config that has a virtual host that doesn't match the server name
449
- verify (xdsConfigWatcher , timeout ( 1000 ) ).onUpdate (xdsUpdateCaptor .capture ());
449
+ verify (xdsConfigWatcher ).onUpdate (xdsUpdateCaptor .capture ());
450
450
assertThat (xdsUpdateCaptor .getValue ().getStatus ().getDescription ())
451
451
.contains ("Failed to find virtual host matching hostname: " + serverName );
452
452
@@ -461,7 +461,7 @@ public void testCorruptLds() {
461
461
xdsDependencyManager = new XdsDependencyManager (xdsClient , xdsConfigWatcher , syncContext ,
462
462
serverName , ldsResourceName , nameResolverArgs , scheduler );
463
463
464
- verify (xdsConfigWatcher , timeout ( 1000 ) ).onUpdate (
464
+ verify (xdsConfigWatcher ).onUpdate (
465
465
argThat (StatusOrMatcher .hasStatus (
466
466
statusHasCode (Status .Code .UNAVAILABLE ).andDescriptionContains (ldsResourceName ))));
467
467
@@ -474,14 +474,14 @@ public void testChangeRdsName_fromLds() {
474
474
InOrder inOrder = Mockito .inOrder (xdsConfigWatcher );
475
475
xdsDependencyManager = new XdsDependencyManager (xdsClient , xdsConfigWatcher , syncContext ,
476
476
serverName , serverName , nameResolverArgs , scheduler );
477
- inOrder .verify (xdsConfigWatcher , timeout ( 1000 ) ).onUpdate (StatusOr .fromValue (defaultXdsConfig ));
477
+ inOrder .verify (xdsConfigWatcher ).onUpdate (StatusOr .fromValue (defaultXdsConfig ));
478
478
479
479
String newRdsName = "newRdsName1" ;
480
480
481
481
Listener clientListener = buildInlineClientListener (newRdsName , CLUSTER_NAME );
482
482
controlPlaneService .setXdsConfig (ADS_TYPE_URL_LDS ,
483
483
ImmutableMap .of (serverName , clientListener ));
484
- inOrder .verify (xdsConfigWatcher , timeout ( 1000 ) ).onUpdate (xdsUpdateCaptor .capture ());
484
+ inOrder .verify (xdsConfigWatcher ).onUpdate (xdsUpdateCaptor .capture ());
485
485
assertThat (xdsUpdateCaptor .getValue ().getValue ()).isNotEqualTo (defaultXdsConfig );
486
486
assertThat (xdsUpdateCaptor .getValue ().getValue ().getVirtualHost ().name ()).isEqualTo (newRdsName );
487
487
}
@@ -530,7 +530,7 @@ public void testMultipleParentsInCdsTree() throws IOException {
530
530
InOrder inOrder = Mockito .inOrder (xdsConfigWatcher );
531
531
xdsDependencyManager = new XdsDependencyManager (xdsClient , xdsConfigWatcher , syncContext ,
532
532
serverName , serverName , nameResolverArgs , scheduler );
533
- inOrder .verify (xdsConfigWatcher , timeout ( 1000 ) ).onUpdate (xdsUpdateCaptor .capture ());
533
+ inOrder .verify (xdsConfigWatcher ).onUpdate (xdsUpdateCaptor .capture ());
534
534
XdsConfig initialConfig = xdsUpdateCaptor .getValue ().getValue ();
535
535
536
536
// Make sure that adding subscriptions that rds points at doesn't change the config
@@ -551,12 +551,12 @@ public void testMultipleParentsInCdsTree() throws IOException {
551
551
XdsTestUtils .buildRouteConfiguration (serverName , XdsTestUtils .RDS_NAME , "clusterA11" );
552
552
controlPlaneService .setXdsConfig (
553
553
ADS_TYPE_URL_RDS , ImmutableMap .of (XdsTestUtils .RDS_NAME , newRouteConfig ));
554
- inOrder .verify (xdsConfigWatcher , timeout ( 1000 ) ).onUpdate (xdsUpdateCaptor .capture ());
554
+ inOrder .verify (xdsConfigWatcher ).onUpdate (xdsUpdateCaptor .capture ());
555
555
assertThat (xdsUpdateCaptor .getValue ().getValue ().getClusters ().keySet ().size ()).isEqualTo (4 );
556
556
557
557
// Now that it is released, we should only have A11
558
558
rootSub .close ();
559
- inOrder .verify (xdsConfigWatcher , timeout ( 1000 ) ).onUpdate (xdsUpdateCaptor .capture ());
559
+ inOrder .verify (xdsConfigWatcher ).onUpdate (xdsUpdateCaptor .capture ());
560
560
assertThat (xdsUpdateCaptor .getValue ().getValue ().getClusters ().keySet ())
561
561
.containsExactly ("clusterA11" );
562
562
}
@@ -591,7 +591,7 @@ public void testMultipleCdsReferToSameEds() {
591
591
// Start the actual test
592
592
xdsDependencyManager = new XdsDependencyManager (xdsClient , xdsConfigWatcher , syncContext ,
593
593
serverName , serverName , nameResolverArgs , scheduler );
594
- verify (xdsConfigWatcher , timeout ( 1000 ) ).onUpdate (xdsUpdateCaptor .capture ());
594
+ verify (xdsConfigWatcher ).onUpdate (xdsUpdateCaptor .capture ());
595
595
XdsConfig initialConfig = xdsUpdateCaptor .getValue ().getValue ();
596
596
assertThat (initialConfig .getClusters ().keySet ())
597
597
.containsExactly ("root" , "clusterA" , "clusterB" );
@@ -643,7 +643,7 @@ public void testChangeRdsName_FromLds_complexTree() {
643
643
Listener clientListener = buildInlineClientListener (newRdsName , "root" );
644
644
controlPlaneService .setXdsConfig (ADS_TYPE_URL_LDS ,
645
645
ImmutableMap .of (serverName , clientListener ));
646
- inOrder .verify (xdsConfigWatcher , timeout ( 1000 ) ).onUpdate (xdsUpdateCaptor .capture ());
646
+ inOrder .verify (xdsConfigWatcher ).onUpdate (xdsUpdateCaptor .capture ());
647
647
XdsConfig config = xdsUpdateCaptor .getValue ().getValue ();
648
648
assertThat (config .getVirtualHost ().name ()).isEqualTo (newRdsName );
649
649
assertThat (config .getClusters ().size ()).isEqualTo (4 );
@@ -655,7 +655,7 @@ public void testChangeAggCluster() {
655
655
656
656
xdsDependencyManager = new XdsDependencyManager (xdsClient , xdsConfigWatcher , syncContext ,
657
657
serverName , serverName , nameResolverArgs , scheduler );
658
- inOrder .verify (xdsConfigWatcher , timeout ( 1000 ) ).onUpdate (any ());
658
+ inOrder .verify (xdsConfigWatcher ).onUpdate (any ());
659
659
660
660
// Setup initial config A -> A1 -> (A11, A12)
661
661
Cluster rootCluster =
@@ -699,7 +699,7 @@ public void testChangeAggCluster() {
699
699
// Verify that the config is updated as expected
700
700
ClusterNameMatcher nameMatcher
701
701
= new ClusterNameMatcher (Arrays .asList ("root" , "clusterA21" , "clusterA22" ));
702
- inOrder .verify (xdsConfigWatcher , timeout ( 1000 ) ).onUpdate (argThat (nameMatcher ));
702
+ inOrder .verify (xdsConfigWatcher ).onUpdate (argThat (nameMatcher ));
703
703
}
704
704
705
705
@ Test
@@ -710,7 +710,7 @@ public void testCdsError() throws IOException {
710
710
xdsDependencyManager = new XdsDependencyManager (xdsClient , xdsConfigWatcher , syncContext ,
711
711
serverName , serverName , nameResolverArgs , scheduler );
712
712
713
- verify (xdsConfigWatcher , timeout ( 1000 ) ).onUpdate (xdsUpdateCaptor .capture ());
713
+ verify (xdsConfigWatcher ).onUpdate (xdsUpdateCaptor .capture ());
714
714
Status status = xdsUpdateCaptor .getValue ().getValue ()
715
715
.getClusters ().get (CLUSTER_NAME ).getStatus ();
716
716
assertThat (status .getDescription ()).contains (XdsTestUtils .CLUSTER_NAME );
@@ -724,7 +724,7 @@ public void ldsUpdateAfterShutdown() {
724
724
xdsDependencyManager = new XdsDependencyManager (xdsClient , xdsConfigWatcher , syncContext ,
725
725
serverName , serverName , nameResolverArgs , scheduler );
726
726
727
- verify (xdsConfigWatcher , timeout ( 1000 ) ).onUpdate (any ());
727
+ verify (xdsConfigWatcher ).onUpdate (any ());
728
728
729
729
@ SuppressWarnings ("unchecked" )
730
730
XdsClient .ResourceWatcher <XdsListenerResource .LdsUpdate > resourceWatcher =
@@ -734,7 +734,7 @@ public void ldsUpdateAfterShutdown() {
734
734
serverName ,
735
735
resourceWatcher ,
736
736
MoreExecutors .directExecutor ());
737
- verify (resourceWatcher , timeout ( 5000 ) ).onChanged (any ());
737
+ verify (resourceWatcher ).onChanged (any ());
738
738
739
739
syncContext .execute (() -> {
740
740
// Shutdown before any updates. This will unsubscribe from XdsClient, but only after this
@@ -743,7 +743,7 @@ public void ldsUpdateAfterShutdown() {
743
743
744
744
XdsTestUtils .setAdsConfig (controlPlaneService , serverName , "RDS2" , "CDS" , "EDS" ,
745
745
ENDPOINT_HOSTNAME , ENDPOINT_PORT );
746
- verify (resourceWatcher , timeout ( 5000 ). times (2 )).onChanged (any ());
746
+ verify (resourceWatcher , times (2 )).onChanged (any ());
747
747
xdsClient .cancelXdsResourceWatch (
748
748
XdsListenerResource .getInstance (), serverName , resourceWatcher );
749
749
});
@@ -757,7 +757,7 @@ public void rdsUpdateAfterShutdown() {
757
757
xdsDependencyManager = new XdsDependencyManager (xdsClient , xdsConfigWatcher , syncContext ,
758
758
serverName , serverName , nameResolverArgs , scheduler );
759
759
760
- verify (xdsConfigWatcher , timeout ( 1000 ) ).onUpdate (any ());
760
+ verify (xdsConfigWatcher ).onUpdate (any ());
761
761
762
762
@ SuppressWarnings ("unchecked" )
763
763
XdsClient .ResourceWatcher <XdsRouteConfigureResource .RdsUpdate > resourceWatcher =
@@ -767,7 +767,7 @@ public void rdsUpdateAfterShutdown() {
767
767
"RDS" ,
768
768
resourceWatcher ,
769
769
MoreExecutors .directExecutor ());
770
- verify (resourceWatcher , timeout ( 5000 ) ).onChanged (any ());
770
+ verify (resourceWatcher ).onChanged (any ());
771
771
772
772
syncContext .execute (() -> {
773
773
// Shutdown before any updates. This will unsubscribe from XdsClient, but only after this
@@ -776,7 +776,7 @@ public void rdsUpdateAfterShutdown() {
776
776
777
777
XdsTestUtils .setAdsConfig (controlPlaneService , serverName , "RDS" , "CDS2" , "EDS" ,
778
778
ENDPOINT_HOSTNAME , ENDPOINT_PORT );
779
- verify (resourceWatcher , timeout ( 5000 ). times (2 )).onChanged (any ());
779
+ verify (resourceWatcher , times (2 )).onChanged (any ());
780
780
xdsClient .cancelXdsResourceWatch (
781
781
XdsRouteConfigureResource .getInstance (), serverName , resourceWatcher );
782
782
});
@@ -790,7 +790,7 @@ public void cdsUpdateAfterShutdown() {
790
790
xdsDependencyManager = new XdsDependencyManager (xdsClient , xdsConfigWatcher , syncContext ,
791
791
serverName , serverName , nameResolverArgs , scheduler );
792
792
793
- verify (xdsConfigWatcher , timeout ( 1000 ) ).onUpdate (any ());
793
+ verify (xdsConfigWatcher ).onUpdate (any ());
794
794
795
795
@ SuppressWarnings ("unchecked" )
796
796
XdsClient .ResourceWatcher <XdsClusterResource .CdsUpdate > resourceWatcher =
@@ -800,7 +800,7 @@ public void cdsUpdateAfterShutdown() {
800
800
"CDS" ,
801
801
resourceWatcher ,
802
802
MoreExecutors .directExecutor ());
803
- verify (resourceWatcher , timeout ( 5000 ) ).onChanged (any ());
803
+ verify (resourceWatcher ).onChanged (any ());
804
804
805
805
syncContext .execute (() -> {
806
806
// Shutdown before any updates. This will unsubscribe from XdsClient, but only after this
@@ -809,7 +809,7 @@ public void cdsUpdateAfterShutdown() {
809
809
810
810
XdsTestUtils .setAdsConfig (controlPlaneService , serverName , "RDS" , "CDS" , "EDS2" ,
811
811
ENDPOINT_HOSTNAME , ENDPOINT_PORT );
812
- verify (resourceWatcher , timeout ( 5000 ). times (2 )).onChanged (any ());
812
+ verify (resourceWatcher , times (2 )).onChanged (any ());
813
813
xdsClient .cancelXdsResourceWatch (
814
814
XdsClusterResource .getInstance (), serverName , resourceWatcher );
815
815
});
@@ -823,7 +823,7 @@ public void edsUpdateAfterShutdown() {
823
823
xdsDependencyManager = new XdsDependencyManager (xdsClient , xdsConfigWatcher , syncContext ,
824
824
serverName , serverName , nameResolverArgs , scheduler );
825
825
826
- verify (xdsConfigWatcher , timeout ( 1000 ) ).onUpdate (any ());
826
+ verify (xdsConfigWatcher ).onUpdate (any ());
827
827
828
828
@ SuppressWarnings ("unchecked" )
829
829
XdsClient .ResourceWatcher <XdsEndpointResource .EdsUpdate > resourceWatcher =
@@ -833,7 +833,7 @@ public void edsUpdateAfterShutdown() {
833
833
"EDS" ,
834
834
resourceWatcher ,
835
835
MoreExecutors .directExecutor ());
836
- verify (resourceWatcher , timeout ( 5000 ) ).onChanged (any ());
836
+ verify (resourceWatcher ).onChanged (any ());
837
837
838
838
syncContext .execute (() -> {
839
839
// Shutdown before any updates. This will unsubscribe from XdsClient, but only after this
@@ -842,7 +842,7 @@ public void edsUpdateAfterShutdown() {
842
842
843
843
XdsTestUtils .setAdsConfig (controlPlaneService , serverName , "RDS" , "CDS" , "EDS" ,
844
844
ENDPOINT_HOSTNAME + "2" , ENDPOINT_PORT );
845
- verify (resourceWatcher , timeout ( 5000 ). times (2 )).onChanged (any ());
845
+ verify (resourceWatcher , times (2 )).onChanged (any ());
846
846
xdsClient .cancelXdsResourceWatch (
847
847
XdsEndpointResource .getInstance (), serverName , resourceWatcher );
848
848
});
0 commit comments