github.com/kyma-project/kyma-environment-broker@v0.0.1/cmd/broker/deprovisioning_test.go (about) 1 package main 2 3 import ( 4 "testing" 5 6 "github.com/kyma-project/kyma-environment-broker/internal" 7 "github.com/pivotal-cf/brokerapi/v8/domain" 8 ) 9 10 func TestKymaDeprovision(t *testing.T) { 11 // given 12 runtimeOptions := RuntimeOptions{ 13 GlobalAccountID: globalAccountID, 14 SubAccountID: subAccountID, 15 Provider: internal.AWS, 16 } 17 18 suite := NewDeprovisioningSuite(t) 19 instanceId := suite.CreateProvisionedRuntime(runtimeOptions) 20 21 // when 22 deprovisioningOperationID := suite.CreateDeprovisioning(deprovisioningOpID, instanceId) 23 24 // then 25 suite.WaitForDeprovisioningState(deprovisioningOperationID, domain.InProgress) 26 suite.AssertProvisionerStartedDeprovisioning(deprovisioningOperationID) 27 28 // when 29 suite.FinishDeprovisioningOperationByProvisioner(deprovisioningOperationID) 30 31 // then 32 suite.WaitForDeprovisioningState(deprovisioningOperationID, domain.Succeeded) 33 suite.AssertInstanceRemoved(instanceId) 34 } 35 36 func TestKymaReDeprovisionSucceeded(t *testing.T) { 37 // given 38 runtimeOptions := RuntimeOptions{ 39 GlobalAccountID: globalAccountID, 40 SubAccountID: badSubAccountID, 41 Provider: internal.AWS, 42 } 43 44 suite := NewDeprovisioningSuite(t) 45 instanceId := suite.CreateProvisionedRuntime(runtimeOptions) 46 47 // when 48 deprovisioningOperationID := suite.CreateDeprovisioning(deprovisioningOpID, instanceId) 49 50 // then 51 suite.WaitForDeprovisioningState(deprovisioningOperationID, domain.InProgress) 52 suite.AssertProvisionerStartedDeprovisioning(deprovisioningOperationID) 53 54 // when 55 suite.FinishDeprovisioningOperationByProvisioner(deprovisioningOperationID) 56 57 // then 58 suite.WaitForDeprovisioningState(deprovisioningOperationID, domain.Succeeded) 59 suite.AssertInstanceNotRemoved(instanceId) 60 61 // when 62 runtimeOptions.SubAccountID = subAccountID 63 suite.updateSubAccountIDForDeprovisioningOperation(runtimeOptions, instanceId) 64 reDeprovisioningOperationID := suite.CreateDeprovisioning(reDeprovisioningOpID, instanceId) 65 66 // then 67 suite.WaitForDeprovisioningState(reDeprovisioningOperationID, domain.InProgress) 68 suite.AssertProvisionerStartedDeprovisioning(reDeprovisioningOperationID) 69 70 // when 71 suite.FinishDeprovisioningOperationByProvisioner(reDeprovisioningOperationID) 72 73 // then 74 suite.WaitForDeprovisioningState(reDeprovisioningOperationID, domain.Succeeded) 75 suite.AssertInstanceRemoved(instanceId) 76 } 77 78 func TestKymaReDeprovisionFailed(t *testing.T) { 79 // given 80 runtimeOptions := RuntimeOptions{ 81 GlobalAccountID: globalAccountID, 82 SubAccountID: badSubAccountID, 83 Provider: internal.AWS, 84 } 85 86 suite := NewDeprovisioningSuite(t) 87 instanceId := suite.CreateProvisionedRuntime(runtimeOptions) 88 // when 89 deprovisioningOperationID := suite.CreateDeprovisioning(deprovisioningOpID, instanceId) 90 91 // then 92 suite.WaitForDeprovisioningState(deprovisioningOperationID, domain.InProgress) 93 suite.AssertProvisionerStartedDeprovisioning(deprovisioningOperationID) 94 95 // when 96 suite.FinishDeprovisioningOperationByProvisioner(deprovisioningOperationID) 97 98 // then 99 suite.WaitForDeprovisioningState(deprovisioningOperationID, domain.Succeeded) 100 suite.AssertInstanceNotRemoved(instanceId) 101 102 // when 103 reDeprovisioningOperationID := suite.CreateDeprovisioning(reDeprovisioningOpID, instanceId) 104 105 // then 106 suite.WaitForDeprovisioningState(reDeprovisioningOperationID, domain.InProgress) 107 suite.AssertProvisionerStartedDeprovisioning(reDeprovisioningOperationID) 108 109 // when 110 suite.FinishDeprovisioningOperationByProvisioner(reDeprovisioningOperationID) 111 112 // then 113 suite.WaitForDeprovisioningState(reDeprovisioningOperationID, domain.Succeeded) 114 suite.AssertInstanceNotRemoved(instanceId) 115 }