@@ -299,7 +299,7 @@ private void verifyResponse(ClientStatusResponse response) {
299
299
assertThat (response .getConfigCount ()).isEqualTo (1 );
300
300
ClientConfig clientConfig = response .getConfig (0 );
301
301
verifyClientConfigNode (clientConfig );
302
- verifyClientConfigNoResources ( XDS_CLIENT_NO_RESOURCES , clientConfig );
302
+ assertThat ( clientConfig . getGenericXdsConfigsList ()). isEmpty ( );
303
303
assertThat (clientConfig .getClientScope ()).isEmpty ();
304
304
}
305
305
@@ -310,7 +310,7 @@ private Collection<String> verifyMultiResponse(ClientStatusResponse response, in
310
310
for (int i = 0 ; i < numExpected ; i ++) {
311
311
ClientConfig clientConfig = response .getConfig (i );
312
312
verifyClientConfigNode (clientConfig );
313
- verifyClientConfigNoResources ( XDS_CLIENT_NO_RESOURCES , clientConfig );
313
+ assertThat ( clientConfig . getGenericXdsConfigsList ()). isEmpty ( );
314
314
clientScopes .add (clientConfig .getClientScope ());
315
315
}
316
316
@@ -382,16 +382,6 @@ public void getClientConfigForXdsClient_subscribedResourcesToGenericXdsConfig()
382
382
.put (EDS , ImmutableMap .of ("subscribedResourceName.EDS" , METADATA_ACKED_EDS ))
383
383
.buildOrThrow ();
384
384
}
385
-
386
- @ Override
387
- public Map <String , XdsResourceType <?>> getSubscribedResourceTypesWithTypeUrl () {
388
- return ImmutableMap .of (
389
- LDS .typeUrl (), LDS ,
390
- RDS .typeUrl (), RDS ,
391
- CDS .typeUrl (), CDS ,
392
- EDS .typeUrl (), EDS
393
- );
394
- }
395
385
};
396
386
ClientConfig clientConfig = CsdsService .getClientConfigForXdsClient (fakeXdsClient ,
397
387
FAKE_CLIENT_SCOPE );
@@ -403,31 +393,31 @@ public Map<String, XdsResourceType<?>> getSubscribedResourceTypesWithTypeUrl() {
403
393
// is propagated to the correct resource types.
404
394
int xdsConfigCount = clientConfig .getGenericXdsConfigsCount ();
405
395
assertThat (xdsConfigCount ).isEqualTo (4 );
406
- Map <XdsResourceType <?> , GenericXdsConfig > configDumps = mapConfigDumps (fakeXdsClient ,
407
- clientConfig );
408
- assertThat ( configDumps . keySet ()). containsExactly (LDS , RDS , CDS , EDS );
396
+ Map <String , GenericXdsConfig > configDumps = mapConfigDumps (clientConfig );
397
+ assertThat ( configDumps . keySet ())
398
+ . containsExactly (LDS . typeUrl () , RDS . typeUrl () , CDS . typeUrl () , EDS . typeUrl () );
409
399
410
400
// LDS.
411
- GenericXdsConfig genericXdsConfigLds = configDumps .get (LDS );
401
+ GenericXdsConfig genericXdsConfigLds = configDumps .get (LDS . typeUrl () );
412
402
assertThat (genericXdsConfigLds .getName ()).isEqualTo ("subscribedResourceName.LDS" );
413
403
assertThat (genericXdsConfigLds .getClientStatus ()).isEqualTo (ClientResourceStatus .ACKED );
414
404
assertThat (genericXdsConfigLds .getVersionInfo ()).isEqualTo (VERSION_ACK_LDS );
415
405
assertThat (genericXdsConfigLds .getXdsConfig ()).isEqualTo (RAW_LISTENER );
416
406
417
407
// RDS.
418
- GenericXdsConfig genericXdsConfigRds = configDumps .get (RDS );
408
+ GenericXdsConfig genericXdsConfigRds = configDumps .get (RDS . typeUrl () );
419
409
assertThat (genericXdsConfigRds .getClientStatus ()).isEqualTo (ClientResourceStatus .ACKED );
420
410
assertThat (genericXdsConfigRds .getVersionInfo ()).isEqualTo (VERSION_ACK_RDS );
421
411
assertThat (genericXdsConfigRds .getXdsConfig ()).isEqualTo (RAW_ROUTE_CONFIGURATION );
422
412
423
413
// CDS.
424
- GenericXdsConfig genericXdsConfigCds = configDumps .get (CDS );
414
+ GenericXdsConfig genericXdsConfigCds = configDumps .get (CDS . typeUrl () );
425
415
assertThat (genericXdsConfigCds .getClientStatus ()).isEqualTo (ClientResourceStatus .ACKED );
426
416
assertThat (genericXdsConfigCds .getVersionInfo ()).isEqualTo (VERSION_ACK_CDS );
427
417
assertThat (genericXdsConfigCds .getXdsConfig ()).isEqualTo (RAW_CLUSTER );
428
418
429
419
// RDS.
430
- GenericXdsConfig genericXdsConfigEds = configDumps .get (EDS );
420
+ GenericXdsConfig genericXdsConfigEds = configDumps .get (EDS . typeUrl () );
431
421
assertThat (genericXdsConfigEds .getClientStatus ()).isEqualTo (ClientResourceStatus .ACKED );
432
422
assertThat (genericXdsConfigEds .getVersionInfo ()).isEqualTo (VERSION_ACK_EDS );
433
423
assertThat (genericXdsConfigEds .getXdsConfig ()).isEqualTo (RAW_CLUSTER_LOAD_ASSIGNMENT );
@@ -438,23 +428,11 @@ public void getClientConfigForXdsClient_noSubscribedResources() throws Interrupt
438
428
ClientConfig clientConfig =
439
429
CsdsService .getClientConfigForXdsClient (XDS_CLIENT_NO_RESOURCES , FAKE_CLIENT_SCOPE );
440
430
verifyClientConfigNode (clientConfig );
441
- verifyClientConfigNoResources ( XDS_CLIENT_NO_RESOURCES , clientConfig );
431
+ assertThat ( clientConfig . getGenericXdsConfigsList ()). isEmpty ( );
442
432
assertThat (clientConfig .getClientScope ()).isEqualTo (FAKE_CLIENT_SCOPE );
443
433
}
444
434
}
445
435
446
- /**
447
- * Assuming {@link MetadataToProtoTests} passes, and metadata converted to corresponding
448
- * config dumps correctly, perform a minimal verification of the general shape of ClientConfig.
449
- */
450
- private static void verifyClientConfigNoResources (FakeXdsClient xdsClient ,
451
- ClientConfig clientConfig ) {
452
- int xdsConfigCount = clientConfig .getGenericXdsConfigsCount ();
453
- assertThat (xdsConfigCount ).isEqualTo (0 );
454
- Map <XdsResourceType <?>, GenericXdsConfig > configDumps = mapConfigDumps (xdsClient , clientConfig );
455
- assertThat (configDumps ).isEmpty ();
456
- }
457
-
458
436
/**
459
437
* Assuming {@link EnvoyProtoDataTest#convertNode} passes, perform a minimal check,
460
438
* just verify the node itself is the one we expect.
@@ -465,21 +443,17 @@ private static void verifyClientConfigNode(ClientConfig clientConfig) {
465
443
assertThat (node ).isEqualTo (BOOTSTRAP_NODE .toEnvoyProtoNode ());
466
444
}
467
445
468
- private static Map <XdsResourceType <?>, GenericXdsConfig > mapConfigDumps (FakeXdsClient client ,
469
- ClientConfig config ) {
470
- Map <XdsResourceType <?>, GenericXdsConfig > xdsConfigMap = new HashMap <>();
446
+ private static Map <String , GenericXdsConfig > mapConfigDumps (ClientConfig config ) {
447
+ Map <String , GenericXdsConfig > xdsConfigMap = new HashMap <>();
471
448
List <GenericXdsConfig > xdsConfigList = config .getGenericXdsConfigsList ();
472
449
for (GenericXdsConfig genericXdsConfig : xdsConfigList ) {
473
- XdsResourceType <?> type = client .getSubscribedResourceTypesWithTypeUrl ()
474
- .get (genericXdsConfig .getTypeUrl ());
475
- assertThat (type ).isNotNull ();
476
- assertThat (xdsConfigMap ).doesNotContainKey (type );
477
- xdsConfigMap .put (type , genericXdsConfig );
450
+ assertThat (xdsConfigMap ).doesNotContainKey (genericXdsConfig .getTypeUrl ());
451
+ xdsConfigMap .put (genericXdsConfig .getTypeUrl (), genericXdsConfig );
478
452
}
479
453
return xdsConfigMap ;
480
454
}
481
455
482
- private static class FakeXdsClient extends XdsClient implements XdsClient . ResourceStore {
456
+ private static class FakeXdsClient extends XdsClient {
483
457
protected Map <XdsResourceType <?>, Map <String , ResourceMetadata >>
484
458
getSubscribedResourcesMetadata () {
485
459
return ImmutableMap .of ();
@@ -495,24 +469,6 @@ private static class FakeXdsClient extends XdsClient implements XdsClient.Resour
495
469
public BootstrapInfo getBootstrapInfo () {
496
470
return BOOTSTRAP_INFO ;
497
471
}
498
-
499
- @ Nullable
500
- @ Override
501
- public Collection <String > getSubscribedResources (
502
- ServerInfo serverInfo , XdsResourceType <? extends ResourceUpdate > type ) {
503
- return null ;
504
- }
505
-
506
- @ Override
507
- public void startMissingResourceTimers (Collection <String > resourceNames ,
508
- XdsResourceType <?> resourceType ) {
509
- // do nothing
510
- }
511
-
512
- @ Override
513
- public Map <String , XdsResourceType <?>> getSubscribedResourceTypesWithTypeUrl () {
514
- return ImmutableMap .of ();
515
- }
516
472
}
517
473
518
474
private static class FakeXdsClientPoolFactory implements XdsClientPoolFactory {
0 commit comments