From 0ea106705bd79ff635476be3c20cf83e1fa56491 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Siwek?= <71661357+RafalSiwek@users.noreply.github.com> Date: Wed, 27 Dec 2023 18:27:00 +0100 Subject: [PATCH] Fix integration tests failing on K8s creating resources (#3) * change integration tests microk8s version to 1.25 --- .github/workflows/integrate.yaml | 16 ++++++++++++++-- CONTRIBUTING.md | 2 +- README.md | 6 +++--- tests/integration/test_charm.py | 24 +++++++++++++++++++----- 4 files changed, 37 insertions(+), 11 deletions(-) diff --git a/.github/workflows/integrate.yaml b/.github/workflows/integrate.yaml index 42f2ac3..302cd04 100644 --- a/.github/workflows/integrate.yaml +++ b/.github/workflows/integrate.yaml @@ -69,8 +69,8 @@ jobs: with: juju-channel: "3.1/stable" provider: microk8s - channel: 1.28-strict/stable - microk8s-addons: "dns storage metallb:10.64.140.43-10.64.140.49" + channel: 1.25-strict/stable + microk8s-addons: "dns storage rbac metallb:10.64.140.43-10.64.140.49" - name: Run integration tests run: sg snap_microk8s -c "tox -vve integration -- --model testing" @@ -91,3 +91,15 @@ jobs: - name: Get operator logs run: kubectl logs --tail 100 -ntesting -loperator.juju.is/name=zenml-server if: failure() + + - name: Get container logs + run: kubectl logs --tail 100 -ntesting -lapp.kubernetes.io/name=zenml-server -czenml-server + if: failure() + + - name: Get container + run: kubectl describe po -ntesting -lapp.kubernetes.io/name=zenml-server + if: failure() + + - name: Get jobs + run: kubectl get jobs -ntesting + if: failure() diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c81bd62..95c33c2 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -52,7 +52,7 @@ juju add-model dev # Enable DEBUG logging juju model-config logging-config="=INFO;unit=DEBUG" # Deploy the charm -juju deploy ./zenml-server_ubuntu-22.04-amd64.charm \ +juju deploy ./zenml-server_ubuntu-20.04-amd64.charm \ --resource oci-image=$(yq '.resources."oci-image"."upstream-source"' metadata.yaml) ``` diff --git a/README.md b/README.md index 0896a3e..5acc8df 100644 --- a/README.md +++ b/README.md @@ -108,7 +108,6 @@ To connect the `zenml SDK` to it run zenml connect --uri http://localhost:31375/ --username default --password '' ``` - ### Build and deploy the charm manually Install dependencies @@ -123,12 +122,12 @@ Create ZenML Charm charmcraft pack ``` -This step will generate a charm file **zenml-server_ubuntu-22.04-amd64.charm** +This step will generate a charm file **zenml-server_ubuntu-20.04-amd64.charm** Deploy the ZenML server charm ```bash -juju deploy ./zenml-server_ubuntu-22.04-amd64.charm zenml-server \ +juju deploy ./zenml-server_ubuntu-20.04-amd64.charm zenml-server \ --resource oci-image=$(yq '.resources."oci-image"."upstream-source"' metadata.yaml) ``` @@ -145,6 +144,7 @@ Run `juju status --watch 2s` to observe the charm deployment and after all the a ``` http://localhost:31375/ ``` + With the same credentials ## Integrate ZenML Server with Charmed Kubeflow diff --git a/tests/integration/test_charm.py b/tests/integration/test_charm.py index 714d193..75b16d0 100644 --- a/tests/integration/test_charm.py +++ b/tests/integration/test_charm.py @@ -1,5 +1,6 @@ import logging import subprocess +import time from pathlib import Path import pytest @@ -20,23 +21,36 @@ async def test_successfull_deploy_senario(self, ops_test: OpsTest): await ops_test.model.deploy( RELATIONAL_DB_CHARM_NAME, channel="8.0/stable", - series="jammy", trust=True, ) - await ops_test.model.relate(CHARM_NAME, RELATIONAL_DB_CHARM_NAME) await ops_test.model.wait_for_idle( - apps=[CHARM_NAME], + apps=[RELATIONAL_DB_CHARM_NAME], status="active", raise_on_blocked=False, raise_on_error=False, timeout=600, ) + + await ops_test.model.relate(RELATIONAL_DB_CHARM_NAME, CHARM_NAME) + + time.sleep(10) # Wait for relation to get active setup + + await ops_test.model.wait_for_idle( + apps=[RELATIONAL_DB_CHARM_NAME, CHARM_NAME], + status="active", + raise_on_blocked=False, + raise_on_error=False, + timeout=600, + ) + assert ops_test.model.applications[CHARM_NAME].units[0].workload_status == "active" config = await ops_test.model.applications[CHARM_NAME].get_config() - zenml_nodeport = config["zenml_nodeport"]["value"] - zenml_url = f"http://localhost:{zenml_nodeport}" + + zenml_port = config["zenml_nodeport"]["value"] + + zenml_url = f"http://localhost:{zenml_port}" zenml_subprocess = subprocess.run( ["zenml", "connect", "--url", zenml_url, "--username", "default", "--password", ""] )