Skip to content

Commit 674cf5b

Browse files
authored
Fix flaky dynamic/TestConfigure test (#2130)
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
1 parent 73a8116 commit 674cf5b

File tree

1 file changed

+39
-17
lines changed

1 file changed

+39
-17
lines changed

dynamic/provider_test.go

Lines changed: 39 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,45 @@ func TestConfigure(t *testing.T) {
195195
t.Parallel()
196196
skipWindows(t)
197197

198+
// We test that the provider can be
199+
// 1. parameterized
200+
// 2. configured
201+
// 3. that the configuration is visible to other resources/invokes
202+
s := grpcTestServer(context.Background(), t)
203+
204+
assertGRPCCall(s.Parameterize, &pulumirpc.ParameterizeRequest{
205+
Parameters: &pulumirpc.ParameterizeRequest_Args{
206+
Args: &pulumirpc.ParameterizeRequest_ParametersArgs{
207+
Args: []string{pfProviderPath(t)},
208+
},
209+
},
210+
}, noParallel, expect(autogold.Expect(`{
211+
"name": "pfprovider",
212+
"version": "0.0.0"
213+
}`)))(t)
214+
215+
assertGRPCCall(s.Configure, &pulumirpc.ConfigureRequest{
216+
Args: marshal(resource.PropertyMap{
217+
"endpoint": resource.NewProperty("my-endpoint"),
218+
}),
219+
}, noParallel, expect(autogold.Expect(`{
220+
"acceptResources": true,
221+
"supportsPreview": true
222+
}`)))(t)
223+
224+
assertGRPCCall(s.Invoke, &pulumirpc.InvokeRequest{
225+
Tok: "pfprovider:index/getConfigEndpoint:getConfigEndpoint",
226+
}, noParallel, expect(autogold.Expect(`{
227+
"return": {
228+
"endpoint": "my-endpoint"
229+
}
230+
}`)))(t)
231+
}
232+
233+
func TestCheckConfig(t *testing.T) {
234+
t.Parallel()
235+
skipWindows(t)
236+
198237
s := grpcTestServer(context.Background(), t)
199238

200239
t.Run("parameterize", assertGRPCCall(s.Parameterize, &pulumirpc.ParameterizeRequest{
@@ -228,23 +267,6 @@ func TestConfigure(t *testing.T) {
228267
"endpoint": 123.456
229268
}
230269
}`))))
231-
232-
t.Run("configure (args)", assertGRPCCall(s.Configure, &pulumirpc.ConfigureRequest{
233-
Args: marshal(resource.PropertyMap{
234-
"endpoint": resource.NewProperty("my-endpoint"),
235-
}),
236-
}, expect(autogold.Expect(`{
237-
"acceptResources": true,
238-
"supportsPreview": true
239-
}`))))
240-
241-
t.Run("validate config", assertGRPCCall(s.Invoke, &pulumirpc.InvokeRequest{
242-
Tok: "pfprovider:index/getConfigEndpoint:getConfigEndpoint",
243-
}, expect(autogold.Expect(`{
244-
"return": {
245-
"endpoint": "my-endpoint"
246-
}
247-
}`))))
248270
}
249271

250272
type assertGRPCCallOptions struct {

0 commit comments

Comments
 (0)