@@ -67,7 +67,6 @@ var _ = ginkgo.Context("[unmanaged] [gc]", func() {
67
67
clusterName := fmt .Sprintf ("%s-%s" , specName , util .RandomString (6 ))
68
68
69
69
configCluster := defaultConfigCluster (clusterName , namespace .Name )
70
- configCluster .KubernetesVersion = e2eCtx .E2EConfig .GetVariable (shared .PreCSIKubernetesVer )
71
70
configCluster .WorkerMachineCount = pointer .Int64 (1 )
72
71
createCluster (ctx , configCluster , result )
73
72
@@ -139,6 +138,118 @@ var _ = ginkgo.Context("[unmanaged] [gc]", func() {
139
138
Expect (err ).NotTo (HaveOccurred ())
140
139
Expect (arns ).To (BeEmpty (), "there are %d service load balancers (elb) still" , len (arns ))
141
140
})
141
+
142
+ ginkgo .It ("[unmanaged] [gc] should cleanup a cluster that has ELB/NLB load balancers using AlternativeGCStrategy" , func () {
143
+ ginkgo .By ("should have a valid test configuration" )
144
+ specName := "unmanaged-gc-alterstrategy-cluster"
145
+
146
+ ctx = context .TODO ()
147
+ result = & clusterctl.ApplyClusterTemplateAndWaitResult {}
148
+
149
+ Expect (e2eCtx .Environment .BootstrapClusterProxy ).ToNot (BeNil (), "Invalid argument. BootstrapClusterProxy can't be nil" )
150
+ Expect (e2eCtx .E2EConfig ).ToNot (BeNil (), "Invalid argument. e2eConfig can't be nil when calling %s spec" , specName )
151
+ Expect (e2eCtx .E2EConfig .Variables ).To (HaveKey (shared .KubernetesVersion ))
152
+
153
+ shared .ReconfigureDeployment (ctx , shared.ReconfigureDeploymentInput {
154
+ Getter : e2eCtx .Environment .BootstrapClusterProxy .GetClient (),
155
+ ClientSet : e2eCtx .Environment .BootstrapClusterProxy .GetClientSet (),
156
+ Name : "capa-controller-manager" ,
157
+ Namespace : "capa-system" ,
158
+ WaitInterval : e2eCtx .E2EConfig .GetIntervals ("" , "wait-deployment-ready" ),
159
+ }, shared .EnableAlternativeGCStrategy , shared .ValidateAlternativeGCStrategyEnabled )
160
+
161
+ requiredResources = & shared.TestResource {EC2Normal : 2 * e2eCtx .Settings .InstanceVCPU , IGW : 1 , NGW : 1 , VPC : 1 , ClassicLB : 1 , EIP : 1 , EventBridgeRules : 50 }
162
+ requiredResources .WriteRequestedResources (e2eCtx , specName )
163
+ Expect (shared .AcquireResources (requiredResources , ginkgo .GinkgoParallelProcess (), flock .New (shared .ResourceQuotaFilePath ))).To (Succeed ())
164
+ defer shared .ReleaseResources (requiredResources , ginkgo .GinkgoParallelProcess (), flock .New (shared .ResourceQuotaFilePath ))
165
+ namespace := shared .SetupNamespace (ctx , specName , e2eCtx )
166
+ defer shared .DumpSpecResourcesAndCleanup (ctx , "" , namespace , e2eCtx )
167
+ ginkgo .By ("Creating cluster with single control plane" )
168
+ clusterName := fmt .Sprintf ("%s-%s" , specName , util .RandomString (6 ))
169
+
170
+ configCluster := defaultConfigCluster (clusterName , namespace .Name )
171
+ configCluster .WorkerMachineCount = pointer .Int64 (1 )
172
+ c , md , cp := createCluster (ctx , configCluster , result )
173
+ Expect (c ).NotTo (BeNil (), "Expecting cluster created" )
174
+ Expect (len (md )).To (Equal (1 ), "Expecting one MachineDeployment" )
175
+ Expect (cp ).NotTo (BeNil (), "Expecting control plane created" )
176
+
177
+ ginkgo .By (fmt .Sprintf ("getting cluster with name %s" , clusterName ))
178
+ cluster := framework .GetClusterByName (ctx , framework.GetClusterByNameInput {
179
+ Getter : e2eCtx .Environment .BootstrapClusterProxy .GetClient (),
180
+ Namespace : namespace .Name ,
181
+ Name : clusterName ,
182
+ })
183
+ Expect (cluster ).NotTo (BeNil (), "couldn't find cluster" )
184
+
185
+ workloadClusterProxy := e2eCtx .Environment .BootstrapClusterProxy .GetWorkloadCluster (ctx , cluster .Namespace , cluster .Name )
186
+ workloadYamlPath := e2eCtx .E2EConfig .GetVariable (shared .GcWorkloadPath )
187
+ ginkgo .By (fmt .Sprintf ("Installing sample workload with load balancer services: %s" , workloadYamlPath ))
188
+ workloadYaml , err := os .ReadFile (workloadYamlPath ) //nolint:gosec
189
+ Expect (err ).ShouldNot (HaveOccurred ())
190
+ Expect (workloadClusterProxy .Apply (ctx , workloadYaml )).ShouldNot (HaveOccurred ())
191
+
192
+ ginkgo .By ("Waiting for the Deployment to be available" )
193
+ shared .WaitForDeploymentsAvailable (ctx , shared.WaitForDeploymentsAvailableInput {
194
+ Getter : workloadClusterProxy .GetClient (),
195
+ Name : "podinfo" ,
196
+ Namespace : "default" ,
197
+ }, e2eCtx .E2EConfig .GetIntervals ("" , "wait-deployment-ready" )... )
198
+
199
+ ginkgo .By ("Checking we have the load balancers in AWS" )
200
+ shared .WaitForLoadBalancerToExistForService (shared.WaitForLoadBalancerToExistForServiceInput {
201
+ AWSSession : e2eCtx .BootstrapUserAWSSession ,
202
+ ServiceName : "podinfo-nlb" ,
203
+ ServiceNamespace : "default" ,
204
+ ClusterName : clusterName ,
205
+ Type : infrav1 .LoadBalancerTypeNLB ,
206
+ }, e2eCtx .E2EConfig .GetIntervals ("" , "wait-loadbalancer-ready" )... )
207
+ shared .WaitForLoadBalancerToExistForService (shared.WaitForLoadBalancerToExistForServiceInput {
208
+ AWSSession : e2eCtx .BootstrapUserAWSSession ,
209
+ ServiceName : "podinfo-elb" ,
210
+ ServiceNamespace : "default" ,
211
+ ClusterName : clusterName ,
212
+ Type : infrav1 .LoadBalancerTypeELB ,
213
+ }, e2eCtx .E2EConfig .GetIntervals ("" , "wait-loadbalancer-ready" )... )
214
+
215
+ ginkgo .By (fmt .Sprintf ("Deleting workload/tenant cluster %s" , clusterName ))
216
+ framework .DeleteCluster (ctx , framework.DeleteClusterInput {
217
+ Deleter : e2eCtx .Environment .BootstrapClusterProxy .GetClient (),
218
+ Cluster : cluster ,
219
+ })
220
+ framework .WaitForClusterDeleted (ctx , framework.WaitForClusterDeletedInput {
221
+ Getter : e2eCtx .Environment .BootstrapClusterProxy .GetClient (),
222
+ Cluster : cluster ,
223
+ }, e2eCtx .E2EConfig .GetIntervals ("" , "wait-delete-cluster" )... )
224
+
225
+ ginkgo .By ("Getting counts of service load balancers" )
226
+ arns , err := shared .GetLoadBalancerARNs (shared.GetLoadBalancerARNsInput {
227
+ AWSSession : e2eCtx .BootstrapUserAWSSession ,
228
+ ServiceName : "podinfo-nlb" ,
229
+ ServiceNamespace : "default" ,
230
+ ClusterName : clusterName ,
231
+ Type : infrav1 .LoadBalancerTypeNLB ,
232
+ })
233
+ Expect (err ).NotTo (HaveOccurred ())
234
+ Expect (arns ).To (BeEmpty (), "there are %d service load balancers (nlb) still" , len (arns ))
235
+ arns , err = shared .GetLoadBalancerARNs (shared.GetLoadBalancerARNsInput {
236
+ AWSSession : e2eCtx .BootstrapUserAWSSession ,
237
+ ServiceName : "podinfo-elb" ,
238
+ ServiceNamespace : "default" ,
239
+ ClusterName : clusterName ,
240
+ Type : infrav1 .LoadBalancerTypeELB ,
241
+ })
242
+ Expect (err ).NotTo (HaveOccurred ())
243
+ Expect (arns ).To (BeEmpty (), "there are %d service load balancers (elb) still" , len (arns ))
244
+
245
+ shared .ReconfigureDeployment (ctx , shared.ReconfigureDeploymentInput {
246
+ Getter : e2eCtx .Environment .BootstrapClusterProxy .GetClient (),
247
+ ClientSet : e2eCtx .Environment .BootstrapClusterProxy .GetClientSet (),
248
+ Name : "capa-controller-manager" ,
249
+ Namespace : "capa-system" ,
250
+ WaitInterval : e2eCtx .E2EConfig .GetIntervals ("" , "wait-deployment-ready" ),
251
+ }, shared .DisableAlternativeGCStrategy , shared .ValidateAlternativeGCStrategyDisabled )
252
+ })
142
253
})
143
254
144
255
// TODO (richardcase): remove this when we merge these tests with the main eks e2e tests.
0 commit comments