From 38d9d04cc5e25762a458f7a7288e7babd7c5e8a0 Mon Sep 17 00:00:00 2001 From: gtato Date: Thu, 27 Feb 2025 13:51:44 +0100 Subject: [PATCH 1/4] fix integration test action to be compatible with the publish one --- .github/workflows/integration_test.yaml | 45 +++++++------------ ..._publish_charm.yaml => publish_charm.yaml} | 2 +- 2 files changed, 16 insertions(+), 31 deletions(-) rename .github/workflows/{test_and_publish_charm.yaml => publish_charm.yaml} (91%) diff --git a/.github/workflows/integration_test.yaml b/.github/workflows/integration_test.yaml index 5667857..740b896 100644 --- a/.github/workflows/integration_test.yaml +++ b/.github/workflows/integration_test.yaml @@ -1,35 +1,20 @@ name: Integration tests + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + on: pull_request: workflow_call: + jobs: - integration-test-microk8s: - name: Integration tests (microk8s) - strategy: - fail-fast: false - matrix: - tox-environments: - - integration-charm - - integration-scaling - - integration-upgrades - - integration-policy - - integration-usersync - runs-on: ubuntu-22.04 - steps: - - name: Free disk space - uses: canonical/free-disk-space@main - with: - android: true - dotnet: true - haskell: true - - name: Checkout - uses: actions/checkout@v3 - - name: Setup operator environment - uses: charmed-kubernetes/actions-operator@main - with: - juju-channel: 3.4/stable - provider: microk8s - microk8s-addons: "ingress storage dns rbac registry" - channel: 1.28-strict/stable - - name: Run integration tests - run: tox -e ${{ matrix.tox-environments }} + integration-tests: + uses: canonical/operator-workflows/.github/workflows/integration_test.yaml@main + secrets: inherit + with: + channel: 1.28-strict/stable + modules: '["test_charm.py", "test_policy.py", "test_usersync.py", "test_scaling.py", "test_upgrades.py"]' + juju-channel: 3.4/stable + self-hosted-runner: false + microk8s-addons: "dns ingress rbac storage metallb:10.15.119.2-10.15.119.4 registry" diff --git a/.github/workflows/test_and_publish_charm.yaml b/.github/workflows/publish_charm.yaml similarity index 91% rename from .github/workflows/test_and_publish_charm.yaml rename to .github/workflows/publish_charm.yaml index e18f519..87265eb 100644 --- a/.github/workflows/test_and_publish_charm.yaml +++ b/.github/workflows/publish_charm.yaml @@ -6,7 +6,7 @@ on: - main jobs: - publish-to-edge: + publish: uses: canonical/operator-workflows/.github/workflows/publish_charm.yaml@main secrets: inherit with: From 150b54dbaa024d1a057aa336fbc165d053fe30cd Mon Sep 17 00:00:00 2001 From: gtato Date: Thu, 27 Feb 2025 15:53:23 +0100 Subject: [PATCH 2/4] fix common conftest --- tests/conftest.py | 16 ++++++++++++++++ tests/integration/__init__.py | 4 ++++ tests/integration/test_charm.py | 2 +- 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 tests/conftest.py create mode 100644 tests/integration/__init__.py diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 0000000..f6ab4f4 --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,16 @@ +# Copyright 2023 Canonical Ltd. +# See LICENSE file for licensing details. + +"""Fixtures for charm tests.""" + +import pytest + + +def pytest_addoption(parser: pytest.Parser): + """Parse additional pytest options. + + Args: + parser: pytest command line parser. + """ + # The prebuilt charm file. + parser.addoption("--charm-file", action="append", default=[]) diff --git a/tests/integration/__init__.py b/tests/integration/__init__.py new file mode 100644 index 0000000..2fb9958 --- /dev/null +++ b/tests/integration/__init__.py @@ -0,0 +1,4 @@ +# Copyright 2023 Canonical Ltd. +# See LICENSE file for licensing details. + +"""Tests module.""" diff --git a/tests/integration/test_charm.py b/tests/integration/test_charm.py index 99d0ac4..75a9908 100644 --- a/tests/integration/test_charm.py +++ b/tests/integration/test_charm.py @@ -7,8 +7,8 @@ import pytest import requests -from conftest import deploy # noqa: F401, pylint: disable=W0611 from helpers import APP_NAME, METADATA, NGINX_NAME, POSTGRES_NAME, get_unit_url +from integration.conftest import deploy # noqa: F401, pylint: disable=W0611 from pytest_operator.plugin import OpsTest logger = logging.getLogger(__name__) From d6df671c36aae3081ba78f67d2e58115fa8b4dd9 Mon Sep 17 00:00:00 2001 From: gtato Date: Thu, 27 Feb 2025 16:30:19 +0100 Subject: [PATCH 3/4] fix imports --- tests/integration/conftest.py | 2 +- tests/integration/test_charm.py | 8 +++++++- tests/integration/test_scaling.py | 2 +- tests/integration/test_upgrades.py | 8 +++++++- tests/integration/test_usersync.py | 2 +- 5 files changed, 17 insertions(+), 5 deletions(-) diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index c626591..e71dbac 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -7,7 +7,7 @@ import pytest import pytest_asyncio -from helpers import APP_NAME, METADATA, POSTGRES_NAME +from integration.helpers import APP_NAME, METADATA, POSTGRES_NAME from pytest_operator.plugin import OpsTest logger = logging.getLogger(__name__) diff --git a/tests/integration/test_charm.py b/tests/integration/test_charm.py index 75a9908..d633264 100644 --- a/tests/integration/test_charm.py +++ b/tests/integration/test_charm.py @@ -7,8 +7,14 @@ import pytest import requests -from helpers import APP_NAME, METADATA, NGINX_NAME, POSTGRES_NAME, get_unit_url from integration.conftest import deploy # noqa: F401, pylint: disable=W0611 +from integration.helpers import ( + APP_NAME, + METADATA, + NGINX_NAME, + POSTGRES_NAME, + get_unit_url, +) from pytest_operator.plugin import OpsTest logger = logging.getLogger(__name__) diff --git a/tests/integration/test_scaling.py b/tests/integration/test_scaling.py index 4a8f725..455bc48 100644 --- a/tests/integration/test_scaling.py +++ b/tests/integration/test_scaling.py @@ -7,7 +7,7 @@ import pytest import requests -from helpers import APP_NAME, get_application_url, scale +from integration.helpers import APP_NAME, get_application_url, scale from pytest_operator.plugin import OpsTest logger = logging.getLogger(__name__) diff --git a/tests/integration/test_upgrades.py b/tests/integration/test_upgrades.py index 30c4a51..f84d7db 100644 --- a/tests/integration/test_upgrades.py +++ b/tests/integration/test_upgrades.py @@ -10,7 +10,13 @@ import pytest_asyncio import requests import yaml -from helpers import APP_NAME, METADATA, POSTGRES_NAME, SECURE_PWD, get_unit_url +from integration.helpers import ( + APP_NAME, + METADATA, + POSTGRES_NAME, + SECURE_PWD, + get_unit_url, +) from pytest_operator.plugin import OpsTest logger = logging.getLogger(__name__) diff --git a/tests/integration/test_usersync.py b/tests/integration/test_usersync.py index 147bbca..9caea56 100644 --- a/tests/integration/test_usersync.py +++ b/tests/integration/test_usersync.py @@ -7,7 +7,7 @@ import time import pytest -from helpers import ( +from integration.helpers import ( APP_NAME, LDAP_NAME, METADATA, From 00ffb0c103e565e76b446e00538b25383c94b8ad Mon Sep 17 00:00:00 2001 From: gtato Date: Thu, 27 Feb 2025 16:50:54 +0100 Subject: [PATCH 4/4] fix one more import --- tests/integration/test_policy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/test_policy.py b/tests/integration/test_policy.py index 5e7b71c..9944685 100644 --- a/tests/integration/test_policy.py +++ b/tests/integration/test_policy.py @@ -7,7 +7,7 @@ import pytest from apache_ranger.client import ranger_client -from helpers import ( +from integration.helpers import ( APP_NAME, RANGER_AUTH, TRINO_NAME,