Skip to content

Commit

Permalink
Add noble integration tests
Browse files Browse the repository at this point in the history
The hw supports Noble, but we did not provide tests for it.
Add noble option to pytest CLI options.

Signed-off-by: Robert Gildein <[email protected]>
  • Loading branch information
rgildein committed Nov 15, 2024
1 parent c4f807b commit 2d02582
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 35 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,13 @@ 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 [email protected] --keep-models'
- 'tox -e func -- -v --base [email protected] --keep-models'
- 'tox -e func -- -v --base [email protected] --keep-models'
juju-channel: ["3.4/stable"]
steps:

Expand Down
9 changes: 6 additions & 3 deletions tests/functional/bundle.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand All @@ -16,7 +16,11 @@ applications:
- "0"
grafana-agent:
charm: grafana-agent
channel: stable
{% if base == '[email protected]' %}
channel: latest/candidate # Note(rgildein): Right now, grafana-agent is not support for Noble on latest/stable.
{% else %}
channel: latest/stable
{% endif %}
hardware-observer:
charm: {{ charm }}

Expand All @@ -25,4 +29,3 @@ relations:
- ubuntu:juju-info
- - hardware-observer:general-info
- ubuntu:juju-info

12 changes: 6 additions & 6 deletions tests/functional/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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="[email protected]",
choices=["[email protected]", "[email protected]", "[email protected]"],
help="Set base for the applications.",
)

parser.addoption(
Expand All @@ -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")
Expand Down
4 changes: 2 additions & 2 deletions tests/functional/test_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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",
Expand Down
12 changes: 6 additions & 6 deletions tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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="[email protected]",
choices=["[email protected]", "[email protected]", "[email protected]"],
help="Set base for the applications.",
)
parser.addoption(
"--channel",
Expand All @@ -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")
Expand Down
22 changes: 6 additions & 16 deletions tests/integration/test_cos_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit 2d02582

Please sign in to comment.