|
35 | 35 | DATABASE_UNITS = 2
|
36 | 36 | RELATION_NAME = "db"
|
37 | 37 |
|
| 38 | +EXTENSIONS_BLOCKING_MESSAGE = ( |
| 39 | + "extensions requested through relation, enable them through config options" |
| 40 | +) |
38 | 41 | ROLES_BLOCKING_MESSAGE = (
|
39 | 42 | "roles requested through relation, use postgresql_client interface instead"
|
40 | 43 | )
|
@@ -70,6 +73,7 @@ async def test_mailman3_core_db(ops_test: OpsTest, charm: str) -> None:
|
70 | 73 | MAILMAN3_CORE_APP_NAME,
|
71 | 74 | APPLICATION_UNITS,
|
72 | 75 | config,
|
| 76 | + series="focal", |
73 | 77 | )
|
74 | 78 | await check_databases_creation(ops_test, ["mailman3"])
|
75 | 79 |
|
@@ -192,6 +196,7 @@ async def test_relation_data_is_updated_correctly_when_scaling(ops_test: OpsTest
|
192 | 196 | psycopg2.connect(primary_connection_string)
|
193 | 197 |
|
194 | 198 |
|
| 199 | +@markers.juju2 |
195 | 200 | @pytest.mark.group(1)
|
196 | 201 | @markers.amd64_only # sentry snap not available for arm64
|
197 | 202 | async def test_sentry_db_blocked(ops_test: OpsTest, charm: str) -> None:
|
@@ -230,10 +235,7 @@ async def test_sentry_db_blocked(ops_test: OpsTest, charm: str) -> None:
|
230 | 235 | except JujuUnitError:
|
231 | 236 | pass
|
232 | 237 |
|
233 |
| - assert ( |
234 |
| - leader_unit.workload_status_message |
235 |
| - == "extensions requested through relation, enable them through config options" |
236 |
| - ) |
| 238 | + assert leader_unit.workload_status_message == EXTENSIONS_BLOCKING_MESSAGE |
237 | 239 |
|
238 | 240 | # Verify that the charm unblocks when the extensions are enabled after being blocked
|
239 | 241 | # due to disabled extensions.
|
@@ -331,6 +333,48 @@ async def test_roles_blocking(ops_test: OpsTest, charm: str) -> None:
|
331 | 333 | )
|
332 | 334 |
|
333 | 335 |
|
| 336 | +@markers.juju3 # As the Sentry test already checks Juju 2. |
| 337 | +@pytest.mark.group(1) |
| 338 | +async def test_extensions_blocking(ops_test: OpsTest, charm: str) -> None: |
| 339 | + await asyncio.gather( |
| 340 | + ops_test.model.applications[APPLICATION_NAME].set_config({"legacy_roles": "False"}), |
| 341 | + ops_test.model.applications[f"{APPLICATION_NAME}2"].set_config({"legacy_roles": "False"}), |
| 342 | + ) |
| 343 | + await ops_test.model.wait_for_idle( |
| 344 | + apps=[APPLICATION_NAME, f"{APPLICATION_NAME}2"], |
| 345 | + status="active", |
| 346 | + timeout=1000, |
| 347 | + ) |
| 348 | + |
| 349 | + await asyncio.gather( |
| 350 | + ops_test.model.relate(f"{DATABASE_APP_NAME}:db", f"{APPLICATION_NAME}:db"), |
| 351 | + ops_test.model.relate(f"{DATABASE_APP_NAME}:db", f"{APPLICATION_NAME}2:db"), |
| 352 | + ) |
| 353 | + |
| 354 | + leader_unit = await get_leader_unit(ops_test, DATABASE_APP_NAME) |
| 355 | + await ops_test.model.block_until( |
| 356 | + lambda: leader_unit.workload_status_message == EXTENSIONS_BLOCKING_MESSAGE, timeout=1000 |
| 357 | + ) |
| 358 | + |
| 359 | + assert leader_unit.workload_status_message == EXTENSIONS_BLOCKING_MESSAGE |
| 360 | + |
| 361 | + logger.info("Verify that the charm remains blocked if there are other blocking relations") |
| 362 | + await ops_test.model.applications[DATABASE_APP_NAME].destroy_relation( |
| 363 | + f"{DATABASE_APP_NAME}:db", f"{APPLICATION_NAME}:db" |
| 364 | + ) |
| 365 | + |
| 366 | + await ops_test.model.block_until( |
| 367 | + lambda: leader_unit.workload_status_message == EXTENSIONS_BLOCKING_MESSAGE, timeout=1000 |
| 368 | + ) |
| 369 | + |
| 370 | + assert leader_unit.workload_status_message == EXTENSIONS_BLOCKING_MESSAGE |
| 371 | + |
| 372 | + logger.info("Verify that active status is restored when all blocking relations are gone") |
| 373 | + await ops_test.model.applications[DATABASE_APP_NAME].destroy_relation( |
| 374 | + f"{DATABASE_APP_NAME}:db", f"{APPLICATION_NAME}2:db" |
| 375 | + ) |
| 376 | + |
| 377 | + |
334 | 378 | @markers.juju2
|
335 | 379 | @pytest.mark.group(1)
|
336 | 380 | @markers.amd64_only # canonical-livepatch-server charm (in bundle) not available for arm64
|
|
0 commit comments