Skip to content

Commit

Permalink
test integration
Browse files Browse the repository at this point in the history
  • Loading branch information
RafalSiwek committed Dec 27, 2023
1 parent 9393a1c commit fc713f1
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 19 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/integrate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,11 @@ 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 get pods -ntesting -lapp.kubernetes.io/name=zenml-server -oyaml
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: 9 additions & 15 deletions tests/integration/test_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import pytest
import yaml
from pytest_operator.plugin import OpsTest
from tenacity import retry, stop_after_delay, wait_fixed

logger = logging.getLogger(__name__)

Expand All @@ -16,16 +15,6 @@


class TestCharm:
@retry(stop=stop_after_delay(100), wait=wait_fixed(10))
def _test_can_connect_with_zenml_client(self, zenml_url: str):
zenml_subprocess = subprocess.run(
["zenml", "connect", "--url", zenml_url, "--username", "default", "--password", ""]
)
logger.info(f"ZenML command stdout: {zenml_subprocess.stdout}")
if zenml_subprocess.stderr:
logger.info(f"ZenML command stderr: {zenml_subprocess.stderr}")
assert zenml_subprocess.returncode == 0

@pytest.mark.abort_on_fail
@pytest.mark.skip_if_deployed
async def test_successfull_deploy_senario(self, ops_test: OpsTest):
Expand All @@ -50,7 +39,7 @@ async def test_successfull_deploy_senario(self, ops_test: OpsTest):

zenml_port = config["zenml_port"]["value"]

zenml_subprocess = subprocess.Popen(
portforward_subprocess = subprocess.Popen(
[
"kubectl",
"-n",
Expand All @@ -63,7 +52,12 @@ async def test_successfull_deploy_senario(self, ops_test: OpsTest):
time.sleep(10) # Must wait for port-forward

zenml_url = f"http://localhost:{zenml_port}"
zenml_subprocess = subprocess.run(
["zenml", "connect", "--url", zenml_url, "--username", "default", "--password", ""]
)
logger.info(f"ZenML command stdout: {zenml_subprocess.stdout}")
if zenml_subprocess.stderr:
logger.info(f"ZenML command stderr: {zenml_subprocess.stderr}")
assert zenml_subprocess.returncode == 0

self._test_can_connect_with_zenml_client(zenml_url=zenml_url)

zenml_subprocess.terminate()
portforward_subprocess.terminate()

0 comments on commit fc713f1

Please sign in to comment.