14
14
15
15
def run_test (add_db_command ):
16
16
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
20
32
try :
21
33
docker_pmm_client .check_output (add_db_command , timeout = 30 )
22
34
except AssertionError :
@@ -26,7 +38,7 @@ def run_test(add_db_command):
26
38
pmm_admin_list = json .loads (docker_pmm_client .check_output ('pmm-admin list --json' , timeout = 30 ))
27
39
for agent in pmm_admin_list ['agent' ]:
28
40
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' ]
30
42
agent_port = agent ['port' ]
31
43
break
32
44
try :
0 commit comments