@@ -33,10 +33,19 @@ import (
33
33
"sigs.k8s.io/cluster-api/test/framework/clusterctl"
34
34
"sigs.k8s.io/cluster-api/util"
35
35
36
+ "sigs.k8s.io/cluster-api-provider-ibmcloud/test/helpers"
37
+
36
38
. "github.com/onsi/ginkgo/v2"
37
39
. "github.com/onsi/gomega"
38
40
)
39
41
42
+ const (
43
+ // powervsRemediationFlavor represents the flavor of PowerVS cluster creation being tested.
44
+ powervsRemediationFlavor = "powervs-md-remediation"
45
+ kubernetesVersion = "KUBERNETES_VERSION"
46
+ serviceInstanceID = "IBMPOWERVS_SERVICE_INSTANCE_ID"
47
+ )
48
+
40
49
var _ = Describe ("Workload cluster creation" , func () {
41
50
var (
42
51
ctx = context .TODO ()
@@ -55,7 +64,7 @@ var _ = Describe("Workload cluster creation", func() {
55
64
Expect (bootstrapClusterProxy ).ToNot (BeNil (), "Invalid argument. bootstrapClusterProxy can't be nil when calling %s spec" , specName )
56
65
Expect (os .MkdirAll (artifactFolder , 0750 )).To (Succeed (), "Invalid argument. artifactFolder can't be created for %s spec" , specName )
57
66
58
- Expect (e2eConfig .Variables ).To (HaveKey (KubernetesVersion ))
67
+ Expect (e2eConfig .Variables ).To (HaveKey (kubernetesVersion ))
59
68
60
69
clusterName = fmt .Sprintf ("capibm-e2e-%s" , util .RandomString (6 ))
61
70
@@ -70,6 +79,14 @@ var _ = Describe("Workload cluster creation", func() {
70
79
// Path to the CNI file is defined in the config
71
80
Expect (e2eConfig .Variables ).To (HaveKey (capi_e2e .CNIPath ), "Missing %s variable in the config" , capi_e2e .CNIPath )
72
81
cniPath = e2eConfig .GetVariable (capi_e2e .CNIPath )
82
+
83
+ // When e2e falvour is powervs-md-remediation, check if virtual server instances are cleaned up
84
+ // before proceeding with cluster creation.
85
+ if flavor == powervsRemediationFlavor {
86
+ Expect (e2eConfig .Variables ).To (HaveKey (serviceInstanceID ))
87
+ err := helpers .VerifyServerInstancesDeletion (e2eConfig .GetVariable (serviceInstanceID ))
88
+ Expect (err ).To (BeNil ())
89
+ }
73
90
})
74
91
75
92
AfterEach (func () {
@@ -100,7 +117,7 @@ var _ = Describe("Workload cluster creation", func() {
100
117
Flavor : flavor ,
101
118
Namespace : namespace .Name ,
102
119
ClusterName : clusterName ,
103
- KubernetesVersion : e2eConfig .GetVariable (KubernetesVersion ),
120
+ KubernetesVersion : e2eConfig .GetVariable (kubernetesVersion ),
104
121
ControlPlaneMachineCount : ptr .To (int64 (1 )),
105
122
WorkerMachineCount : ptr .To (int64 (1 )),
106
123
},
@@ -121,7 +138,7 @@ var _ = Describe("Workload cluster creation", func() {
121
138
Flavor : flavor ,
122
139
Namespace : namespace .Name ,
123
140
ClusterName : clusterName ,
124
- KubernetesVersion : e2eConfig .GetVariable (KubernetesVersion ),
141
+ KubernetesVersion : e2eConfig .GetVariable (kubernetesVersion ),
125
142
ControlPlaneMachineCount : ptr .To (int64 (1 )),
126
143
WorkerMachineCount : ptr .To (int64 (3 )),
127
144
},
@@ -146,7 +163,7 @@ var _ = Describe("Workload cluster creation", func() {
146
163
Flavor : flavor ,
147
164
Namespace : namespace .Name ,
148
165
ClusterName : clusterName ,
149
- KubernetesVersion : e2eConfig .GetVariable (KubernetesVersion ),
166
+ KubernetesVersion : e2eConfig .GetVariable (kubernetesVersion ),
150
167
ControlPlaneMachineCount : ptr .To (int64 (3 )),
151
168
WorkerMachineCount : ptr .To (int64 (1 )),
152
169
},
0 commit comments