Skip to content

Commit 2d790b6

Browse files
[DPE-4809] Enforce Juju versions (#518)
* Enforce Juju versions Signed-off-by: Marcelo Henrique Neppel <[email protected]> * Upgrade to Juju 3.4.3 Signed-off-by: Marcelo Henrique Neppel <[email protected]> * Fix test_mailman3_core_db Signed-off-by: Marcelo Henrique Neppel <[email protected]> * Run sentry test only on Juju 2 Signed-off-by: Marcelo Henrique Neppel <[email protected]> * Change mailman3-core series to focal Signed-off-by: Marcelo Henrique Neppel <[email protected]> * Change constraint to Juju 3.5.1 Signed-off-by: Marcelo Henrique Neppel <[email protected]> * Add test to replace Sentry extensions block test on Juju 3 Signed-off-by: Marcelo Henrique Neppel <[email protected]> * Upgrade CI to use Juju 3.4.4 Signed-off-by: Marcelo Henrique Neppel <[email protected]> * Pin LXD channel Signed-off-by: Marcelo Henrique Neppel <[email protected]> --------- Signed-off-by: Marcelo Henrique Neppel <[email protected]>
1 parent dd72f65 commit 2d790b6

File tree

4 files changed

+64
-6
lines changed

4 files changed

+64
-6
lines changed

.github/workflows/ci.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,13 @@ jobs:
5656
- agent: 2.9.49 # renovate: juju-agent-pin-minor
5757
libjuju: ==2.9.49.0 # renovate: latest libjuju 2
5858
allure_on_amd64: false
59-
- agent: 3.1.8 # renovate: juju-agent-pin-minor
59+
- agent: 3.4.4 # renovate: juju-agent-pin-minor
6060
allure_on_amd64: true
6161
architecture:
6262
- amd64
6363
include:
6464
- juju:
65-
agent: 3.1.8 # renovate: juju-agent-pin-minor
65+
agent: 3.4.4 # renovate: juju-agent-pin-minor
6666
allure_on_amd64: true
6767
architecture: arm64
6868
name: Integration test charm | ${{ matrix.juju.agent }} | ${{ matrix.architecture }}
@@ -75,6 +75,7 @@ jobs:
7575
artifact-prefix: ${{ needs.build.outputs.artifact-prefix }}
7676
architecture: ${{ matrix.architecture }}
7777
cloud: lxd
78+
lxd-snap-channel: 5.21/stable
7879
juju-agent-version: ${{ matrix.juju.agent }}
7980
libjuju-version-constraint: ${{ matrix.juju.libjuju }}
8081
_beta_allure_report: ${{ matrix.juju.allure_on_amd64 && matrix.architecture == 'amd64' }}

metadata.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,13 @@ storage:
6565

6666
assumes:
6767
- juju
68+
- any-of:
69+
- all-of:
70+
- juju >= 2.9.49
71+
- juju < 3
72+
- all-of:
73+
- juju >= 3.4.3
74+
- juju < 3.5
75+
- all-of:
76+
- juju >= 3.5.1
77+
- juju < 4

tests/integration/helpers.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,7 @@ async def deploy_and_relate_application_with_postgresql(
294294
config: dict = None,
295295
channel: str = "stable",
296296
relation: str = "db",
297+
series: str = None,
297298
) -> int:
298299
"""Helper function to deploy and relate application with PostgreSQL.
299300
@@ -306,6 +307,7 @@ async def deploy_and_relate_application_with_postgresql(
306307
channel: The channel to use for the charm.
307308
relation: Name of the PostgreSQL relation to relate
308309
the application to.
310+
series: Series of the charm to deploy.
309311
310312
Returns:
311313
the id of the created relation.
@@ -317,6 +319,7 @@ async def deploy_and_relate_application_with_postgresql(
317319
application_name=application_name,
318320
num_units=number_of_units,
319321
config=config,
322+
series=series,
320323
)
321324
await ops_test.model.wait_for_idle(
322325
apps=[application_name],

tests/integration/test_db.py

Lines changed: 48 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@
3535
DATABASE_UNITS = 2
3636
RELATION_NAME = "db"
3737

38+
EXTENSIONS_BLOCKING_MESSAGE = (
39+
"extensions requested through relation, enable them through config options"
40+
)
3841
ROLES_BLOCKING_MESSAGE = (
3942
"roles requested through relation, use postgresql_client interface instead"
4043
)
@@ -70,6 +73,7 @@ async def test_mailman3_core_db(ops_test: OpsTest, charm: str) -> None:
7073
MAILMAN3_CORE_APP_NAME,
7174
APPLICATION_UNITS,
7275
config,
76+
series="focal",
7377
)
7478
await check_databases_creation(ops_test, ["mailman3"])
7579

@@ -192,6 +196,7 @@ async def test_relation_data_is_updated_correctly_when_scaling(ops_test: OpsTest
192196
psycopg2.connect(primary_connection_string)
193197

194198

199+
@markers.juju2
195200
@pytest.mark.group(1)
196201
@markers.amd64_only # sentry snap not available for arm64
197202
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:
230235
except JujuUnitError:
231236
pass
232237

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
237239

238240
# Verify that the charm unblocks when the extensions are enabled after being blocked
239241
# due to disabled extensions.
@@ -331,6 +333,48 @@ async def test_roles_blocking(ops_test: OpsTest, charm: str) -> None:
331333
)
332334

333335

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+
334378
@markers.juju2
335379
@pytest.mark.group(1)
336380
@markers.amd64_only # canonical-livepatch-server charm (in bundle) not available for arm64

0 commit comments

Comments
 (0)