From d56ff3cbaa447936b6733e4c1ab9cc9cd3b43ade Mon Sep 17 00:00:00 2001 From: Robert Gildein Date: Tue, 19 Nov 2024 08:41:55 +0100 Subject: [PATCH] Add noble integration tests (#342) * Add noble integration tests The hw supports Noble, but we did not provide tests for it. Add noble option to pytest CLI options. Signed-off-by: Robert Gildein * Exclude arm64 test for noble Grafana-agent do not support arm64 for Noble. Signed-off-by: Robert Gildein * Apply suggestions from code review Co-authored-by: Andrea Ieri --------- Signed-off-by: Robert Gildein Co-authored-by: Andrea Ieri --- .github/workflows/check.yaml | 13 +++++++++++-- tests/functional/bundle.yaml.j2 | 9 ++++++--- tests/functional/conftest.py | 12 ++++++------ tests/functional/test_charm.py | 4 ++-- tests/integration/conftest.py | 12 ++++++------ tests/integration/test_cos_integration.py | 22 ++++++---------------- 6 files changed, 37 insertions(+), 35 deletions(-) diff --git a/.github/workflows/check.yaml b/.github/workflows/check.yaml index 52c1354c..cc22f45a 100644 --- a/.github/workflows/check.yaml +++ b/.github/workflows/check.yaml @@ -82,9 +82,18 @@ jobs: strategy: fail-fast: false matrix: - runs-on: [[ubuntu-22.04], [Ubuntu_ARM64_4C_16G_01]] - test-command: ['tox -e func -- -v --series focal --keep-models', 'tox -e func -- -v --series jammy --keep-models'] + runs-on: + - [ubuntu-22.04] + - [Ubuntu_ARM64_4C_16G_01] + test-command: + - 'tox -e func -- -v --base ubuntu@20.04 --keep-models' + - 'tox -e func -- -v --base ubuntu@22.04 --keep-models' + - 'tox -e func -- -v --base ubuntu@24.04 --keep-models' juju-channel: ["3.4/stable"] + exclude: + # NOTE(rgildein): The grafana-agent does not support ubuntu@24.04 on arm64. See #347 + - test-command: 'tox -e func -- -v --base ubuntu@24.04 --keep-models' + runs-on: [Ubuntu_ARM64_4C_16G_01] steps: - uses: actions/checkout@v4 diff --git a/tests/functional/bundle.yaml.j2 b/tests/functional/bundle.yaml.j2 index 63def9a6..f23a5bcd 100644 --- a/tests/functional/bundle.yaml.j2 +++ b/tests/functional/bundle.yaml.j2 @@ -3,7 +3,7 @@ # ubuntu:juju-info <-> hardware-observer:general-info # grafana-agent:cos-agent <-> hardware-observer:cos-agent -series: {{ series }} +default-base: {{ base }} machines: "0": @@ -16,7 +16,11 @@ applications: - "0" grafana-agent: charm: grafana-agent - channel: stable + {% if base == 'ubuntu@24.04' %} + channel: latest/candidate # Note(rgildein): Right now, grafana-agent is not support for Noble on latest/stable. See #348 + {% else %} + channel: latest/stable + {% endif %} hardware-observer: charm: {{ charm }} @@ -25,4 +29,3 @@ relations: - ubuntu:juju-info - - hardware-observer:general-info - ubuntu:juju-info - diff --git a/tests/functional/conftest.py b/tests/functional/conftest.py index 219964ef..fc6ec0c6 100644 --- a/tests/functional/conftest.py +++ b/tests/functional/conftest.py @@ -11,11 +11,11 @@ def pytest_addoption(parser): parser.addoption( - "--series", + "--base", type=str.lower, - default="jammy", - choices=["focal", "jammy"], - help="Set series for the machine units", + default="ubuntu@22.04", + choices=["ubuntu@20.04", "ubuntu@22.04", "ubuntu@24.04"], + help="Set base for the applications.", ) parser.addoption( @@ -38,8 +38,8 @@ def pytest_addoption(parser): @pytest.fixture(scope="module") -def series(request): - return request.config.getoption("--series") +def base(request): + return request.config.getoption("--base") @pytest.fixture(scope="module") diff --git a/tests/functional/test_charm.py b/tests/functional/test_charm.py index b3d4bb0d..45a50fae 100644 --- a/tests/functional/test_charm.py +++ b/tests/functional/test_charm.py @@ -56,7 +56,7 @@ class AppStatus(str, Enum): @pytest.mark.abort_on_fail @pytest.mark.skip_if_deployed async def test_build_and_deploy( # noqa: C901, function is too complex - ops_test: OpsTest, series, architecture, provided_collectors, required_resources + ops_test: OpsTest, base, architecture, provided_collectors, required_resources ): """Build the charm-under-test and deploy it together with related charms. @@ -78,7 +78,7 @@ async def test_build_and_deploy( # noqa: C901, function is too complex bundle = ops_test.render_bundle( bundle_template_path, charm=charm, - series=series, + base=base, resources={ "storcli-deb": "empty-resource", "perccli-deb": "empty-resource", diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index 5093502c..d672ad53 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -16,11 +16,11 @@ def pytest_addoption(parser): parser.addoption( - "--series", + "--base", type=str.lower, - default="jammy", - choices=["focal", "jammy"], - help="Set series for the machine units", + default="ubuntu@22.04", + choices=["ubuntu@20.04", "ubuntu@22.04", "ubuntu@24.04"], + help="Set base for the applications.", ) parser.addoption( "--channel", @@ -32,8 +32,8 @@ def pytest_addoption(parser): @pytest.fixture(scope="module") -def series(request): - return request.config.getoption("--series") +def base(request): + return request.config.getoption("--base") @pytest.fixture(scope="module") diff --git a/tests/integration/test_cos_integration.py b/tests/integration/test_cos_integration.py index 6499d72a..da387e29 100644 --- a/tests/integration/test_cos_integration.py +++ b/tests/integration/test_cos_integration.py @@ -19,11 +19,11 @@ @pytest.mark.abort_on_fail @pytest.mark.skip_if_deployed -async def test_setup_and_deploy(series, channel, lxd_ctl, k8s_ctl, lxd_model, k8s_model): +async def test_setup_and_deploy(base, channel, lxd_ctl, k8s_ctl, lxd_model, k8s_model): """Setup models and then deploy Hardware Observer and COS.""" await _deploy_cos(channel, k8s_ctl, k8s_model) - await _deploy_hardware_observer(series, channel, lxd_model) + await _deploy_hardware_observer(base, channel, lxd_model) await _add_cross_controller_relations(k8s_ctl, lxd_ctl, k8s_model, lxd_model) @@ -148,25 +148,15 @@ async def _deploy_cos(channel, ctl, model): subprocess.run(cmd, check=True) -async def _deploy_hardware_observer(series, channel, model): +async def _deploy_hardware_observer(base, channel, model): """Deploy Hardware Observer and Grafana Agent on the existing lxd cloud.""" await asyncio.gather( # Principal Ubuntu - model.deploy( - "ubuntu", - num_units=1, - series=series, - channel=channel, - ), + model.deploy("ubuntu", num_units=1, base=base, channel=channel), # Hardware Observer - model.deploy("hardware-observer", series=series, num_units=0, channel=channel), + model.deploy("hardware-observer", base=base, num_units=0, channel=channel), # Grafana Agent - model.deploy( - "grafana-agent", - num_units=0, - series=series, - channel=channel, - ), + model.deploy("grafana-agent", num_units=0, base=base, channel=channel), ) await model.add_relation("ubuntu:juju-info", "hardware-observer:general-info")