Skip to content

Commit

Permalink
Fix integration tests failing on K8s creating resources (#3)
Browse files Browse the repository at this point in the history
* change  integration tests microk8s version to 1.25
  • Loading branch information
RafalSiwek authored Dec 27, 2023
1 parent 06788e8 commit 0ea1067
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 11 deletions.
16 changes: 14 additions & 2 deletions .github/workflows/integrate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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()
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ juju add-model dev
# Enable DEBUG logging
juju model-config logging-config="<root>=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)
```

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
```

Expand All @@ -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
Expand Down
24 changes: 19 additions & 5 deletions tests/integration/test_charm.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import logging
import subprocess
import time
from pathlib import Path

import pytest
Expand All @@ -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", ""]
)
Expand Down

0 comments on commit 0ea1067

Please sign in to comment.