MCPcopy
hub / github.com/grpc/grpc-go / TestClientSideFederation

Method TestClientSideFederation

test/xds/xds_client_federation_test.go:57–146  ·  view source on GitHub ↗

TestClientSideFederation tests that federation is supported. In this test, some xDS responses contain resource names in another authority (in the new resource name style): - LDS: old style, no authority (default authority) - RDS: new style, in a different authority - CDS: old style, no authority (d

(t *testing.T)

Source from the content-addressed store, hash-verified

55// - CDS: old style, no authority (default authority)
56// - EDS: new style, in a different authority
57func (s) TestClientSideFederation(t *testing.T) {
58 // Start a management server as the default authority.
59 serverDefaultAuth := e2e.StartManagementServer(t, e2e.ManagementServerOptions{})
60
61 // Start another management server as the other authority.
62 const nonDefaultAuth = "non-default-auth"
63 serverAnotherAuth := e2e.StartManagementServer(t, e2e.ManagementServerOptions{})
64
65 // Create a bootstrap file in a temporary directory.
66 nodeID := uuid.New().String()
67 bootstrapContents, err := bootstrap.NewContentsForTesting(bootstrap.ConfigOptionsForTesting{
68 Servers: []byte(fmt.Sprintf(`[{
69 "server_uri": %q,
70 "channel_creds": [{"type": "insecure"}]
71 }]`, serverDefaultAuth.Address)),
72 Node: []byte(fmt.Sprintf(`{"id": "%s"}`, nodeID)),
73 ServerListenerResourceNameTemplate: e2e.ServerListenerResourceNameTemplate,
74 // Specify the address of the non-default authority.
75 Authorities: map[string]json.RawMessage{
76 nonDefaultAuth: []byte(fmt.Sprintf(`{
77 "xds_servers": [
78 {
79 "server_uri": %q,
80 "channel_creds": [{"type": "insecure"}]
81 }
82 ]
83 }`, serverAnotherAuth.Address)),
84 },
85 })
86 if err != nil {
87 t.Fatalf("Failed to create bootstrap file: %v", err)
88 }
89
90 resolver, err := internal.NewXDSResolverWithConfigForTesting.(func([]byte) (resolver.Builder, error))(bootstrapContents)
91 if err != nil {
92 t.Fatalf("Failed to create xDS resolver for testing: %v", err)
93 }
94 server := stubserver.StartTestService(t, nil)
95 defer server.Stop()
96
97 const serviceName = "my-service-client-side-xds"
98 // LDS is old style name.
99 ldsName := serviceName
100 // RDS is new style, with the non default authority.
101 rdsName := fmt.Sprintf("xdstp://%s/envoy.config.route.v3.RouteConfiguration/%s", nonDefaultAuth, "route-"+serviceName)
102 // CDS is old style name.
103 cdsName := "cluster-" + serviceName
104 // EDS is new style, with the non default authority.
105 edsName := fmt.Sprintf("xdstp://%s/envoy.config.route.v3.ClusterLoadAssignment/%s", nonDefaultAuth, "endpoints-"+serviceName)
106
107 // Split resources, put LDS/CDS in the default authority, and put RDS/EDS in
108 // the other authority.
109 resourcesDefault := e2e.UpdateOptions{
110 NodeID: nodeID,
111 // This has only LDS and CDS.
112 Listeners: []*v3listenerpb.Listener{e2e.DefaultClientListener(ldsName, rdsName)},
113 Clusters: []*v3clusterpb.Cluster{e2e.DefaultCluster(cdsName, edsName, e2e.SecurityLevelNone)},
114 SkipValidation: true,

Callers

nothing calls this directly

Calls 15

EmptyCallMethod · 0.95
StartManagementServerFunction · 0.92
NewContentsForTestingFunction · 0.92
StartTestServiceFunction · 0.92
DefaultClientListenerFunction · 0.92
DefaultClusterFunction · 0.92
DefaultRouteConfigFunction · 0.92
DefaultEndpointFunction · 0.92
ParsePortFunction · 0.92
NewClientFunction · 0.92
WithTransportCredentialsFunction · 0.92
NewCredentialsFunction · 0.92

Tested by

no test coverage detected