Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions test/e2e/tests/test_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@

from time import sleep
from e2e import service_marker, CRD_GROUP, CRD_VERSION, load_elasticache_resource
from e2e.util import assert_user_deletion

RESOURCE_PLURAL = "users"
DEFAULT_WAIT_SECS = 90
DEFAULT_WAIT_SECS = 30


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


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


@service_marker
Expand Down
11 changes: 11 additions & 0 deletions test/e2e/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,17 @@ def wait_snapshot_deleted(snapshot_name: str,
return False


# assert that either: 1) deletion has been initiated, or 2) deletion has been completed
# on the service-side
def assert_user_deletion(user_id: str):
try:
resp = ec.describe_users(UserId=user_id)
assert len(resp['Users']) == 1
assert resp['Users'][0]['Status'] == 'deleting' # at this point, deletion is a server-side responsibility
except ec.exceptions.UserNotFoundFault:
pass # we only expect this particular exception (if deletion has already completed)


# provide a basic nodeGroupConfiguration object of desired size
def provide_node_group_configuration(size: int):
ngc = []
Expand Down