From 0abba878db16f044acd1fd47f2b361dcb226fe8a Mon Sep 17 00:00:00 2001 From: NucciTheBoss Date: Thu, 23 Mar 2023 12:11:51 -0400 Subject: [PATCH 1/2] bugfix: Fix integration tests Notes: * Bumped CI pipeline to use Juju 3.1/stable. * Update integration tests to use MySQL and MySQL router operators over Percona XtraDB Cluster. * Removed tenacity as a test dependency. --- .github/workflows/ci.yaml | 4 +--- tests/integration/helpers.py | 1 - tests/integration/test_charm.py | 38 ++++++++++++++++----------------- tox.ini | 5 ++--- 4 files changed, 22 insertions(+), 26 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 79be76f..e9eb660 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -24,7 +24,6 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 - - name: woke uses: get-woke/woke-action@v0 with: @@ -67,7 +66,6 @@ jobs: uses: charmed-kubernetes/actions-operator@main with: provider: lxd - # Juju channel should eventually be updated to 3.0/stable - juju-channel: 2.9/stable + juju-channel: 3.1/stable - name: Run tests run: tox -e integration diff --git a/tests/integration/helpers.py b/tests/integration/helpers.py index 90ea73e..9b21ee6 100644 --- a/tests/integration/helpers.py +++ b/tests/integration/helpers.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python3 # Copyright 2023 Canonical Ltd. # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/tests/integration/test_charm.py b/tests/integration/test_charm.py index 8801012..06e1a8c 100644 --- a/tests/integration/test_charm.py +++ b/tests/integration/test_charm.py @@ -32,6 +32,8 @@ SLURMD = "slurmd" SLURMDBD = "slurmdbd" SLURMRESTD = "slurmrestd" +DATABASE = "mysql" +ROUTER = "mysql-router" @pytest.mark.abort_on_fail @@ -76,31 +78,29 @@ async def test_build_and_deploy( series=series, ), ops_test.model.deploy( - "percona-cluster", - application_name="mysql", + ROUTER, + application_name=f"{SLURMDBD}-{ROUTER}", + channel="dpe/edge", + num_units=1, + series=series, + ), + ops_test.model.deploy( + DATABASE, + application_name=DATABASE, channel="edge", num_units=1, - series="bionic", + series="jammy", ), ) - # Attach ETCD resource to the slurmctld controller + # Attach resources to charms. await ops_test.juju("attach-resource", SLURMCTLD, f"etcd={res_slurmctld['etcd']}") - - # Add slurmdbd relation to slurmctld - await ops_test.model.relate(SLURMCTLD, SLURMDBD) - - # Add mysql relation to slurmdbd - await ops_test.model.relate(SLURMDBD, "mysql") - - # Add slurmctld relation to slurmrestd - await ops_test.model.relate(SLURMRESTD, SLURMCTLD) - - # Attach NHC resource to the slurmd controller await ops_test.juju("attach-resource", SLURMD, f"nhc={res_slurmd['nhc']}") - - # Add slurmctld relation to slurmd - await ops_test.model.add_relation(SLURMD, SLURMCTLD) - + # Set relations for charmed applications. + await ops_test.model.relate(f"{SLURMCTLD}:{SLURMDBD}", f"{SLURMDBD}:{SLURMDBD}") + await ops_test.model.relate(f"{SLURMDBD}-{ROUTER}:backend-database", f"{DATABASE}:database") + await ops_test.model.relate(f"{SLURMDBD}:database", f"{SLURMDBD}-{ROUTER}:database") + await ops_test.model.relate(f"{SLURMRESTD}:slurmrestd", f"{SLURMCTLD}:slurmrestd") + await ops_test.model.add_relation(f"{SLURMD}:{SLURMD}", f"{SLURMCTLD}:{SLURMD}") # Reduce the update status frequency to accelerate the triggering of deferred events. async with ops_test.fast_forward(): await ops_test.model.wait_for_idle(apps=[SLURMRESTD], status="active", timeout=1000) diff --git a/tox.ini b/tox.ini index b498c97..caa897b 100644 --- a/tox.ini +++ b/tox.ini @@ -56,10 +56,9 @@ commands = [testenv:integration] description = Run integration tests deps = + juju==3.1.0.1 pytest==7.2.0 - juju==3.0.4 pytest-operator==0.22.0 - requests==2.28.1 tenacity==8.1.0 commands = pytest -v \ @@ -67,6 +66,6 @@ commands = --tb native \ --ignore={[vars]tst_path}unit \ --log-cli-level=INFO \ - --model controller \ + --model dev \ --keep-models \ {posargs} From bab679eec901875cdbd7b3833b9c8764db7a690a Mon Sep 17 00:00:00 2001 From: NucciTheBoss Date: Thu, 23 Mar 2023 12:14:02 -0400 Subject: [PATCH 2/2] refactor: Change target model back to controller --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index caa897b..fee5cf1 100644 --- a/tox.ini +++ b/tox.ini @@ -66,6 +66,6 @@ commands = --tb native \ --ignore={[vars]tst_path}unit \ --log-cli-level=INFO \ - --model dev \ + --model controller \ --keep-models \ {posargs}