Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DPE-4809] Enforce Juju versions #518

Merged
merged 15 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ jobs:
- agent: 2.9.49 # renovate: juju-agent-pin-minor
libjuju: ==2.9.49.0 # renovate: latest libjuju 2
allure_on_amd64: false
- agent: 3.1.8 # renovate: juju-agent-pin-minor
- agent: 3.4.4 # renovate: juju-agent-pin-minor
allure_on_amd64: true
architecture:
- amd64
include:
- juju:
agent: 3.1.8 # renovate: juju-agent-pin-minor
agent: 3.4.4 # renovate: juju-agent-pin-minor
allure_on_amd64: true
architecture: arm64
name: Integration test charm | ${{ matrix.juju.agent }} | ${{ matrix.architecture }}
Expand All @@ -75,6 +75,7 @@ jobs:
artifact-prefix: ${{ needs.build.outputs.artifact-prefix }}
architecture: ${{ matrix.architecture }}
cloud: lxd
lxd-snap-channel: 5.21/stable
juju-agent-version: ${{ matrix.juju.agent }}
libjuju-version-constraint: ${{ matrix.juju.libjuju }}
_beta_allure_report: ${{ matrix.juju.allure_on_amd64 && matrix.architecture == 'amd64' }}
Expand Down
10 changes: 10 additions & 0 deletions metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,13 @@ storage:

assumes:
- juju
- any-of:
- all-of:
- juju >= 2.9.49
- juju < 3
- all-of:
- juju >= 3.4.3
- juju < 3.5
- all-of:
- juju >= 3.5.1
- juju < 4
3 changes: 3 additions & 0 deletions tests/integration/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ async def deploy_and_relate_application_with_postgresql(
config: dict = None,
channel: str = "stable",
relation: str = "db",
series: str = None,
) -> int:
"""Helper function to deploy and relate application with PostgreSQL.

Expand All @@ -306,6 +307,7 @@ async def deploy_and_relate_application_with_postgresql(
channel: The channel to use for the charm.
relation: Name of the PostgreSQL relation to relate
the application to.
series: Series of the charm to deploy.

Returns:
the id of the created relation.
Expand All @@ -317,6 +319,7 @@ async def deploy_and_relate_application_with_postgresql(
application_name=application_name,
num_units=number_of_units,
config=config,
series=series,
)
await ops_test.model.wait_for_idle(
apps=[application_name],
Expand Down
52 changes: 48 additions & 4 deletions tests/integration/test_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
DATABASE_UNITS = 2
RELATION_NAME = "db"

EXTENSIONS_BLOCKING_MESSAGE = (
"extensions requested through relation, enable them through config options"
)
ROLES_BLOCKING_MESSAGE = (
"roles requested through relation, use postgresql_client interface instead"
)
Expand Down Expand Up @@ -70,6 +73,7 @@ async def test_mailman3_core_db(ops_test: OpsTest, charm: str) -> None:
MAILMAN3_CORE_APP_NAME,
APPLICATION_UNITS,
config,
series="focal",
)
await check_databases_creation(ops_test, ["mailman3"])

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


@markers.juju2
@pytest.mark.group(1)
@markers.amd64_only # sentry snap not available for arm64
async def test_sentry_db_blocked(ops_test: OpsTest, charm: str) -> None:
Expand Down Expand Up @@ -230,10 +235,7 @@ async def test_sentry_db_blocked(ops_test: OpsTest, charm: str) -> None:
except JujuUnitError:
pass

assert (
leader_unit.workload_status_message
== "extensions requested through relation, enable them through config options"
)
assert leader_unit.workload_status_message == EXTENSIONS_BLOCKING_MESSAGE

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


@markers.juju3 # As the Sentry test already checks Juju 2.
@pytest.mark.group(1)
async def test_extensions_blocking(ops_test: OpsTest, charm: str) -> None:
await asyncio.gather(
ops_test.model.applications[APPLICATION_NAME].set_config({"legacy_roles": "False"}),
ops_test.model.applications[f"{APPLICATION_NAME}2"].set_config({"legacy_roles": "False"}),
)
await ops_test.model.wait_for_idle(
apps=[APPLICATION_NAME, f"{APPLICATION_NAME}2"],
status="active",
timeout=1000,
)

await asyncio.gather(
ops_test.model.relate(f"{DATABASE_APP_NAME}:db", f"{APPLICATION_NAME}:db"),
ops_test.model.relate(f"{DATABASE_APP_NAME}:db", f"{APPLICATION_NAME}2:db"),
)

leader_unit = await get_leader_unit(ops_test, DATABASE_APP_NAME)
await ops_test.model.block_until(
lambda: leader_unit.workload_status_message == EXTENSIONS_BLOCKING_MESSAGE, timeout=1000
)

assert leader_unit.workload_status_message == EXTENSIONS_BLOCKING_MESSAGE

logger.info("Verify that the charm remains blocked if there are other blocking relations")
await ops_test.model.applications[DATABASE_APP_NAME].destroy_relation(
f"{DATABASE_APP_NAME}:db", f"{APPLICATION_NAME}:db"
)

await ops_test.model.block_until(
lambda: leader_unit.workload_status_message == EXTENSIONS_BLOCKING_MESSAGE, timeout=1000
)

assert leader_unit.workload_status_message == EXTENSIONS_BLOCKING_MESSAGE

logger.info("Verify that active status is restored when all blocking relations are gone")
await ops_test.model.applications[DATABASE_APP_NAME].destroy_relation(
f"{DATABASE_APP_NAME}:db", f"{APPLICATION_NAME}2:db"
)


@markers.juju2
@pytest.mark.group(1)
@markers.amd64_only # canonical-livepatch-server charm (in bundle) not available for arm64
Expand Down
Loading