|
13 | 13 | from pytest_operator.plugin import OpsTest
|
14 | 14 |
|
15 | 15 | 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 | +) |
17 | 26 | from ..juju_ import juju_major_version
|
18 | 27 | from .helpers import (
|
19 | 28 | build_connection_string,
|
@@ -184,6 +193,33 @@ async def test_database_relation_with_charm_libraries(ops_test: OpsTest):
|
184 | 193 | cursor.execute("DROP TABLE test;")
|
185 | 194 |
|
186 | 195 |
|
| 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 | + |
187 | 223 | @pytest.mark.group("new_relations_tests")
|
188 | 224 | async def test_user_with_extra_roles(ops_test: OpsTest):
|
189 | 225 | """Test superuser actions and the request for more permissions."""
|
|
0 commit comments