Skip to content

Commit c2188c0

Browse files
committed
Integration test
1 parent a63f183 commit c2188c0

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

tests/integration/new_relations/test_new_relations.py

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,16 @@
1313
from pytest_operator.plugin import OpsTest
1414

1515
from .. import markers
16-
from ..helpers import CHARM_BASE, assert_sync_standbys, get_leader_unit, scale_application
16+
from ..helpers import (
17+
CHARM_BASE,
18+
assert_sync_standbys,
19+
get_leader_unit,
20+
get_machine_from_unit,
21+
get_primary,
22+
scale_application,
23+
start_machine,
24+
stop_machine,
25+
)
1726
from ..juju_ import juju_major_version
1827
from .helpers import (
1928
build_connection_string,
@@ -184,6 +193,33 @@ async def test_database_relation_with_charm_libraries(ops_test: OpsTest):
184193
cursor.execute("DROP TABLE test;")
185194

186195

196+
@pytest.mark.group("new_relations_tests")
197+
@pytest.mark.abort_on_fail
198+
async def test_filter_out_degraded_replicas(ops_test: OpsTest):
199+
primary = await get_primary(ops_test, f"{DATABASE_APP_NAME}/0")
200+
replica = next(
201+
unit.name
202+
for unit in ops_test.model.applications[DATABASE_APP_NAME].units
203+
if unit.name != primary
204+
)
205+
machine = await get_machine_from_unit(ops_test, replica)
206+
await stop_machine(ops_test, machine)
207+
208+
# Topology observer runs every half a minute
209+
await asyncio.sleep(60)
210+
211+
data = await get_application_relation_data(
212+
ops_test,
213+
APPLICATION_APP_NAME,
214+
FIRST_DATABASE_RELATION_NAME,
215+
"read-only-endpoints",
216+
)
217+
assert len(data.split(",")) == 1
218+
219+
await start_machine(ops_test, machine)
220+
await ops_test.model.wait_for_idle(apps=DATABASE_APP_NAME, status="active", timeout=200)
221+
222+
187223
@pytest.mark.group("new_relations_tests")
188224
async def test_user_with_extra_roles(ops_test: OpsTest):
189225
"""Test superuser actions and the request for more permissions."""

0 commit comments

Comments
 (0)