Skip to content

Commit

Permalink
[DPE-4977] Run integration tests against Juju 3.6 (#689)
Browse files Browse the repository at this point in the history
* Attempt to run integration tests on juju 3.6

* Change pgdata permissions to 0o700 + fix charm bases in tests

* Remove import to fix lint warning

* Set pg data permissions to 750 explicitly so it works well with pgbackrest

* Use base [email protected] for finos-waltz-k8s

* Deploy charms without jammy support with base [email protected]

* Test against juju 3.6/edge due to secrets related fixes + deploy mattermost with [email protected]

* Run tests against juju 3.6/stable

* Run tests against 3.6/candidate and not 3.6/stable

* Run juju 3.6 tests only on a nightly schedule

* Address missed case of series->base after merge of main into branch

* Address Dragomir's feedback on test failures due to nuances of python libjuju

* Use series for the indico charm as the usage of bases shows incompatibility with focal
  • Loading branch information
shayancanonical authored Nov 15, 2024
1 parent 44aca9e commit 7bcadff
Show file tree
Hide file tree
Showing 19 changed files with 104 additions and 47 deletions.
9 changes: 8 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,20 @@ jobs:
allure_on_amd64: false
- agent: 3.4.6 # renovate: juju-agent-pin-minor
allure_on_amd64: true
- snap_channel: 3.6/candidate
allure_on_amd64: false
architecture:
- amd64
include:
- juju:
agent: 3.4.6 # renovate: juju-agent-pin-minor
allure_on_amd64: true
architecture: arm64
name: Integration | ${{ matrix.juju.agent }} | ${{ matrix.architecture }}
- juju:
snap_channel: 3.6/candidate
allure_on_amd64: false
architecture: arm64
name: Integration | ${{ matrix.juju.agent || matrix.juju.snap_channel }} | ${{ matrix.architecture }}
needs:
- lint
- unit-test
Expand All @@ -78,6 +84,7 @@ jobs:
cloud: microk8s
microk8s-snap-channel: 1.31-strict/stable # renovate: latest microk8s
juju-agent-version: ${{ matrix.juju.agent }}
juju-snap-channel: ${{ matrix.juju.snap_channel }}
libjuju-version-constraint: ${{ matrix.juju.libjuju }}
_beta_allure_report: ${{ matrix.juju.allure_on_amd64 && matrix.architecture == 'amd64' }}
secrets:
Expand Down
9 changes: 7 additions & 2 deletions tests/integration/ha_tests/test_async_replication.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from .. import architecture, markers
from ..helpers import (
APPLICATION_NAME,
CHARM_BASE,
DATABASE_APP_NAME,
build_and_deploy,
get_leader_unit,
Expand Down Expand Up @@ -112,8 +113,12 @@ async def test_deploy_async_replication_setup(
"""Build and deploy two PostgreSQL cluster in two separate models to test async replication."""
await build_and_deploy(ops_test, CLUSTER_SIZE, wait_for_idle=False)
await build_and_deploy(ops_test, CLUSTER_SIZE, wait_for_idle=False, model=second_model)
await ops_test.model.deploy(APPLICATION_NAME, channel="latest/edge", num_units=1)
await second_model.deploy(APPLICATION_NAME, channel="latest/edge", num_units=1)
await ops_test.model.deploy(
APPLICATION_NAME, channel="latest/edge", num_units=1, base=CHARM_BASE
)
await second_model.deploy(
APPLICATION_NAME, channel="latest/edge", num_units=1, base=CHARM_BASE
)

async with ops_test.fast_forward(), fast_forward(second_model):
await gather(
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/ha_tests/test_replication.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from ..helpers import (
APPLICATION_NAME,
CHARM_SERIES,
CHARM_BASE,
app_name,
build_and_deploy,
db_connect,
Expand Down Expand Up @@ -43,7 +43,7 @@ async def test_build_and_deploy(ops_test: OpsTest) -> None:
await ops_test.model.deploy(
APPLICATION_NAME,
application_name=APPLICATION_NAME,
series=CHARM_SERIES,
base=CHARM_BASE,
channel="edge",
)

Expand Down
5 changes: 3 additions & 2 deletions tests/integration/ha_tests/test_rollback_to_master_label.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from ..architecture import architecture
from ..helpers import (
APPLICATION_NAME,
CHARM_SERIES,
CHARM_BASE,
DATABASE_APP_NAME,
get_leader_unit,
get_primary,
Expand Down Expand Up @@ -47,13 +47,14 @@ async def test_deploy_stable(ops_test: OpsTest) -> None:
num_units=3,
channel="14/stable",
revision=LABEL_REVISION,
series=CHARM_SERIES,
base=CHARM_BASE,
trust=True,
),
ops_test.model.deploy(
APPLICATION_NAME,
num_units=1,
channel="latest/edge",
base=CHARM_BASE,
),
)
logger.info("Wait for applications to become active")
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/ha_tests/test_self_healing.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from .. import markers
from ..helpers import (
APPLICATION_NAME,
CHARM_SERIES,
CHARM_BASE,
METADATA,
app_name,
build_and_deploy,
Expand Down Expand Up @@ -69,7 +69,7 @@ async def test_build_and_deploy(ops_test: OpsTest) -> None:
await ops_test.model.deploy(
APPLICATION_NAME,
application_name=APPLICATION_NAME,
series=CHARM_SERIES,
base=CHARM_BASE,
channel="edge",
)

Expand Down
6 changes: 3 additions & 3 deletions tests/integration/ha_tests/test_smoke.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

from .. import markers
from ..helpers import (
CHARM_SERIES,
CHARM_BASE,
DATABASE_APP_NAME,
scale_application,
)
Expand Down Expand Up @@ -56,7 +56,7 @@ async def test_app_force_removal(ops_test: OpsTest):
application_name=DATABASE_APP_NAME,
num_units=1,
channel="14/stable",
series=CHARM_SERIES,
base=CHARM_BASE,
trust=True,
config={"profile": "testing"},
)
Expand Down Expand Up @@ -169,7 +169,7 @@ async def test_app_resources_conflicts(ops_test: OpsTest):
application_name=DUP_DATABASE_APP_NAME,
num_units=1,
channel="14/stable",
series=CHARM_SERIES,
base=CHARM_BASE,
trust=True,
config={"profile": "testing"},
)
Expand Down
3 changes: 3 additions & 0 deletions tests/integration/ha_tests/test_upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

from ..helpers import (
APPLICATION_NAME,
CHARM_BASE,
DATABASE_APP_NAME,
METADATA,
count_switchovers,
Expand Down Expand Up @@ -44,11 +45,13 @@ async def test_deploy_latest(ops_test: OpsTest) -> None:
channel="14/edge",
trust=True,
config={"profile": "testing"},
base=CHARM_BASE,
),
ops_test.model.deploy(
APPLICATION_NAME,
num_units=1,
channel="latest/edge",
base=CHARM_BASE,
),
)
logger.info("Wait for applications to become active")
Expand Down
3 changes: 3 additions & 0 deletions tests/integration/ha_tests/test_upgrade_from_stable.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from .. import markers
from ..helpers import (
APPLICATION_NAME,
CHARM_BASE,
DATABASE_APP_NAME,
METADATA,
count_switchovers,
Expand Down Expand Up @@ -42,11 +43,13 @@ async def test_deploy_stable(ops_test: OpsTest) -> None:
num_units=3,
channel="14/stable",
trust=True,
base=CHARM_BASE,
),
ops_test.model.deploy(
APPLICATION_NAME,
num_units=1,
channel="latest/edge",
base=CHARM_BASE,
),
)
logger.info("Wait for applications to become active")
Expand Down
11 changes: 10 additions & 1 deletion tests/integration/ha_tests/test_upgrade_to_primary_label.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@
from ..architecture import architecture
from ..helpers import (
APPLICATION_NAME,
CHARM_BASE,
CHARM_SERIES,
DATABASE_APP_NAME,
get_leader_unit,
get_primary,
get_unit_by_index,
)
from ..juju_ import juju_major_version
from .helpers import (
are_writes_increasing,
check_writes,
Expand All @@ -36,19 +38,26 @@
@pytest.mark.abort_on_fail
async def test_deploy_stable(ops_test: OpsTest) -> None:
"""Simple test to ensure that the PostgreSQL and application charms get deployed."""
database_additional_params = {}
if juju_major_version >= 3:
database_additional_params["base"] = CHARM_BASE
else:
database_additional_params["series"] = CHARM_SERIES

await asyncio.gather(
ops_test.model.deploy(
DATABASE_APP_NAME,
num_units=3,
channel="14/stable",
revision=(280 if architecture == "arm64" else 281),
series=CHARM_SERIES,
trust=True,
**database_additional_params,
),
ops_test.model.deploy(
APPLICATION_NAME,
num_units=1,
channel="latest/edge",
base=CHARM_BASE,
),
)
logger.info("Wait for applications to become active")
Expand Down
12 changes: 9 additions & 3 deletions tests/integration/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
wait_fixed,
)

CHARM_BASE = "[email protected]"
CHARM_SERIES = "jammy"
METADATA = yaml.safe_load(Path("./metadata.yaml").read_text())
DATABASE_APP_NAME = METADATA["name"]
Expand Down Expand Up @@ -100,7 +101,7 @@ async def build_and_deploy(
application_name=database_app_name,
trust=True,
num_units=num_units,
series=CHARM_SERIES,
base=CHARM_BASE,
config={"profile": "testing"},
),
)
Expand Down Expand Up @@ -277,6 +278,7 @@ async def deploy_and_relate_application_with_postgresql(
channel: str = "stable",
relation: str = "db",
status: str = "blocked",
base: str = CHARM_BASE,
) -> int:
"""Helper function to deploy and relate application with PostgreSQL.
Expand All @@ -289,6 +291,7 @@ async def deploy_and_relate_application_with_postgresql(
relation: Name of the PostgreSQL relation to relate
the application to.
status: The status to wait for in the application (default: blocked).
base: The base of the charm to deploy
Returns:
the id of the created relation.
Expand All @@ -299,6 +302,7 @@ async def deploy_and_relate_application_with_postgresql(
channel=channel,
application_name=application_name,
num_units=number_of_units,
base=base,
)
await ops_test.model.wait_for_idle(
apps=[application_name],
Expand Down Expand Up @@ -837,8 +841,10 @@ async def backup_operations(
) -> None:
"""Basic set of operations for backup testing in different cloud providers."""
# Deploy S3 Integrator and TLS Certificates Operator.
await ops_test.model.deploy(s3_integrator_app_name)
await ops_test.model.deploy(tls_certificates_app_name, config=tls_config, channel=tls_channel)
await ops_test.model.deploy(s3_integrator_app_name, base=CHARM_BASE)
await ops_test.model.deploy(
tls_certificates_app_name, config=tls_config, channel=tls_channel, base=CHARM_BASE
)
# Deploy and relate PostgreSQL to S3 integrator (one database app for each cloud for now
# as archivo_mode is disabled after restoring the backup) and to TLS Certificates Operator
# (to be able to create backups from replicas).
Expand Down
31 changes: 19 additions & 12 deletions tests/integration/new_relations/test_new_relations.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

from .. import markers
from ..helpers import (
CHARM_SERIES,
CHARM_BASE,
check_database_users_existence,
scale_application,
)
Expand Down Expand Up @@ -56,7 +56,7 @@ async def test_database_relation_with_charm_libraries(ops_test: OpsTest, databas
APPLICATION_APP_NAME,
application_name=APPLICATION_APP_NAME,
num_units=2,
series=CHARM_SERIES,
base=CHARM_BASE,
channel="edge",
),
ops_test.model.deploy(
Expand All @@ -68,7 +68,7 @@ async def test_database_relation_with_charm_libraries(ops_test: OpsTest, databas
},
application_name=DATABASE_APP_NAME,
num_units=3,
series=CHARM_SERIES,
base=CHARM_BASE,
trust=True,
config={"profile": "testing"},
),
Expand All @@ -81,7 +81,7 @@ async def test_database_relation_with_charm_libraries(ops_test: OpsTest, databas
},
application_name=ANOTHER_DATABASE_APP_NAME,
num_units=3,
series=CHARM_SERIES,
base=CHARM_BASE,
trust=True,
config={"profile": "testing"},
),
Expand Down Expand Up @@ -196,7 +196,7 @@ async def test_two_applications_doesnt_share_the_same_relation_data(ops_test: Op
await ops_test.model.deploy(
APPLICATION_APP_NAME,
application_name=another_application_app_name,
series=CHARM_SERIES,
base=CHARM_BASE,
channel="edge",
)
await ops_test.model.wait_for_idle(apps=all_app_names, status="active")
Expand Down Expand Up @@ -453,7 +453,7 @@ async def test_admin_role(ops_test: OpsTest):
all_app_names = [DATA_INTEGRATOR_APP_NAME]
all_app_names.extend(APP_NAMES)
async with ops_test.fast_forward():
await ops_test.model.deploy(DATA_INTEGRATOR_APP_NAME)
await ops_test.model.deploy(DATA_INTEGRATOR_APP_NAME, base=CHARM_BASE)
await ops_test.model.wait_for_idle(apps=[DATA_INTEGRATOR_APP_NAME], status="blocked")
await ops_test.model.applications[DATA_INTEGRATOR_APP_NAME].set_config({
"database-name": DATA_INTEGRATOR_APP_NAME.replace("-", "_"),
Expand Down Expand Up @@ -542,7 +542,9 @@ async def test_invalid_extra_user_roles(ops_test: OpsTest):
another_data_integrator_app_name = f"another-{DATA_INTEGRATOR_APP_NAME}"
data_integrator_apps_names = [DATA_INTEGRATOR_APP_NAME, another_data_integrator_app_name]
await ops_test.model.deploy(
DATA_INTEGRATOR_APP_NAME, application_name=another_data_integrator_app_name
DATA_INTEGRATOR_APP_NAME,
application_name=another_data_integrator_app_name,
base=CHARM_BASE,
)
await ops_test.model.wait_for_idle(
apps=[another_data_integrator_app_name], status="blocked"
Expand Down Expand Up @@ -607,7 +609,7 @@ async def test_database_deploy_clientapps(ops_test: OpsTest, database_charm):
},
application_name=DATABASE_APP_NAME,
num_units=3,
series=CHARM_SERIES,
base=CHARM_BASE,
trust=True,
config={"profile": "testing"},
),
Expand All @@ -628,7 +630,7 @@ async def test_discourse(ops_test: OpsTest):
await gather(
ops_test.model.deploy(DISCOURSE_APP_NAME, application_name=DISCOURSE_APP_NAME),
ops_test.model.deploy(
REDIS_APP_NAME, application_name=REDIS_APP_NAME, channel="latest/edge"
REDIS_APP_NAME, application_name=REDIS_APP_NAME, channel="latest/edge", base=CHARM_BASE
),
)

Expand Down Expand Up @@ -705,12 +707,17 @@ async def test_indico_datatabase(ops_test: OpsTest) -> None:
async with ops_test.fast_forward(fast_interval="30s"):
await ops_test.model.deploy(
"indico",
channel="stable",
channel="latest/edge",
application_name="indico",
num_units=1,
series="focal",
)
await ops_test.model.deploy(
"redis-k8s", channel="stable", application_name="redis-broker", base="[email protected]"
)
await ops_test.model.deploy(
"redis-k8s", channel="stable", application_name="redis-cache", base="[email protected]"
)
await ops_test.model.deploy("redis-k8s", channel="stable", application_name="redis-broker")
await ops_test.model.deploy("redis-k8s", channel="stable", application_name="redis-cache")
await asyncio.gather(
ops_test.model.relate("redis-broker", "indico:redis-broker"),
ops_test.model.relate("redis-cache", "indico:redis-cache"),
Expand Down
Loading

0 comments on commit 7bcadff

Please sign in to comment.