|
| 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 | + ) |
0 commit comments