Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 2fca031

Browse files
committedMay 13, 2025·
PMM. Fix auth tests, remove all PSMDB services before adding PSMDB with new auth method
1 parent baff0f8 commit 2fca031

File tree

1 file changed

+16
-4
lines changed
  • pmm_psmdb_diffauth_setup/test

1 file changed

+16
-4
lines changed
 

‎pmm_psmdb_diffauth_setup/test/test.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,21 @@
1414

1515
def run_test(add_db_command):
1616
try:
17-
docker_pmm_client.check_output('pmm-admin remove mongodb psmdb-server', timeout=30)
18-
except AssertionError:
19-
pass
17+
output = docker_pmm_client.check_output('pmm-admin list --json', timeout=30)
18+
services_info = json.loads(output)
19+
except (AssertionError, json.JSONDecodeError):
20+
pytest.fail("Failed to get or parse service list from pmm-admin")
21+
services_to_remove = []
22+
for service in services_info.get("service", []):
23+
service_type = service.get("service_type")
24+
service_name = service.get("service_name", "")
25+
if service_type == "SERVICE_TYPE_MONGODB_SERVICE" and service_name.startswith("psmdb-server"):
26+
services_to_remove.append(service_name)
27+
for service_name in services_to_remove:
28+
try:
29+
docker_pmm_client.check_output(f'pmm-admin remove mongodb {service_name}', timeout=30)
30+
except AssertionError:
31+
pass
2032
try:
2133
docker_pmm_client.check_output(add_db_command, timeout=30)
2234
except AssertionError:
@@ -26,7 +38,7 @@ def run_test(add_db_command):
2638
pmm_admin_list = json.loads(docker_pmm_client.check_output('pmm-admin list --json', timeout=30))
2739
for agent in pmm_admin_list['agent']:
2840
if agent['agent_type'] == 'AGENT_TYPE_MONGODB_EXPORTER':
29-
agent_id = "mypass"
41+
agent_id = "mypass" if "GSSAPI" not in add_db_command else agent['agent_id']
3042
agent_port = agent['port']
3143
break
3244
try:

0 commit comments

Comments
 (0)
Please sign in to comment.