Skip to content

Commit

Permalink
Fix flaky dynamic/TestConfigure test (#2130)
Browse files Browse the repository at this point in the history
73a8116 introduced a test with a race condition between parallel tests.
This PR separates the stateful and stateless tests into TestConfigure
and TestCheckConfig respectively. It removes the race condition.

Fixes #2129
  • Loading branch information
iwahbe authored Jun 26, 2024
1 parent 73a8116 commit 674cf5b
Showing 1 changed file with 39 additions and 17 deletions.
56 changes: 39 additions & 17 deletions dynamic/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,45 @@ func TestConfigure(t *testing.T) {
t.Parallel()
skipWindows(t)

// We test that the provider can be
// 1. parameterized
// 2. configured
// 3. that the configuration is visible to other resources/invokes
s := grpcTestServer(context.Background(), t)

assertGRPCCall(s.Parameterize, &pulumirpc.ParameterizeRequest{
Parameters: &pulumirpc.ParameterizeRequest_Args{
Args: &pulumirpc.ParameterizeRequest_ParametersArgs{
Args: []string{pfProviderPath(t)},
},
},
}, noParallel, expect(autogold.Expect(`{
"name": "pfprovider",
"version": "0.0.0"
}`)))(t)

assertGRPCCall(s.Configure, &pulumirpc.ConfigureRequest{
Args: marshal(resource.PropertyMap{
"endpoint": resource.NewProperty("my-endpoint"),
}),
}, noParallel, expect(autogold.Expect(`{
"acceptResources": true,
"supportsPreview": true
}`)))(t)

assertGRPCCall(s.Invoke, &pulumirpc.InvokeRequest{
Tok: "pfprovider:index/getConfigEndpoint:getConfigEndpoint",
}, noParallel, expect(autogold.Expect(`{
"return": {
"endpoint": "my-endpoint"
}
}`)))(t)
}

func TestCheckConfig(t *testing.T) {
t.Parallel()
skipWindows(t)

s := grpcTestServer(context.Background(), t)

t.Run("parameterize", assertGRPCCall(s.Parameterize, &pulumirpc.ParameterizeRequest{
Expand Down Expand Up @@ -228,23 +267,6 @@ func TestConfigure(t *testing.T) {
"endpoint": 123.456
}
}`))))

t.Run("configure (args)", assertGRPCCall(s.Configure, &pulumirpc.ConfigureRequest{
Args: marshal(resource.PropertyMap{
"endpoint": resource.NewProperty("my-endpoint"),
}),
}, expect(autogold.Expect(`{
"acceptResources": true,
"supportsPreview": true
}`))))

t.Run("validate config", assertGRPCCall(s.Invoke, &pulumirpc.InvokeRequest{
Tok: "pfprovider:index/getConfigEndpoint:getConfigEndpoint",
}, expect(autogold.Expect(`{
"return": {
"endpoint": "my-endpoint"
}
}`))))
}

type assertGRPCCallOptions struct {
Expand Down

0 comments on commit 674cf5b

Please sign in to comment.