Skip to content

Commit f69e689

Browse files
authored
wait_for_cluster_deleted when cleaning up test EKS clusters (#72)
`wait_for_cluster_deleted` when cleaning up test EKS clusters. Also, update the SHA for `acktest` upstream in order to bring in a fix from aws-controllers-k8s/test-infra#361 Issue #, if available: aws-controllers-k8s/community#1509 Description of changes: Add the use of a boto3 `Waiter` to poll for cluster deletion before considering a test EKS cluster to be cleaned up. By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent e6ca56b commit f69e689

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

test/e2e/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
acktest @ git+https://github.com/aws-controllers-k8s/test-infra.git@589f8349bf75a27b0f53602bda73f76f80a967c5
1+
acktest @ git+https://github.com/aws-controllers-k8s/test-infra.git@abc558ed87fb22dcf1e8d30d91317d9e2f4d091c

test/e2e/tests/test_cluster.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,16 @@ def wait_for_cluster_active(eks_client, cluster_name):
3838
waiter = eks_client.get_waiter('cluster_active')
3939
waiter.wait(name=cluster_name)
4040

41+
def wait_for_cluster_deleted(eks_client, cluster_name):
42+
waiter = eks_client.get_waiter('cluster_deleted')
43+
waiter.wait(
44+
name=cluster_name,
45+
WaiterConfig={
46+
'Delay': 30,
47+
'MaxAttempts': 40, # 20 minutes
48+
},
49+
)
50+
4151
def get_and_assert_status(ref: k8s.CustomResourceReference, expected_status: str, expected_synced: bool):
4252
cr = k8s.get_resource(ref)
4353
assert cr is not None
@@ -55,7 +65,7 @@ def eks_client():
5565
return boto3.client('eks')
5666

5767
@pytest.fixture
58-
def simple_cluster():
68+
def simple_cluster(eks_client):
5969
cluster_name = random_suffix_name("simple-cluster", 32)
6070

6171
replacements = REPLACEMENT_VALUES.copy()
@@ -84,6 +94,7 @@ def simple_cluster():
8494
try:
8595
_, deleted = k8s.delete_custom_resource(ref, 3, 10)
8696
assert deleted
97+
wait_for_cluster_deleted(eks_client, cluster_name)
8798
except:
8899
pass
89100

@@ -152,3 +163,4 @@ def test_create_update_delete_cluster(self, eks_client, simple_cluster):
152163

153164
# Delete the k8s resource on teardown of the module
154165
k8s.delete_custom_resource(ref)
166+
wait_for_cluster_deleted(eks_client, cluster_name)

0 commit comments

Comments
 (0)