Skip to content

Commit 789c4b2

Browse files
Jeff Peelerarschles
Jeff Peeler
authored andcommitted
Use dynamic reaction to fix data race (openshift#1650)
Modifying the controller reactions after the setup function (in the test function in this case) leads to races. Using a dynamic reaction solves this issue. Also, change the test to look for a successful provision rather than a request in flight condition so that no timing issues can occur. Closes openshift#1625
1 parent f1be763 commit 789c4b2

File tree

1 file changed

+37
-37
lines changed

1 file changed

+37
-37
lines changed

Diff for: test/integration/controller_instance_test.go

+37-37
Original file line numberDiff line numberDiff line change
@@ -1261,43 +1261,43 @@ func TestDeleteServiceInstance(t *testing.T) {
12611261
}
12621262
},
12631263
},
1264-
// {
1265-
// name: "deprovision instance after in progress provision",
1266-
// skipVerifyingInstanceSuccess: true,
1267-
// setup: func(ct *controllerTest) {
1268-
// ct.osbClient.PollLastOperationReaction = &fakeosb.PollLastOperationReaction{
1269-
// Response: &osb.LastOperationResponse{
1270-
// State: osb.StateInProgress,
1271-
// },
1272-
// }
1273-
// ct.osbClient.ProvisionReaction = &fakeosb.ProvisionReaction{
1274-
// Response: &osb.ProvisionResponse{
1275-
// Async: true,
1276-
// },
1277-
// }
1278-
// ct.osbClient.DeprovisionReaction = &fakeosb.DeprovisionReaction{
1279-
// Response: &osb.DeprovisionResponse{},
1280-
// }
1281-
// },
1282-
// testFunction: func(ct *controllerTest) {
1283-
// verifyCondition := v1beta1.ServiceInstanceCondition{
1284-
// Type: v1beta1.ServiceInstanceConditionReady,
1285-
// Status: v1beta1.ConditionFalse,
1286-
// Reason: "ProvisionRequestInFlight",
1287-
// }
1288-
// if err := util.WaitForInstanceCondition(ct.client, testNamespace, testInstanceName, verifyCondition); err != nil {
1289-
// t.Fatalf("error waiting for instance condition: %v", err)
1290-
// }
1291-
// ct.osbClient.PollLastOperationReaction = &fakeosb.PollLastOperationReaction{
1292-
// Response: &osb.LastOperationResponse{
1293-
// State: osb.StateSucceeded,
1294-
// },
1295-
// }
1296-
// if err := util.WaitForInstanceReconciledGeneration(ct.client, testNamespace, testInstanceName, ct.instance.Status.ReconciledGeneration+1); err != nil {
1297-
// t.Fatalf("error waiting for instance to reconcile: %v", err)
1298-
// }
1299-
// },
1300-
// },
1264+
{
1265+
name: "deprovision instance after in progress provision",
1266+
skipVerifyingInstanceSuccess: true,
1267+
setup: func(ct *controllerTest) {
1268+
ct.osbClient.PollLastOperationReaction = fakeosb.DynamicPollLastOperationReaction(
1269+
getLastOperationResponseByPollCountReactions(2, []fakeosb.PollLastOperationReaction{
1270+
fakeosb.PollLastOperationReaction{
1271+
Response: &osb.LastOperationResponse{
1272+
State: osb.StateInProgress,
1273+
},
1274+
},
1275+
fakeosb.PollLastOperationReaction{
1276+
Response: &osb.LastOperationResponse{
1277+
State: osb.StateSucceeded,
1278+
},
1279+
},
1280+
}))
1281+
ct.osbClient.ProvisionReaction = &fakeosb.ProvisionReaction{
1282+
Response: &osb.ProvisionResponse{
1283+
Async: true,
1284+
},
1285+
}
1286+
ct.osbClient.DeprovisionReaction = &fakeosb.DeprovisionReaction{
1287+
Response: &osb.DeprovisionResponse{},
1288+
}
1289+
},
1290+
testFunction: func(ct *controllerTest) {
1291+
verifyCondition := v1beta1.ServiceInstanceCondition{
1292+
Type: v1beta1.ServiceInstanceConditionReady,
1293+
Status: v1beta1.ConditionTrue,
1294+
Reason: "ProvisionedSuccessfully",
1295+
}
1296+
if err := util.WaitForInstanceCondition(ct.client, testNamespace, testInstanceName, verifyCondition); err != nil {
1297+
t.Fatalf("error waiting for instance condition: %v", err)
1298+
}
1299+
},
1300+
},
13011301
}
13021302

13031303
for _, tc := range cases {

0 commit comments

Comments
 (0)