diff --git a/tests/integration/ha_tests/helpers.py b/tests/integration/ha_tests/helpers.py index 13a6a38d8..bc7b48e1e 100644 --- a/tests/integration/ha_tests/helpers.py +++ b/tests/integration/ha_tests/helpers.py @@ -443,7 +443,7 @@ async def reused_storage(ops_test: OpsTest, unit_name, removal_time) -> bool: If member transitions to STARTUP2 from REMOVED then it is re-using the storage we provided. """ - cat_cmd = f"run --unit {unit_name} -- cat {MONGODB_LOG_PATH}" + cat_cmd = f"exec --unit {unit_name} -- cat {MONGODB_LOG_PATH}" return_code, output, _ = await ops_test.juju(*cat_cmd.split()) if return_code != 0: @@ -521,7 +521,7 @@ async def db_step_down(ops_test: OpsTest, old_primary_unit: str, sigterm_time: i app = await app_name(ops_test) for unit in ops_test.model.applications[app].units: # verify log file exists on this machine - search_file = f"run --unit {unit.name} ls {MONGODB_LOG_PATH}" + search_file = f"exec --unit {unit.name} ls {MONGODB_LOG_PATH}" return_code, _, _ = await ops_test.juju(*search_file.split()) if return_code == 2: continue @@ -559,7 +559,7 @@ async def all_db_processes_down(ops_test: OpsTest) -> bool: for attempt in Retrying(stop=stop_after_attempt(60), wait=wait_fixed(3)): with attempt: for unit in ops_test.model.applications[app].units: - search_db_process = f"run --unit {unit.name} pgrep -x mongod" + search_db_process = f"exec --unit {unit.name} pgrep -x mongod" _, processes, _ = await ops_test.juju(*search_db_process.split()) # splitting processes by "\n" results in one or more empty lines, hence we # need to process these lines accordingly. @@ -593,7 +593,7 @@ async def update_restart_delay(ops_test: OpsTest, unit, delay: int): # MONGOD_SERVICE_DEFAULT_PATH since this directory has strict permissions, instead we scp it # elsewhere and then move it to MONGOD_SERVICE_DEFAULT_PATH. await unit.scp_to(source=TMP_SERVICE_PATH, destination="mongod.service") - mv_cmd = f"run --unit {unit.name} mv /home/ubuntu/mongod.service {MONGOD_SERVICE_DEFAULT_PATH}" + mv_cmd = f"exec --unit {unit.name} mv /home/ubuntu/mongod.service {MONGOD_SERVICE_DEFAULT_PATH}" return_code, _, _ = await ops_test.juju(*mv_cmd.split()) if return_code != 0: raise ProcessError(f"Command: {mv_cmd} failed on unit: {unit.name}.") @@ -602,7 +602,7 @@ async def update_restart_delay(ops_test: OpsTest, unit, delay: int): subprocess.call(["rm", TMP_SERVICE_PATH]) # reload the daemon for systemd otherwise changes are not saved - reload_cmd = f"run --unit {unit.name} systemctl daemon-reload" + reload_cmd = f"exec --unit {unit.name} systemctl daemon-reload" return_code, _, _ = await ops_test.juju(*reload_cmd.split()) if return_code != 0: raise ProcessError(f"Command: {reload_cmd} failed on unit: {unit.name}.") @@ -634,7 +634,7 @@ async def update_service_logging(ops_test: OpsTest, unit, logging: bool): # MONGOD_SERVICE_DEFAULT_PATH since this directory has strict permissions, instead we scp it # elsewhere and then move it to MONGOD_SERVICE_DEFAULT_PATH. await unit.scp_to(source=TMP_SERVICE_PATH, destination="mongod.service") - mv_cmd = f"run --unit {unit.name} mv /home/ubuntu/mongod.service {MONGOD_SERVICE_DEFAULT_PATH}" + mv_cmd = f"exec --unit {unit.name} mv /home/ubuntu/mongod.service {MONGOD_SERVICE_DEFAULT_PATH}" return_code, _, _ = await ops_test.juju(*mv_cmd.split()) if return_code != 0: raise ProcessError(f"Command: {mv_cmd} failed on unit: {unit.name}.") @@ -643,7 +643,7 @@ async def update_service_logging(ops_test: OpsTest, unit, logging: bool): subprocess.call(["rm", TMP_SERVICE_PATH]) # reload the daemon for systemd otherwise changes are not saved - reload_cmd = f"run --unit {unit.name} systemctl daemon-reload" + reload_cmd = f"exec --unit {unit.name} systemctl daemon-reload" return_code, _, _ = await ops_test.juju(*reload_cmd.split()) if return_code != 0: raise ProcessError(f"Command: {reload_cmd} failed on unit: {unit.name}.") @@ -651,13 +651,13 @@ async def update_service_logging(ops_test: OpsTest, unit, logging: bool): async def stop_mongod(ops_test: OpsTest, unit) -> None: """Safely stops the mongod process.""" - stop_db_process = f"run --unit {unit.name} snap stop charmed-mongodb.mongod" + stop_db_process = f"exec --unit {unit.name} snap stop charmed-mongodb.mongod" await ops_test.juju(*stop_db_process.split()) async def start_mongod(ops_test: OpsTest, unit) -> None: """Safely starts the mongod process.""" - start_db_process = f"run --unit {unit.name} snap start charmed-mongodb.mongod" + start_db_process = f"exec --unit {unit.name} snap start charmed-mongodb.mongod" await ops_test.juju(*start_db_process.split()) diff --git a/tests/integration/ha_tests/test_ha.py b/tests/integration/ha_tests/test_ha.py index fd976d8df..9edd2b812 100644 --- a/tests/integration/ha_tests/test_ha.py +++ b/tests/integration/ha_tests/test_ha.py @@ -69,7 +69,7 @@ async def change_logging(ops_test: OpsTest): time.sleep(15) # remove the log file as to not clog up space on the replicas. - rm_cmd = f"run --unit {unit.name} rm {helpers.MONGODB_LOG_PATH}" + rm_cmd = f"exec --unit {unit.name} rm {helpers.MONGODB_LOG_PATH}" await ops_test.juju(*rm_cmd.split()) diff --git a/tests/integration/relation_tests/legacy_relations/helpers.py b/tests/integration/relation_tests/legacy_relations/helpers.py index f56866962..9bb27b3fe 100644 --- a/tests/integration/relation_tests/legacy_relations/helpers.py +++ b/tests/integration/relation_tests/legacy_relations/helpers.py @@ -159,7 +159,7 @@ async def check_tls(ops_test: OpsTest, unit: ops.model.Unit, enabled: bool) -> b ): with attempt: mongod_tls_check = await mongo_tls_command(ops_test) - check_tls_cmd = f"run --unit {unit.name} -- {mongod_tls_check}" + check_tls_cmd = f"exec --unit {unit.name} -- {mongod_tls_check}" return_code, _, _ = await ops_test.juju(*check_tls_cmd.split()) tls_enabled = return_code == 0 if enabled != tls_enabled: diff --git a/tests/integration/relation_tests/legacy_relations/test_charm_legacy_relations.py b/tests/integration/relation_tests/legacy_relations/test_charm_legacy_relations.py index cd0857f46..11e358c40 100644 --- a/tests/integration/relation_tests/legacy_relations/test_charm_legacy_relations.py +++ b/tests/integration/relation_tests/legacy_relations/test_charm_legacy_relations.py @@ -133,7 +133,7 @@ async def test_add_unit_joins_without_auth(ops_test: OpsTest): """Verify scaling mongodb with legacy relations supports no auth.""" await ops_test.model.applications[DATABASE_APP_NAME].add_unit(count=1) await ops_test.model.wait_for_idle( - apps=[DATABASE_APP_NAME], status="active", timeout=1000, wait_for_units=3 + apps=[DATABASE_APP_NAME], status="active", timeout=1000, wait_for_exact_units=3 ) # verify auth is still disabled diff --git a/tests/integration/relation_tests/new_relations/test_charm_relations.py b/tests/integration/relation_tests/new_relations/test_charm_relations.py index 532cd5a96..e3d7920bd 100644 --- a/tests/integration/relation_tests/new_relations/test_charm_relations.py +++ b/tests/integration/relation_tests/new_relations/test_charm_relations.py @@ -49,7 +49,7 @@ async def test_deploy_charms(ops_test: OpsTest, application_charm, database_char application_name=ANOTHER_DATABASE_APP_NAME, ), ) - await ops_test.model.wait_for_idle(apps=APP_NAMES, status="active", wait_for_units=1) + await ops_test.model.wait_for_idle(apps=APP_NAMES, status="active", wait_for_at_least_units=1) @pytest.mark.abort_on_fail