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 c33e369
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 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
5 changes: 3 additions & 2 deletions tests/integration/backup_tests/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ 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()
Expand Down

0 comments on commit c33e369

Please sign in to comment.