Skip to content

Commit

Permalink
Add Ubuntu Pro & Landscape Client subordinate charm test (#115)
Browse files Browse the repository at this point in the history
  • Loading branch information
carlcsaposs-canonical authored Mar 20, 2024
1 parent a7c99af commit fd35e6c
Show file tree
Hide file tree
Showing 5 changed files with 119 additions and 21 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -159,3 +159,9 @@ jobs:
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 }}
env:
LIBJUJU_VERSION_SPECIFIER: ${{ matrix.libjuju-version }}
SECRETS_FROM_GITHUB: |
{
"UBUNTU_PRO_TOKEN" : "${{ secrets.UBUNTU_PRO_TOKEN }}",
"LANDSCAPE_ACCOUNT_NAME": "${{ secrets.LANDSCAPE_ACCOUNT_NAME }}",
"LANDSCAPE_REGISTRATION_KEY": "${{ secrets.LANDSCAPE_REGISTRATION_KEY }}",
}
38 changes: 17 additions & 21 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ pytest = "^7.4.0"
pytest-operator = "^0.28.0"
pytest-operator-cache = {git = "https://github.com/canonical/data-platform-workflows", tag = "v7.0.0", subdirectory = "python/pytest_plugins/pytest_operator_cache"}
pytest-operator-groups = {git = "https://github.com/canonical/data-platform-workflows", tag = "v7.0.0", subdirectory = "python/pytest_plugins/pytest_operator_groups"}
pytest-github-secrets = {git = "https://github.com/canonical/data-platform-workflows", tag = "v7.0.0", subdirectory = "python/pytest_plugins/github_secrets"}
juju = "3.2.0.1"
mysql-connector-python = "~8.0.33"
tenacity = "^8.2.2"
Expand Down
94 changes: 94 additions & 0 deletions tests/integration/test_subordinate_charms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# Copyright 2024 Canonical Ltd.
# See LICENSE file for licensing details.

"""Test charms subordinated alongside MySQL Router charm."""

import asyncio

import pytest

from .test_database import (
APPLICATION_APP_NAME,
MYSQL_APP_NAME,
MYSQL_ROUTER_APP_NAME,
SLOW_TIMEOUT,
)

UBUNTU_PRO_APP_NAME = "ubuntu-advantage"
LANDSCAPE_CLIENT_APP_NAME = "landscape-client"


@pytest.mark.group(1)
async def test_ubuntu_pro(ops_test, mysql_router_charm_series, github_secrets):
mysqlrouter_charm = await ops_test.build_charm(".")
await asyncio.gather(
ops_test.model.deploy(
MYSQL_APP_NAME,
channel="8.0/edge",
application_name=MYSQL_APP_NAME,
config={"profile": "testing"},
),
ops_test.model.deploy(
mysqlrouter_charm,
application_name=MYSQL_ROUTER_APP_NAME,
# deploy mysqlrouter with num_units=None since it's a subordinate charm
num_units=None,
),
ops_test.model.deploy(
APPLICATION_APP_NAME,
application_name=APPLICATION_APP_NAME,
channel="latest/edge",
# MySQL Router is subordinate—it will use the series of the principal charm
series=mysql_router_charm_series,
),
ops_test.model.deploy(
UBUNTU_PRO_APP_NAME,
application_name=UBUNTU_PRO_APP_NAME,
channel="latest/edge",
config={"token": github_secrets["UBUNTU_PRO_TOKEN"]},
),
)
await ops_test.model.relate(f"{MYSQL_APP_NAME}", f"{MYSQL_ROUTER_APP_NAME}")
await ops_test.model.relate(
f"{MYSQL_ROUTER_APP_NAME}:database", f"{APPLICATION_APP_NAME}:database"
)
await ops_test.model.relate(APPLICATION_APP_NAME, UBUNTU_PRO_APP_NAME)
async with ops_test.fast_forward("60s"):
await ops_test.model.wait_for_idle(
apps=[
MYSQL_APP_NAME,
MYSQL_ROUTER_APP_NAME,
APPLICATION_APP_NAME,
UBUNTU_PRO_APP_NAME,
],
status="active",
raise_on_blocked=True,
timeout=SLOW_TIMEOUT,
)


@pytest.mark.group(1)
async def test_landscape_client(ops_test, github_secrets):
await ops_test.model.deploy(
LANDSCAPE_CLIENT_APP_NAME,
application_name=LANDSCAPE_CLIENT_APP_NAME,
channel="latest/edge",
config={
"account-name": github_secrets["LANDSCAPE_ACCOUNT_NAME"],
"registration-key": github_secrets["LANDSCAPE_REGISTRATION_KEY"],
"ppa": "ppa:landscape/self-hosted-beta",
},
)
await ops_test.model.relate(APPLICATION_APP_NAME, LANDSCAPE_CLIENT_APP_NAME)
async with ops_test.fast_forward("60s"):
await ops_test.model.wait_for_idle(
apps=[
MYSQL_APP_NAME,
MYSQL_ROUTER_APP_NAME,
APPLICATION_APP_NAME,
LANDSCAPE_CLIENT_APP_NAME,
],
status="active",
raise_on_blocked=True,
timeout=SLOW_TIMEOUT,
)
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ set_env =
pass_env =
CI
GITHUB_OUTPUT
SECRETS_FROM_GITHUB
allowlist_externals =
{[testenv:pack-wrapper]allowlist_externals}
commands_pre =
Expand Down

0 comments on commit fd35e6c

Please sign in to comment.