Skip to content

Commit 19c227a

Browse files
Merge pull request #41 from echen-98/spec-fields
fix deletion assertions in user e2e tests
2 parents 4b2fcc4 + 823ef7e commit 19c227a

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

test/e2e/tests/test_user.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@
2323

2424
from time import sleep
2525
from e2e import service_marker, CRD_GROUP, CRD_VERSION, load_elasticache_resource
26+
from e2e.util import assert_user_deletion
2627

2728
RESOURCE_PLURAL = "users"
28-
DEFAULT_WAIT_SECS = 90
29+
DEFAULT_WAIT_SECS = 30
2930

3031

3132
@pytest.fixture(scope="module")
@@ -57,8 +58,7 @@ def user_nopass(user_nopass_input, elasticache_client):
5758
# teardown: delete in k8s, assert user does not exist in AWS
5859
k8s.delete_custom_resource(reference)
5960
sleep(DEFAULT_WAIT_SECS)
60-
with pytest.raises(botocore.exceptions.ClientError, match="UserNotFound"):
61-
_ = elasticache_client.describe_users(UserId=user_nopass_input["USER_ID"])
61+
assert_user_deletion(user_nopass_input['USER_ID'])
6262

6363

6464
# create secrets for below user password test
@@ -104,8 +104,7 @@ def user_password(user_password_input, elasticache_client):
104104
# teardown: delete in k8s, assert user does not exist in AWS
105105
k8s.delete_custom_resource(reference)
106106
sleep(DEFAULT_WAIT_SECS)
107-
with pytest.raises(botocore.exceptions.ClientError, match="UserNotFound"):
108-
_ = elasticache_client.describe_users(UserId=user_password_input["USER_ID"])
107+
assert_user_deletion(user_password_input['USER_ID'])
109108

110109

111110
@service_marker

test/e2e/util.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,17 @@ def wait_snapshot_deleted(snapshot_name: str,
8181
return False
8282

8383

84+
# assert that either: 1) deletion has been initiated, or 2) deletion has been completed
85+
# on the service-side
86+
def assert_user_deletion(user_id: str):
87+
try:
88+
resp = ec.describe_users(UserId=user_id)
89+
assert len(resp['Users']) == 1
90+
assert resp['Users'][0]['Status'] == 'deleting' # at this point, deletion is a server-side responsibility
91+
except ec.exceptions.UserNotFoundFault:
92+
pass # we only expect this particular exception (if deletion has already completed)
93+
94+
8495
# provide a basic nodeGroupConfiguration object of desired size
8596
def provide_node_group_configuration(size: int):
8697
ngc = []

0 commit comments

Comments
 (0)