@@ -935,128 +935,6 @@ func (s) TestResolverMaxStreamDuration(t *testing.T) {
935935 }
936936}
937937
938- // Tests that clusters remain in service config if RPCs are in flight.
939- func (s ) TestResolverDelayedOnCommitted (t * testing.T ) {
940- // Spin up an xDS management server for the test.
941- ctx , cancel := context .WithTimeout (context .Background (), defaultTestTimeout )
942- defer cancel ()
943- nodeID := uuid .New ().String ()
944- mgmtServer , _ , _ , bc := setupManagementServerForTest (t , nodeID )
945-
946- // Configure resources on the management server.
947- resources := e2e .DefaultClientResources (e2e.ResourceParams {
948- DialTarget : defaultTestServiceName ,
949- NodeID : nodeID ,
950- Host : defaultTestHostname ,
951- Port : defaultTestPort [0 ],
952- SecLevel : e2e .SecurityLevelNone ,
953- })
954- if err := mgmtServer .Update (ctx , resources ); err != nil {
955- t .Fatal (err )
956- }
957-
958- stateCh , _ , _ := buildResolverForTarget (t , resolver.Target {URL : * testutils .MustParseURL ("xds:///" + defaultTestServiceName )}, bc )
959-
960- // Read the update pushed by the resolver to the ClientConn.
961- cs := verifyUpdateFromResolver (ctx , t , stateCh , wantServiceConfig (resources .Clusters [0 ].Name ))
962-
963- // Make an RPC, but do not commit it yet.
964- resOld , err := cs .SelectConfig (iresolver.RPCInfo {Context : ctx , Method : "/service/method" })
965- if err != nil {
966- t .Fatalf ("cs.SelectConfig(): %v" , err )
967- }
968- wantClusterName := fmt .Sprintf ("cluster:%s" , resources .Clusters [0 ].Name )
969- if cluster := clustermanager .PickedCluster (resOld .Context ); cluster != wantClusterName {
970- t .Fatalf ("Picked cluster is %q, want %q" , cluster , wantClusterName )
971- }
972-
973- // Delay resOld.OnCommitted(). As long as there are pending RPCs to removed
974- // clusters, they still appear in the service config.
975- oldClusterName := resources .Clusters [0 ].Name
976- // Update the route configuration resource on the management server to
977- // return a new cluster.
978- newClusterName := "new-" + defaultTestClusterName
979- newEndpointName := "new-" + defaultTestEndpointName
980- resources .Routes = []* v3routepb.RouteConfiguration {e2e .DefaultRouteConfig (resources .Routes [0 ].Name , defaultTestServiceName , newClusterName )}
981- // Appending the new cluster and endpoint resources to avoid getting
982- // resource removed errors.
983- resources .Clusters = append (resources .Clusters , e2e .DefaultCluster (newClusterName , newEndpointName , e2e .SecurityLevelNone ))
984- resources .Endpoints = append (resources .Endpoints , e2e .DefaultEndpoint (newEndpointName , defaultTestHostname , defaultTestPort ))
985- if err := mgmtServer .Update (ctx , resources ); err != nil {
986- t .Fatal (err )
987- }
988-
989- // Read the update pushed by the resolver to the ClientConn and ensure the
990- // old cluster is present in the service config. Also ensure that the newly
991- // returned config selector does not hold a reference to the old cluster.
992- wantSC := fmt .Sprintf (`
993- {
994- "loadBalancingConfig": [
995- {
996- "xds_cluster_manager_experimental": {
997- "children": {
998- "cluster:%s": {
999- "childPolicy": [
1000- {
1001- "cds_experimental": {
1002- "cluster": "%s"
1003- }
1004- }
1005- ]
1006- },
1007- "cluster:%s": {
1008- "childPolicy": [
1009- {
1010- "cds_experimental": {
1011- "cluster": "%s"
1012- }
1013- }
1014- ]
1015- }
1016- }
1017- }
1018- }
1019- ]
1020- }` , oldClusterName , oldClusterName , newClusterName , newClusterName )
1021- cs = verifyUpdateFromResolver (ctx , t , stateCh , wantSC )
1022-
1023- resNew , err := cs .SelectConfig (iresolver.RPCInfo {Context : ctx , Method : "/service/method" })
1024- if err != nil {
1025- t .Fatalf ("cs.SelectConfig(): %v" , err )
1026- }
1027- wantClusterName = fmt .Sprintf ("cluster:%s" , newClusterName )
1028- if cluster := clustermanager .PickedCluster (resNew .Context ); cluster != wantClusterName {
1029- t .Fatalf ("Picked cluster is %q, want %q" , cluster , wantClusterName )
1030- }
1031-
1032- // Invoke OnCommitted on the old RPC; should lead to a service config update
1033- // that deletes the old cluster, as the old cluster no longer has any
1034- // pending RPCs.
1035- resOld .OnCommitted ()
1036-
1037- wantSC = fmt .Sprintf (`
1038- {
1039- "loadBalancingConfig": [
1040- {
1041- "xds_cluster_manager_experimental": {
1042- "children": {
1043- "cluster:%s": {
1044- "childPolicy": [
1045- {
1046- "cds_experimental": {
1047- "cluster": "%s"
1048- }
1049- }
1050- ]
1051- }
1052- }
1053- }
1054- }
1055- ]
1056- }` , newClusterName , newClusterName )
1057- verifyUpdateFromResolver (ctx , t , stateCh , wantSC )
1058- }
1059-
1060938// Tests the case where two LDS updates with the same RDS name to watch are
1061939// received without an RDS in between. Those LDS updates shouldn't trigger a
1062940// service config update.
0 commit comments