Skip to content

Commit

Permalink
fix removal of cluster in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MiaAltieri committed Sep 5, 2023
1 parent 64133ff commit 27075ff
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/charms/mongodb/v0/mongodb_backups.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)

Expand Down
10 changes: 6 additions & 4 deletions tests/integration/backup_tests/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 27075ff

Please sign in to comment.