Skip to content

Commit

Permalink
update test_mongos to test the new way of removing users
Browse files Browse the repository at this point in the history
  • Loading branch information
MiaAltieri committed Oct 21, 2024
1 parent 851406c commit 35e5c47
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions tests/integration/sharding_tests/test_mongos.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
SHARD_REL_NAME = "sharding"
CLUSTER_REL_NAME = "cluster"
CONFIG_SERVER_REL_NAME = "config-server"
NUMBER_OF_MONGOS_USERS_WHEN_NO_ROUTERS = 1
TIMEOUT = 10 * 60


Expand Down Expand Up @@ -124,8 +125,12 @@ async def test_connect_to_cluster_creates_user(ops_test: OpsTest) -> None:

@pytest.mark.group(1)
@pytest.mark.abort_on_fail
async def test_disconnect_from_cluster_removes_user(ops_test: OpsTest) -> None:
"""Verifies that when the cluster is formed a the user is removed."""
async def test_disconnect_from_cluster_removes_all_mongos_users(ops_test: OpsTest) -> None:
"""Verifies that when the cluster is formed the client users are removed.
Since mongos-k8s router supports multiple users, we expect that the removal of this
integration will result in the removal of the mongos-k8s admin users and all of its clients.
"""
# generate URI for new mongos user
(username, password) = await get_related_username_password(
ops_test, app_name=MONGOS_APP_NAME, relation_name=CLUSTER_REL_NAME
Expand All @@ -147,9 +152,8 @@ async def test_disconnect_from_cluster_removes_user(ops_test: OpsTest) -> None:
raise_on_error=False,
)
num_users_after_removal = count_users(mongos_client)

assert (
num_users - 1 == num_users_after_removal
NUMBER_OF_MONGOS_USERS_WHEN_NO_ROUTERS == num_users_after_removal
), "Cluster did not remove user after integration removal."

mongos_user_client = await get_direct_mongo_client(
Expand Down

0 comments on commit 35e5c47

Please sign in to comment.