Skip to content

Commit fd35e6c

Browse files
Add Ubuntu Pro & Landscape Client subordinate charm test (#115)
https://warthogs.atlassian.net/browse/DPE-3657
1 parent a7c99af commit fd35e6c

File tree

5 files changed

+119
-21
lines changed

5 files changed

+119
-21
lines changed

.github/workflows/ci.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,3 +159,9 @@ jobs:
159159
run: tox run -e integration -- "${{ matrix.groups.path_to_test_file }}" --group="${{ matrix.groups.group_number }}" -m '${{ steps.select-test-stability.outputs.mark_expression }}' --mysql-router-charm-series=${{ matrix.ubuntu-versions.series }} --mysql-router-charm-bases-index=${{ matrix.ubuntu-versions.bases-index }}
160160
env:
161161
LIBJUJU_VERSION_SPECIFIER: ${{ matrix.libjuju-version }}
162+
SECRETS_FROM_GITHUB: |
163+
{
164+
"UBUNTU_PRO_TOKEN" : "${{ secrets.UBUNTU_PRO_TOKEN }}",
165+
"LANDSCAPE_ACCOUNT_NAME": "${{ secrets.LANDSCAPE_ACCOUNT_NAME }}",
166+
"LANDSCAPE_REGISTRATION_KEY": "${{ secrets.LANDSCAPE_REGISTRATION_KEY }}",
167+
}

poetry.lock

Lines changed: 17 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ pytest = "^7.4.0"
5656
pytest-operator = "^0.28.0"
5757
pytest-operator-cache = {git = "https://github.com/canonical/data-platform-workflows", tag = "v7.0.0", subdirectory = "python/pytest_plugins/pytest_operator_cache"}
5858
pytest-operator-groups = {git = "https://github.com/canonical/data-platform-workflows", tag = "v7.0.0", subdirectory = "python/pytest_plugins/pytest_operator_groups"}
59+
pytest-github-secrets = {git = "https://github.com/canonical/data-platform-workflows", tag = "v7.0.0", subdirectory = "python/pytest_plugins/github_secrets"}
5960
juju = "3.2.0.1"
6061
mysql-connector-python = "~8.0.33"
6162
tenacity = "^8.2.2"
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# Copyright 2024 Canonical Ltd.
2+
# See LICENSE file for licensing details.
3+
4+
"""Test charms subordinated alongside MySQL Router charm."""
5+
6+
import asyncio
7+
8+
import pytest
9+
10+
from .test_database import (
11+
APPLICATION_APP_NAME,
12+
MYSQL_APP_NAME,
13+
MYSQL_ROUTER_APP_NAME,
14+
SLOW_TIMEOUT,
15+
)
16+
17+
UBUNTU_PRO_APP_NAME = "ubuntu-advantage"
18+
LANDSCAPE_CLIENT_APP_NAME = "landscape-client"
19+
20+
21+
@pytest.mark.group(1)
22+
async def test_ubuntu_pro(ops_test, mysql_router_charm_series, github_secrets):
23+
mysqlrouter_charm = await ops_test.build_charm(".")
24+
await asyncio.gather(
25+
ops_test.model.deploy(
26+
MYSQL_APP_NAME,
27+
channel="8.0/edge",
28+
application_name=MYSQL_APP_NAME,
29+
config={"profile": "testing"},
30+
),
31+
ops_test.model.deploy(
32+
mysqlrouter_charm,
33+
application_name=MYSQL_ROUTER_APP_NAME,
34+
# deploy mysqlrouter with num_units=None since it's a subordinate charm
35+
num_units=None,
36+
),
37+
ops_test.model.deploy(
38+
APPLICATION_APP_NAME,
39+
application_name=APPLICATION_APP_NAME,
40+
channel="latest/edge",
41+
# MySQL Router is subordinate—it will use the series of the principal charm
42+
series=mysql_router_charm_series,
43+
),
44+
ops_test.model.deploy(
45+
UBUNTU_PRO_APP_NAME,
46+
application_name=UBUNTU_PRO_APP_NAME,
47+
channel="latest/edge",
48+
config={"token": github_secrets["UBUNTU_PRO_TOKEN"]},
49+
),
50+
)
51+
await ops_test.model.relate(f"{MYSQL_APP_NAME}", f"{MYSQL_ROUTER_APP_NAME}")
52+
await ops_test.model.relate(
53+
f"{MYSQL_ROUTER_APP_NAME}:database", f"{APPLICATION_APP_NAME}:database"
54+
)
55+
await ops_test.model.relate(APPLICATION_APP_NAME, UBUNTU_PRO_APP_NAME)
56+
async with ops_test.fast_forward("60s"):
57+
await ops_test.model.wait_for_idle(
58+
apps=[
59+
MYSQL_APP_NAME,
60+
MYSQL_ROUTER_APP_NAME,
61+
APPLICATION_APP_NAME,
62+
UBUNTU_PRO_APP_NAME,
63+
],
64+
status="active",
65+
raise_on_blocked=True,
66+
timeout=SLOW_TIMEOUT,
67+
)
68+
69+
70+
@pytest.mark.group(1)
71+
async def test_landscape_client(ops_test, github_secrets):
72+
await ops_test.model.deploy(
73+
LANDSCAPE_CLIENT_APP_NAME,
74+
application_name=LANDSCAPE_CLIENT_APP_NAME,
75+
channel="latest/edge",
76+
config={
77+
"account-name": github_secrets["LANDSCAPE_ACCOUNT_NAME"],
78+
"registration-key": github_secrets["LANDSCAPE_REGISTRATION_KEY"],
79+
"ppa": "ppa:landscape/self-hosted-beta",
80+
},
81+
)
82+
await ops_test.model.relate(APPLICATION_APP_NAME, LANDSCAPE_CLIENT_APP_NAME)
83+
async with ops_test.fast_forward("60s"):
84+
await ops_test.model.wait_for_idle(
85+
apps=[
86+
MYSQL_APP_NAME,
87+
MYSQL_ROUTER_APP_NAME,
88+
APPLICATION_APP_NAME,
89+
LANDSCAPE_CLIENT_APP_NAME,
90+
],
91+
status="active",
92+
raise_on_blocked=True,
93+
timeout=SLOW_TIMEOUT,
94+
)

tox.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ set_env =
8282
pass_env =
8383
CI
8484
GITHUB_OUTPUT
85+
SECRETS_FROM_GITHUB
8586
allowlist_externals =
8687
{[testenv:pack-wrapper]allowlist_externals}
8788
commands_pre =

0 commit comments

Comments
 (0)