From 27075ff6d9e23a6c4b1ac78ebfbd4265e01b7dba Mon Sep 17 00:00:00 2001 From: Mia Altieri Date: Tue, 5 Sep 2023 07:55:25 +0000 Subject: [PATCH] fix removal of cluster in tests --- lib/charms/mongodb/v0/mongodb_backups.py | 2 +- tests/integration/backup_tests/helpers.py | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/charms/mongodb/v0/mongodb_backups.py b/lib/charms/mongodb/v0/mongodb_backups.py index 6f705c4ba..c65c86f1d 100644 --- a/lib/charms/mongodb/v0/mongodb_backups.py +++ b/lib/charms/mongodb/v0/mongodb_backups.py @@ -42,7 +42,7 @@ # Increment this PATCH version before using `charmcraft publish-lib` or reset # to 0 if you are raising the major API version -LIBPATCH = 2 +LIBPATCH = 6 logger = logging.getLogger(__name__) diff --git a/tests/integration/backup_tests/helpers.py b/tests/integration/backup_tests/helpers.py index b4cb47682..f3f4b9eb8 100644 --- a/tests/integration/backup_tests/helpers.py +++ b/tests/integration/backup_tests/helpers.py @@ -19,15 +19,17 @@ async def destroy_cluster(ops_test: OpsTest, cluster_name: str) -> None: # best practice to scale down before removing the entire cluster. Wait for cluster to settle # removing the next for i in range(0, len(units[:-1])): - await units[i].remove() + unit_name = units[i].name + await ops_test.model.applications[cluster_name].destroy_unit(unit_name) await ops_test.model.block_until( lambda: len(ops_test.model.applications[cluster_name].units) == len(units) - i - 1, timeout=TIMEOUT, ) - ops_test.model.wait_for_idle(apps=[cluster_name], status="active") + await ops_test.model.wait_for_idle(apps=[cluster_name], status="active") - # now that the cluster only has one unit left we can remove the application from Juju - await ops_test.model.applications[cluster_name].destroy() + # now that the cluster only has one unit left we can remove the application from Juju, send + # force for a quicker removal of the cluster. + await ops_test.model.applications[cluster_name].destroy(force=True) # verify there are no more units. await ops_test.model.block_until(