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

Add noble integration tests #342

Merged
merged 4 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
13 changes: 11 additions & 2 deletions .github/workflows/check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 [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"]
exclude:
# NOTE(rgildein): The grafana-agent does not support [email protected] on arm64.
rgildein marked this conversation as resolved.
Show resolved Hide resolved
- test-command: 'tox -e func -- -v --base [email protected] --keep-models'
runs-on: [Ubuntu_ARM64_4C_16G_01]
rgildein marked this conversation as resolved.
Show resolved Hide resolved
steps:

- uses: actions/checkout@v4
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.
rgildein marked this conversation as resolved.
Show resolved Hide resolved
{% 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
Loading