Skip to content
This repository has been archived by the owner on May 6, 2022. It is now read-only.

Commit

Permalink
added TestServiceInstanceDeleteWithAsyncUpdateInProgress
Browse files Browse the repository at this point in the history
  • Loading branch information
Jay Boyd committed Feb 12, 2018
1 parent 9931835 commit c59d259
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions test/integration/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,60 @@ func TestAsyncProvisionWithMultiplePolls(t *testing.T) {
})
}

func TestServiceInstanceDeleteWithAsyncUpdateInProgress(t *testing.T) {
const NumberOfInProgressResponses = 2
numberOfPolls := 0

ct := controllerTest{
t: t,
broker: getTestBroker(),
instance: getTestInstance(),
skipVerifyingInstanceSuccess: true,
setup: func(ct *controllerTest) {
ct.osbClient.UpdateInstanceReaction.(*fakeosb.UpdateInstanceReaction).Response.Async = true
ct.osbClient.PollLastOperationReaction = fakeosb.DynamicPollLastOperationReaction(
func(_ *osb.LastOperationRequest) (*osb.LastOperationResponse, error) {
numberOfPolls++
state := osb.StateInProgress
if numberOfPolls > NumberOfInProgressResponses {
state = osb.StateSucceeded
}
return &osb.LastOperationResponse{State: state}, nil
})
},
}
ct.run(func(ct *controllerTest) {

/* Update() results in this error:
controller_test.go:390: error updating instance: serviceinstances.servicecatalog.k8s.io "test-instance" is invalid:
metadata.resourceVersion: Invalid value: 0x0: must be specified for an update
*/

_, err := ct.client.ServiceInstances(ct.instance.Namespace).Update(ct.instance)
if err != nil {
t.Fatalf("error updating instance: %v", err)
}

if err := util.WaitForInstanceCondition(ct.client, ct.instance.Namespace, ct.instance.Name,
v1beta1.ServiceInstanceCondition{
Type: v1beta1.ServiceInstanceConditionReady,
Status: v1beta1.ConditionFalse,
Reason: "Updating",
}); err != nil {
t.Fatalf("error waiting for instance to be updating asynchronously: %v", err)
}
if err := ct.client.ServiceInstances(ct.instance.Namespace).Delete(ct.instance.Name, &metav1.DeleteOptions{}); err != nil {
t.Fatalf("failed to delete instance: %v", err)
}
if err := util.WaitForInstanceToNotExist(ct.client, ct.instance.Namespace, ct.instance.Name); err != nil {
t.Fatalf("error waiting for instance to not exist: %v", err)
}
// We deleted the instance above, clear it so test cleanup doesn't fail
// attempting to delete the instance again.
ct.instance = nil
})
}

func TestServiceInstanceDeleteWithAsyncOperationInProgress(t *testing.T) {
const NumberOfInProgressResponses = 2
numberOfPolls := 0
Expand Down

0 comments on commit c59d259

Please sign in to comment.