diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 5ac46fd..023399f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -39,8 +39,7 @@ jobs: uses: charmed-kubernetes/actions-operator@main with: provider: microk8s - # This is needed until https://bugs.launchpad.net/juju/+bug/1977582 is fixed - bootstrap-options: "--agent-version 2.9.29" + bootstrap-options: "--agent-version 2.9.43" - name: Run integration tests run: tox -e integration-charm @@ -57,8 +56,7 @@ jobs: uses: charmed-kubernetes/actions-operator@main with: provider: microk8s - # This is needed until https://bugs.launchpad.net/juju/+bug/1977582 is fixed - bootstrap-options: "--agent-version 2.9.29" + bootstrap-options: "--agent-version 2.9.43" - name: Run integration tests run: tox -e integration-relation @@ -75,8 +73,7 @@ jobs: uses: charmed-kubernetes/actions-operator@main with: provider: microk8s - # This is needed until https://bugs.launchpad.net/juju/+bug/1977582 is fixed - bootstrap-options: "--agent-version 2.9.29" + bootstrap-options: "--agent-version 2.9.43" - name: Run integration tests run: tox -e integration-relation -- --num-units 1 @@ -93,8 +90,7 @@ jobs: uses: charmed-kubernetes/actions-operator@main with: provider: microk8s - # This is needed until https://bugs.launchpad.net/juju/+bug/1977582 is fixed - bootstrap-options: "--agent-version 2.9.29" + bootstrap-options: "--agent-version 2.9.43" - name: Run integration tests run: tox -e integration-password @@ -111,7 +107,6 @@ jobs: uses: charmed-kubernetes/actions-operator@main with: provider: microk8s - # This is needed until https://bugs.launchpad.net/juju/+bug/1977582 is fixed bootstrap-options: "--agent-version 2.9.29" - name: Run integration tests run: tox -e integration-scaling \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 2ba9d20..3681328 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,7 +2,7 @@ # Copyright 2022 Canonical Ltd. # See LICENSE file for licensing details. -ops~=1.5.0 +ops~=2.3.0 redis~=4.3.4 jinja2==3.1.1 tenacity==8.0.1 diff --git a/tests/integration/test_redis_relation.py b/tests/integration/test_redis_relation.py index 7711cf7..19f5aa6 100644 --- a/tests/integration/test_redis_relation.py +++ b/tests/integration/test_redis_relation.py @@ -61,19 +61,22 @@ async def test_build_and_deploy(ops_test: OpsTest, num_units: int): FIRST_DISCOURSE_APP_NAME, application_name=FIRST_DISCOURSE_APP_NAME, series="focal" ), ops_test.model.deploy( - POSTGRESQL_APP_NAME, application_name=POSTGRESQL_APP_NAME, series="focal" + POSTGRESQL_APP_NAME, + application_name=POSTGRESQL_APP_NAME, + channel="latest/stable", + series="focal", ), ) await ops_test.model.wait_for_idle( - apps=[APP_NAME, POSTGRESQL_APP_NAME], status="active", timeout=3000 + apps=[APP_NAME, POSTGRESQL_APP_NAME], status="active", idle_period=20, timeout=3000 ) # Discourse becomes blocked waiting for relations. await ops_test.model.wait_for_idle( - apps=[FIRST_DISCOURSE_APP_NAME], status="blocked", timeout=3000 + apps=[FIRST_DISCOURSE_APP_NAME], status="waiting", idle_period=20, timeout=3000 ) assert ( - ops_test.model.applications[FIRST_DISCOURSE_APP_NAME].units[0].workload_status == "blocked" + ops_test.model.applications[FIRST_DISCOURSE_APP_NAME].units[0].workload_status == "waiting" ) assert ops_test.model.applications[POSTGRESQL_APP_NAME].units[0].workload_status == "active" @@ -98,8 +101,13 @@ async def test_discourse_relation(ops_test: OpsTest): """ await ops_test.model.block_until( - lambda: check_application_status(ops_test, "discourse-k8s") == "active", - timeout=600, + lambda: check_application_status(ops_test, FIRST_DISCOURSE_APP_NAME) == "active", + timeout=900, + wait_period=5, + ) + await ops_test.model.block_until( + lambda: check_application_status(ops_test, POSTGRESQL_APP_NAME) == "active", + timeout=900, wait_period=5, ) @@ -113,9 +121,7 @@ async def test_discourse_request(ops_test: OpsTest): assert response.status == 200 -async def test_delete_redis_pod( - ops_test: OpsTest, -): +async def test_delete_redis_pod(ops_test: OpsTest): """Delete the leader redis-k8s pod. Check relation data updated with the new redis-k8s pod IP after pod revived by juju. @@ -127,7 +133,10 @@ async def test_delete_redis_pod( client = AsyncClient(namespace=ops_test.model.info.name) await client.delete(Pod, name=f"{APP_NAME}-{leader_unit_num}") - await ops_test.model.wait_for_idle(status="active") + # Wait for `upgrade_charm` sequence + await ops_test.model.wait_for_idle( + apps=[APP_NAME], status="active", timeout=1000, idle_period=60 + ) await ops_test.model.block_until( lambda: check_application_status(ops_test, FIRST_DISCOURSE_APP_NAME) == "active", timeout=600, @@ -135,8 +144,7 @@ async def test_delete_redis_pod( ) redis_ip_after = await get_address(ops_test, app_name=APP_NAME, unit_num=leader_unit_num) - # discourse restarted, unit_num += 1 - discourse_ip = await get_address(ops_test, app_name=FIRST_DISCOURSE_APP_NAME, unit_num=1) + discourse_ip = await get_address(ops_test, app_name=FIRST_DISCOURSE_APP_NAME) url = f"http://{discourse_ip}:3000/site.json" response = query_url(url) diff --git a/tests/unit/test_charm.py b/tests/unit/test_charm.py index 03d51bb..39f44ba 100644 --- a/tests/unit/test_charm.py +++ b/tests/unit/test_charm.py @@ -28,6 +28,8 @@ def setUp(self): self.harness = Harness(RedisK8sCharm) self.addCleanup(self.harness.cleanup) + self.harness.set_can_connect("redis", True) + self.harness.set_can_connect("sentinel", True) self.harness.begin() self.harness.add_relation(self._peer_relation, self.harness.charm.app.name) diff --git a/tox.ini b/tox.ini index aa14afd..2fec1d6 100644 --- a/tox.ini +++ b/tox.ini @@ -69,11 +69,10 @@ commands = description = Run integration tests deps = pytest - # This is needed because of https://github.com/juju/python-libjuju/pull/698 - juju==2.9.11 + juju==2.9.42.4 pytest-operator pytest-order - lightkube==0.10.0 + lightkube==0.13.0 -r{toxinidir}/requirements.txt commands = pytest -vv --tb native --ignore={[vars]tst_path}unit --log-cli-level=INFO -s {posargs} --durations=0 @@ -82,10 +81,9 @@ commands = description = Run charm integration tests deps = pytest - # This is needed because of https://github.com/juju/python-libjuju/pull/698 - juju==2.9.11 + juju==2.9.42.4 pytest-operator - lightkube==0.10.0 + lightkube==0.13.0 -r{toxinidir}/requirements.txt commands = pytest {[vars]tst_path}/integration/test_charm.py -vv --tb native --ignore={[vars]tst_path}unit --log-cli-level=INFO -s {posargs} --durations=0 @@ -94,8 +92,7 @@ commands = description = Run scaling integration tests deps = pytest - # This is needed because of https://github.com/juju/python-libjuju/pull/698 - juju==2.9.11 + juju==2.9.42.4 pytest-operator pytest-order -r{toxinidir}/requirements.txt @@ -106,8 +103,7 @@ commands = description = Run password integration tests deps = pytest - # This is needed because of https://github.com/juju/python-libjuju/pull/698 - juju==2.9.11 + juju==2.9.42.4 pytest-operator -r{toxinidir}/requirements.txt commands = @@ -117,10 +113,9 @@ commands = description = Run integration tests for redis relation deps = pytest - # This is needed because of https://github.com/juju/python-libjuju/pull/698 - juju==2.9.11 + juju==2.9.42.4 pytest-operator - lightkube==0.10.0 + lightkube==0.13.0 -r{toxinidir}/requirements.txt commands = pytest {[vars]tst_path}/integration/test_redis_relation.py -vv --tb native --ignore={[vars]tst_path}unit --log-cli-level=INFO -s {posargs} --durations=0