Skip to content

Commit 2918860

Browse files
committed
handle error: storage belongs to different cluster
1 parent 164256c commit 2918860

File tree

2 files changed

+26
-29
lines changed

2 files changed

+26
-29
lines changed

tests/integration/ha_tests/test_restore_cluster.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env python3
22
# Copyright 2023 Canonical Ltd.
33
# See LICENSE file for licensing details.
4+
import asyncio
45
import logging
56

67
import pytest
@@ -37,24 +38,23 @@ async def test_build_and_deploy(ops_test: OpsTest) -> None:
3738
charm = await ops_test.build_charm(".")
3839
async with ops_test.fast_forward():
3940
# Deploy the first cluster with reusable storage
40-
await ops_test.model.deploy(
41-
charm,
42-
application_name=FIRST_APPLICATION,
43-
num_units=3,
44-
series=CHARM_SERIES,
45-
storage={"pgdata": {"pool": "lxd-btrfs", "size": 2048}},
46-
config={"profile": "testing"},
41+
await asyncio.gather(
42+
ops_test.model.deploy(
43+
charm,
44+
application_name=FIRST_APPLICATION,
45+
num_units=3,
46+
series=CHARM_SERIES,
47+
storage={"pgdata": {"pool": "lxd-btrfs", "size": 2048}},
48+
config={"profile": "testing"},
49+
),
50+
ops_test.model.deploy(
51+
charm,
52+
application_name=SECOND_APPLICATION,
53+
num_units=1,
54+
series=CHARM_SERIES,
55+
config={"profile": "testing"},
56+
)
4757
)
48-
49-
# Deploy the second cluster
50-
await ops_test.model.deploy(
51-
charm,
52-
application_name=SECOND_APPLICATION,
53-
num_units=1,
54-
series=CHARM_SERIES,
55-
config={"profile": "testing"},
56-
)
57-
5858
await ops_test.model.wait_for_idle(status="active", timeout=1500)
5959

6060
# TODO have a better way to bootstrap clusters with existing storage

tests/integration/ha_tests/test_self_healing.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,14 @@ async def test_build_and_deploy(ops_test: OpsTest) -> None:
8585
storage={"pgdata": {"pool": "lxd-btrfs", "size": 2048}},
8686
config={"profile": "testing"},
8787
)
88+
await ops_test.model.deploy(
89+
charm,
90+
num_units=1,
91+
application_name=SECOND_APPLICATION,
92+
series=CHARM_SERIES,
93+
storage={"pgdata": {"pool": "lxd-btrfs", "size": 2048}},
94+
config={"profile": "testing"},
95+
)
8896
# Deploy the continuous writes application charm if it wasn't already deployed.
8997
if not await app_name(ops_test, APPLICATION_NAME):
9098
wait_for_apps = True
@@ -553,19 +561,8 @@ async def test_network_cut_without_ip_change(
553561

554562

555563
@pytest.mark.group(1)
556-
async def test_deploy_zero_units(ops_test: OpsTest):
564+
async def test_deploy_zero_units(ops_test: OpsTest, charm):
557565
"""Scale the database to zero units and scale up again."""
558-
async with ops_test.fast_forward():
559-
await ops_test.model.deploy(
560-
APP_NAME,
561-
num_units=1,
562-
application_name=SECOND_APPLICATION,
563-
series=CHARM_SERIES,
564-
storage={"pgdata": {"pool": "lxd-btrfs", "size": 2048}},
565-
config={"profile": "testing"},
566-
)
567-
await ops_test.model.wait_for_idle(status="active", timeout=1500)
568-
569566
app = await app_name(ops_test)
570567
dbname = f"{APPLICATION_NAME.replace('-', '_')}_first_database"
571568
connection_string, _ = await get_db_connection(ops_test, dbname=dbname)

0 commit comments

Comments
 (0)