From 83b3df520518089651e145372a10ba556f118e68 Mon Sep 17 00:00:00 2001 From: javierdelapuente Date: Tue, 7 May 2024 18:38:42 +0200 Subject: [PATCH] Fix integration tests and docs for testing. (#215) --- docs/how-to/contribute.md | 24 +++++++++--------------- docs/tutorial.md | 2 +- tests/integration/conftest.py | 4 +--- tests/integration/test_core.py | 2 +- 4 files changed, 12 insertions(+), 20 deletions(-) diff --git a/docs/how-to/contribute.md b/docs/how-to/contribute.md index 321bf8b6..138da518 100644 --- a/docs/how-to/contribute.md +++ b/docs/how-to/contribute.md @@ -27,23 +27,17 @@ WordPress operator. To build and deploy wordpress-k8s charm from source follow the steps below. -#### Docker image build +#### Rockcraft image build and upload -Build the `wordpress.Dockerfile` image with the following command. +Enable MicroK8S registry: -``` -docker build -t wordpress -f wordpress.Dockerfile . -``` - -#### Microk8s upload docker artifacts + microk8s enable registry -For microk8s to pick up the locally built image, you must export the image and import it within -microk8s. +The following commands import the images in the Docker daemon and push them into +the registry: -``` -docker save wordpress > wordpress.tar -microk8s ctr image import wordpress.tar -``` + cd [project_dir]/wordpress_rock && rockcraft pack + skopeo --insecure-policy copy --dest-tls-verify=false oci-archive:wordpress_1.0_amd64.rock docker://localhost:32000/wordpress:latest #### Build the charm @@ -58,8 +52,8 @@ charmcraft pack Deploy the locally built WordPress charm with the following command. ``` -juju deploy ./wordpress-k8s_ubuntu-22.04-amd64_ubuntu-20.04-amd64.charm \ - --resource wordpress-image=wordpress +juju deploy ./wordpress-k8s_ubuntu-22.04-amd64.charm \ + --resource wordpress-image=localhost:32000/wordpress:latest ``` You should now be able to see your local wordpress-k8s charm progress through the stages of the diff --git a/docs/tutorial.md b/docs/tutorial.md index 63aac4a8..05bb15ba 100644 --- a/docs/tutorial.md +++ b/docs/tutorial.md @@ -43,7 +43,7 @@ juju deploy wordpress-k8s The following commands deploy the mysql-k8s charm and integrate it with the wordpress-k8s charm. ``` -juju deploy mysql-k8s +juju deploy mysql-k8s --trust # 'database' interface is required since mysql-k8s charm provides multiple compatible interfaces juju relate wordpress-k8s mysql-k8s:database diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index 81d42450..1eca6e91 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -95,9 +95,7 @@ async def wordpress_fixture( @pytest_asyncio.fixture(scope="module") async def prepare_mysql(ops_test: OpsTest, wordpress: WordpressApp, model: Model): """Deploy and relate the mysql-k8s charm for integration tests.""" - await ops_test.juju( - "deploy", "mysql-k8s", "--channel=8.0/candidate", "--revision=75", "--trust" - ) + await ops_test.juju("deploy", "mysql-k8s", "--channel=8.0/candidate", "--trust") await model.wait_for_idle(status="active", apps=["mysql-k8s"], timeout=30 * 60) await model.relate(f"{wordpress.name}:database", "mysql-k8s:database") await model.wait_for_idle( diff --git a/tests/integration/test_core.py b/tests/integration/test_core.py index b5db6ce8..13c4c2a0 100644 --- a/tests/integration/test_core.py +++ b/tests/integration/test_core.py @@ -127,4 +127,4 @@ async def test_uploads_owner(wordpress: WordpressApp, ops_test: OpsTest): retcode, stdout, _ = await ops_test.run(*cmd) assert retcode == 0 - assert "584792" == stdout + assert "584792" == stdout.strip()