Skip to content

Commit

Permalink
xds: remove race in TestUnmarshalCluster_WithUpdateValidatorFunc (#4836)
Browse files Browse the repository at this point in the history
  • Loading branch information
easwars committed Oct 1, 2021
1 parent b9f6253 commit 0997020
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions xds/internal/test/xds_security_config_nack_test.go
Expand Up @@ -222,25 +222,6 @@ func (s) TestUnmarshalCluster_WithUpdateValidatorFunc(t *testing.T) {
missingRootProviderInstance = "missing-root-provider-instance"
)

// setupManagementServer() sets up a bootstrap file with certificate
// provider instance names: `e2e.ServerSideCertProviderInstance` and
// `e2e.ClientSideCertProviderInstance`.
managementServer, nodeID, _, resolver, cleanup1 := setupManagementServer(t)
defer cleanup1()

port, cleanup2 := clientSetup(t, &testService{})
defer cleanup2()

// This creates a `Cluster` resource with a security config which refers to
// `e2e.ClientSideCertProviderInstance` for both root and identity certs.
resources := e2e.DefaultClientResources(e2e.ResourceParams{
DialTarget: serviceName,
NodeID: nodeID,
Host: "localhost",
Port: port,
SecLevel: e2e.SecurityLevelMTLS,
})

tests := []struct {
name string
securityConfig *v3corepb.TransportSocket
Expand Down Expand Up @@ -340,11 +321,30 @@ func (s) TestUnmarshalCluster_WithUpdateValidatorFunc(t *testing.T) {
},
}

ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)
defer cancel()
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
// setupManagementServer() sets up a bootstrap file with certificate
// provider instance names: `e2e.ServerSideCertProviderInstance` and
// `e2e.ClientSideCertProviderInstance`.
managementServer, nodeID, _, resolver, cleanup1 := setupManagementServer(t)
defer cleanup1()

port, cleanup2 := clientSetup(t, &testService{})
defer cleanup2()

// This creates a `Cluster` resource with a security config which
// refers to `e2e.ClientSideCertProviderInstance` for both root and
// identity certs.
resources := e2e.DefaultClientResources(e2e.ResourceParams{
DialTarget: serviceName,
NodeID: nodeID,
Host: "localhost",
Port: port,
SecLevel: e2e.SecurityLevelMTLS,
})
resources.Clusters[0].TransportSocket = test.securityConfig
ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)
defer cancel()
if err := managementServer.Update(ctx, resources); err != nil {
t.Fatal(err)
}
Expand Down

0 comments on commit 0997020

Please sign in to comment.