From c20f53479c9ae2371b4252ae88851516769adf87 Mon Sep 17 00:00:00 2001 From: Carl Csaposs Date: Thu, 16 Feb 2023 14:06:55 +0000 Subject: [PATCH] Cache charmcraft pack container, skip unstable tests except on schedule Ported from https://github.com/canonical/mysql-k8s-operator/pull/146 --- .github/workflows/ci.yaml | 152 ++++++------------ CONTRIBUTING.md | 17 +- pyproject.toml | 10 +- tests/integration/conftest.py | 25 ++- .../integration/ha_tests/test_self_healing.py | 6 - .../new_relations/test_new_relations.py | 11 -- tests/integration/test_charm.py | 5 - tests/integration/test_db.py | 4 - tests/integration/test_db_admin.py | 1 - tests/integration/test_password_rotation.py | 2 - tests/integration/test_tls.py | 3 - tox.ini | 88 ++++++---- 12 files changed, 140 insertions(+), 184 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index b66f14f986..61409b9c1d 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1,6 +1,12 @@ +# Copyright 2022 Canonical Ltd. +# See LICENSE file for licensing details. name: Tests + on: pull_request: + schedule: + - cron: '53 0 * * *' # Daily at 00:53 UTC + # Triggered on push to branch "main" by .github/workflows/release.yaml workflow_call: jobs: @@ -10,10 +16,11 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 - - name: Install dependencies + - name: Install tox + # TODO: Consider replacing with custom image on self-hosted runner OR pinning version run: python3 -m pip install tox - name: Run linters - run: tox -e lint + run: tox run -e lint unit-test: name: Unit tests @@ -21,125 +28,62 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 - - name: Install dependencies - run: python -m pip install tox + - name: Install tox + # TODO: Consider replacing with custom image on self-hosted runner OR pinning version + run: python3 -m pip install tox - name: Run tests - run: tox -e unit + run: tox run -e unit - name: Upload Coverage to Codecov uses: codecov/codecov-action@v3 - integration-test-lxd-charm: - name: Integration tests for charm deployment (lxd) - needs: - - lint - - unit-test - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Setup operator environment - uses: charmed-kubernetes/actions-operator@main - with: - provider: lxd - - name: Run integration tests - run: tox -e charm-integration - - integration-test-lxd-database-relation: - name: Integration tests for database relation (lxd) - needs: - - lint - - unit-test - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Setup operator environment - uses: charmed-kubernetes/actions-operator@main - with: - provider: lxd - # This is needed until https://bugs.launchpad.net/juju/+bug/1992833 is fixed. - bootstrap-options: "--agent-version 2.9.34" - - name: Run integration tests - run: tox -e database-relation-integration - - integration-test-lxd-db-relation: - name: Integration tests for db relation (lxd) - needs: - - lint - - unit-test - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Setup operator environment - uses: charmed-kubernetes/actions-operator@main - with: - provider: lxd - - name: Run integration tests - run: tox -e db-relation-integration - - integration-test-lxd-db-admin-relation: - name: Integration tests for db-admin relation (lxd) - needs: - - lint - - unit-test - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Setup operator environment - uses: charmed-kubernetes/actions-operator@main - with: - provider: lxd - - name: Run integration tests - run: tox -e db-admin-relation-integration + build: + name: Build charms + uses: canonical/data-platform-workflows/.github/workflows/build_charms_with_cache.yaml@v1 - integration-test-ha-self-healing-rotation: - name: Integration tests for high availability self healing (lxd) + integration-test: + strategy: + fail-fast: false + matrix: + tox-environments: + - charm-integration + - database-relation-integration + - db-relation-integration + - db-admin-relation-integration + - ha-self-healing-integration + - password-rotation-integration + - tls-integration + name: ${{ matrix.tox-environments }} needs: - lint - unit-test + - build runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v3 - name: Setup operator environment + # TODO: Replace with custom image on self-hosted runner uses: charmed-kubernetes/actions-operator@main with: provider: lxd # This is needed until https://bugs.launchpad.net/juju/+bug/1992833 is fixed. bootstrap-options: "--agent-version 2.9.34" - - name: Run integration tests - run: tox -e ha-self-healing-integration - - integration-test-lxd-password-rotation: - name: Integration tests for password rotation (lxd) - needs: - - lint - - unit-test - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Setup operator environment - uses: charmed-kubernetes/actions-operator@main - with: - provider: lxd - - name: Run integration tests - run: tox -e password-rotation-integration - - integration-test-lxd-tls: - name: Integration tests for TLS (lxd) - needs: - - lint - - unit-test - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Setup operator environment - uses: charmed-kubernetes/actions-operator@main + - name: Download packed charm(s) + uses: actions/download-artifact@v3 with: - provider: lxd + name: ${{ needs.build.outputs.artifact-name }} + - name: Select tests + id: select-tests + run: | + if [ "${{ github.event_name }}" == "schedule" ] + then + echo Running unstable and stable tests + echo "mark_expression=" >> $GITHUB_OUTPUT + else + echo Skipping unstable tests + echo "mark_expression=not unstable" >> $GITHUB_OUTPUT + fi - name: Run integration tests - run: tox -e tls-integration + run: tox run -e ${{ matrix.tox-environments }} -- -m '${{ steps.select-tests.outputs.mark_expression }}' + env: + CI_PACKED_CHARMS: ${{ needs.build.outputs.charms }} diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index dba2e94ebc..9e72d3264c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -21,23 +21,24 @@ this operator. ## Developing -You can use the environments created by `tox` for development: +You can create an environment for development with `tox`: ```shell -tox --notest -e unit -source .tox/unit/bin/activate +tox devenv -e integration +source venv/bin/activate ``` ### Testing ```shell -tox -e fmt # update your code according to linting rules -tox -e lint # code style -tox -e unit # unit tests -tox -e integration # integration tests -tox # runs 'lint' and 'unit' environments +tox run -e format # update your code according to linting rules +tox run -e lint # code style +tox run -e unit # unit tests +tox run -e integration # integration tests +tox # runs 'lint' and 'unit' environments ``` + ## Build charm Build the charm in this git repository using: diff --git a/pyproject.toml b/pyproject.toml index d596539718..236ffc0fb7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -15,15 +15,7 @@ exclude_lines = [ minversion = "6.0" log_cli_level = "INFO" asyncio_mode = "auto" -markers = [ - "charm_tests", - "database_relation_tests", - "db_relation_tests", - "db_admin_relation_tests", - "ha_self_healing_tests", - "password_rotation_tests", - "tls_tests", -] +markers = ["unstable"] # Formatting tools configuration [tool.black] diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index 2e47504452..8c7bd1136c 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -1,10 +1,33 @@ #!/usr/bin/env python3 # Copyright 2022 Canonical Ltd. # See LICENSE file for licensing details. -import pytest as pytest + +import json +import os +from pathlib import Path + +import pytest from pytest_operator.plugin import OpsTest +@pytest.fixture +def ops_test(ops_test: OpsTest) -> OpsTest: + if os.environ.get("CI") == "true": + # Running in GitHub Actions; skip build step + # (GitHub Actions uses a separate, cached build step. See .github/workflows/ci.yaml) + packed_charms = json.loads(os.environ["CI_PACKED_CHARMS"]) + + async def build_charm(charm_path, bases_index: int = None) -> Path: + for charm in packed_charms: + if Path(charm_path) == Path(charm["directory_path"]): + if bases_index is None or bases_index == charm["bases_index"]: + return charm["file_path"] + raise ValueError(f"Unable to find .charm file for {bases_index=} at {charm_path=}") + + ops_test.build_charm = build_charm + return ops_test + + @pytest.fixture(scope="module") async def charm(ops_test: OpsTest): """Build the charm-under-test.""" diff --git a/tests/integration/ha_tests/test_self_healing.py b/tests/integration/ha_tests/test_self_healing.py index 0c93007444..90d6a72c48 100644 --- a/tests/integration/ha_tests/test_self_healing.py +++ b/tests/integration/ha_tests/test_self_healing.py @@ -41,7 +41,6 @@ @pytest.mark.abort_on_fail -@pytest.mark.ha_self_healing_tests async def test_build_and_deploy(ops_test: OpsTest) -> None: """Build and deploy three unit of PostgreSQL.""" # It is possible for users to provide their own cluster for HA testing. Hence, check if there @@ -56,7 +55,6 @@ async def test_build_and_deploy(ops_test: OpsTest) -> None: await ops_test.model.wait_for_idle(status="active", timeout=1000) -@pytest.mark.ha_self_healing_tests @pytest.mark.parametrize("process", DB_PROCESSES) async def test_kill_db_process( ops_test: OpsTest, process: str, continuous_writes, master_start_timeout @@ -116,7 +114,6 @@ async def test_kill_db_process( ), "secondary not up to date with the cluster after restarting." -@pytest.mark.ha_self_healing_tests @pytest.mark.parametrize("process", DB_PROCESSES) async def test_freeze_db_process( ops_test: OpsTest, process: str, continuous_writes, master_start_timeout @@ -182,7 +179,6 @@ async def test_freeze_db_process( ), "secondary not up to date with the cluster after restarting." -@pytest.mark.ha_self_healing_tests @pytest.mark.parametrize("process", DB_PROCESSES) async def test_restart_db_process( ops_test: OpsTest, process: str, continuous_writes, master_start_timeout @@ -235,7 +231,6 @@ async def test_restart_db_process( ), "secondary not up to date with the cluster after restarting." -@pytest.mark.ha_self_healing_tests @pytest.mark.parametrize("process", [PATRONI_PROCESS]) @pytest.mark.parametrize("signal", ["SIGTERM", "SIGKILL"]) async def test_full_cluster_restart( @@ -293,7 +288,6 @@ async def test_full_cluster_restart( assert total_expected_writes == actual_writes, "writes to the db were missed." -@pytest.mark.ha_self_healing_tests async def test_forceful_restart_without_data_and_transaction_logs( ops_test: OpsTest, continuous_writes, diff --git a/tests/integration/new_relations/test_new_relations.py b/tests/integration/new_relations/test_new_relations.py index dcd413a68e..b9ca63b13b 100644 --- a/tests/integration/new_relations/test_new_relations.py +++ b/tests/integration/new_relations/test_new_relations.py @@ -32,7 +32,6 @@ @pytest.mark.abort_on_fail -@pytest.mark.database_relation_tests async def test_deploy_charms(ops_test: OpsTest, application_charm, database_charm): """Deploy both charms (application and database) to use in the tests.""" # Deploy both charms (multiple units for each application to test that later they correctly @@ -67,7 +66,6 @@ async def test_deploy_charms(ops_test: OpsTest, application_charm, database_char await ops_test.model.wait_for_idle(apps=APP_NAMES, status="active", timeout=3000) -@pytest.mark.database_relation_tests async def test_no_read_only_endpoint_in_standalone_cluster(ops_test: OpsTest): """Test that there is no read-only endpoint in a standalone cluster.""" async with ops_test.fast_forward(): @@ -94,7 +92,6 @@ async def test_no_read_only_endpoint_in_standalone_cluster(ops_test: OpsTest): ) -@pytest.mark.database_relation_tests async def test_read_only_endpoint_in_scaled_up_cluster(ops_test: OpsTest): """Test that there is read-only endpoint in a scaled up cluster.""" async with ops_test.fast_forward(): @@ -112,7 +109,6 @@ async def test_read_only_endpoint_in_scaled_up_cluster(ops_test: OpsTest): ) -@pytest.mark.database_relation_tests async def test_database_relation_with_charm_libraries(ops_test: OpsTest): """Test basic functionality of database relation interface.""" # Get the connection string to connect to the database using the read/write endpoint. @@ -160,7 +156,6 @@ async def test_database_relation_with_charm_libraries(ops_test: OpsTest): cursor.execute("DROP TABLE test;") -@pytest.mark.database_relation_tests async def test_user_with_extra_roles(ops_test: OpsTest): """Test superuser actions and the request for more permissions.""" # Get the connection string to connect to the database. @@ -181,7 +176,6 @@ async def test_user_with_extra_roles(ops_test: OpsTest): connection.close() -@pytest.mark.database_relation_tests async def test_two_applications_doesnt_share_the_same_relation_data( ops_test: OpsTest, application_charm ): @@ -216,7 +210,6 @@ async def test_two_applications_doesnt_share_the_same_relation_data( assert application_connection_string != another_application_connection_string -@pytest.mark.database_relation_tests async def test_an_application_can_connect_to_multiple_database_clusters( ops_test: OpsTest, database_charm ): @@ -249,7 +242,6 @@ async def test_an_application_can_connect_to_multiple_database_clusters( assert application_connection_string != another_application_connection_string -@pytest.mark.database_relation_tests async def test_an_application_can_connect_to_multiple_aliased_database_clusters( ops_test: OpsTest, database_charm ): @@ -285,7 +277,6 @@ async def test_an_application_can_connect_to_multiple_aliased_database_clusters( assert application_connection_string != another_application_connection_string -@pytest.mark.database_relation_tests async def test_an_application_can_request_multiple_databases(ops_test: OpsTest, application_charm): """Test that an application can request additional databases using the same interface.""" # Relate the charms using another relation and wait for them exchanging some connection data. @@ -306,7 +297,6 @@ async def test_an_application_can_request_multiple_databases(ops_test: OpsTest, assert first_database_connection_string != second_database_connection_string -@pytest.mark.database_relation_tests async def test_relation_data_is_updated_correctly_when_scaling(ops_test: OpsTest): """Test that relation data, like connection data, is updated correctly when scaling.""" # Retrieve the list of current database unit names. @@ -372,7 +362,6 @@ async def test_relation_data_is_updated_correctly_when_scaling(ops_test: OpsTest psycopg2.connect(primary_connection_string) -@pytest.mark.database_relation_tests async def test_relation_with_no_database_name(ops_test: OpsTest): """Test that a relation with no database name doesn't block the charm.""" async with ops_test.fast_forward(): diff --git a/tests/integration/test_charm.py b/tests/integration/test_charm.py index 9781c4aabe..1ce8487c67 100644 --- a/tests/integration/test_charm.py +++ b/tests/integration/test_charm.py @@ -34,7 +34,6 @@ @pytest.mark.abort_on_fail -@pytest.mark.charm_tests @pytest.mark.parametrize("series", SERIES) @pytest.mark.skip_if_deployed async def test_deploy(ops_test: OpsTest, charm: str, series: str): @@ -61,7 +60,6 @@ async def test_deploy(ops_test: OpsTest, charm: str, series: str): @pytest.mark.abort_on_fail -@pytest.mark.charm_tests @pytest.mark.parametrize("series", SERIES) @pytest.mark.parametrize("unit_id", UNIT_IDS) async def test_database_is_up(ops_test: OpsTest, series: str, unit_id: int): @@ -75,7 +73,6 @@ async def test_database_is_up(ops_test: OpsTest, series: str, unit_id: int): assert result.status_code == 200 -@pytest.mark.charm_tests @pytest.mark.parametrize("series", SERIES) @pytest.mark.parametrize("unit_id", UNIT_IDS) async def test_settings_are_correct(ops_test: OpsTest, series: str, unit_id: int): @@ -139,7 +136,6 @@ async def test_settings_are_correct(ops_test: OpsTest, series: str, unit_id: int assert settings["maximum_lag_on_failover"] == 1048576 -@pytest.mark.charm_tests @pytest.mark.parametrize("series", SERIES) async def test_scale_down_and_up(ops_test: OpsTest, series: str): """Test data is replicated to new units after a scale up.""" @@ -225,7 +221,6 @@ async def test_scale_down_and_up(ops_test: OpsTest, series: str): await scale_application(ops_test, application_name, initial_scale) -@pytest.mark.charm_tests @pytest.mark.parametrize("series", SERIES) async def test_persist_data_through_primary_deletion(ops_test: OpsTest, series: str): """Test data persists through a primary deletion.""" diff --git a/tests/integration/test_db.py b/tests/integration/test_db.py index ab827cb1cd..89f960c17d 100644 --- a/tests/integration/test_db.py +++ b/tests/integration/test_db.py @@ -26,7 +26,6 @@ RELATION_NAME = "db" -@pytest.mark.db_relation_tests async def test_mailman3_core_db(ops_test: OpsTest, charm: str) -> None: """Deploy Mailman3 Core to test the 'db' relation.""" async with ops_test.fast_forward(): @@ -95,7 +94,6 @@ async def test_mailman3_core_db(ops_test: OpsTest, charm: str) -> None: assert domain_name not in [domain.mail_host for domain in client.domains] -@pytest.mark.db_relation_tests async def test_relation_data_is_updated_correctly_when_scaling(ops_test: OpsTest): """Test that relation data, like connection data, is updated correctly when scaling.""" # Retrieve the list of current database unit names. @@ -160,7 +158,6 @@ async def test_relation_data_is_updated_correctly_when_scaling(ops_test: OpsTest psycopg2.connect(primary_connection_string) -@pytest.mark.db_relation_tests async def test_nextcloud_db_blocked(ops_test: OpsTest, charm: str) -> None: async with ops_test.fast_forward(): # Deploy Nextcloud. @@ -198,7 +195,6 @@ async def test_nextcloud_db_blocked(ops_test: OpsTest, charm: str) -> None: await ops_test.model.remove_application("nextcloud", block_until_done=True) -@pytest.mark.db_relation_tests async def test_weebl_db(ops_test: OpsTest, charm: str) -> None: async with ops_test.fast_forward(): await ops_test.model.deploy( diff --git a/tests/integration/test_db_admin.py b/tests/integration/test_db_admin.py index 79a5c6849e..6096b0ca24 100644 --- a/tests/integration/test_db_admin.py +++ b/tests/integration/test_db_admin.py @@ -33,7 +33,6 @@ RELATION_NAME = "db-admin" -@pytest.mark.db_admin_relation_tests async def test_landscape_scalable_bundle_db(ops_test: OpsTest, charm: str) -> None: """Deploy Landscape Scalable Bundle to test the 'db-admin' relation.""" config = { diff --git a/tests/integration/test_password_rotation.py b/tests/integration/test_password_rotation.py index 0dd04ef0da..c3f55fc2e8 100644 --- a/tests/integration/test_password_rotation.py +++ b/tests/integration/test_password_rotation.py @@ -18,7 +18,6 @@ @pytest.mark.abort_on_fail -@pytest.mark.password_rotation_tests @pytest.mark.skip_if_deployed async def test_deploy_active(ops_test: OpsTest): """Build the charm and deploy it.""" @@ -31,7 +30,6 @@ async def test_deploy_active(ops_test: OpsTest): await ops_test.model.wait_for_idle(apps=[APP_NAME], status="active", timeout=1000) -@pytest.mark.password_rotation_tests async def test_password_rotation(ops_test: OpsTest): """Test password rotation action.""" # Get the initial passwords set for the system users. diff --git a/tests/integration/test_tls.py b/tests/integration/test_tls.py index 01eca6b0e3..ccb23f74a9 100644 --- a/tests/integration/test_tls.py +++ b/tests/integration/test_tls.py @@ -31,7 +31,6 @@ @pytest.mark.abort_on_fail -@pytest.mark.tls_tests @pytest.mark.skip_if_deployed async def test_deploy_active(ops_test: OpsTest): """Build the charm and deploy it.""" @@ -45,7 +44,6 @@ async def test_deploy_active(ops_test: OpsTest): # bundles don't wait between deploying charms. -@pytest.mark.tls_tests async def test_tls_enabled(ops_test: OpsTest) -> None: """Test that TLS is enabled when relating to the TLS Certificates Operator.""" async with ops_test.fast_forward(): @@ -146,7 +144,6 @@ async def test_tls_enabled(ops_test: OpsTest) -> None: not os.environ.get("RESTART_MACHINE_TEST"), reason="RESTART_MACHINE_TEST environment variable not set", ) -@pytest.mark.tls_tests async def test_restart_machine(ops_test: OpsTest) -> None: async with ops_test.fast_forward(): # Relate it to the PostgreSQL to enable TLS. diff --git a/tox.ini b/tox.ini index 373c18e28e..a749af1448 100644 --- a/tox.ini +++ b/tox.ini @@ -2,28 +2,28 @@ # See LICENSE file for licensing details. [tox] -skipsdist=True +no_package = True skip_missing_interpreters = True -envlist = lint, unit +env_list = lint, unit [vars] -src_path = {toxinidir}/src/ -tst_path = {toxinidir}/tests/ -;lib_path = {toxinidir}/lib/charms/operator_name_with_underscores -all_path = {[vars]src_path} {[vars]tst_path} +src_path = {tox_root}/src +tests_path = {tox_root}/tests +;lib_path = {tox_root}/lib/charms/operator_name_with_underscores +all_path = {[vars]src_path} {[vars]tests_path} [testenv] -setenv = - PYTHONPATH = {toxinidir}:{toxinidir}/lib:{[vars]src_path} +set_env = + PYTHONPATH = {tox_root}:{tox_root}/lib:{[vars]src_path} PYTHONBREAKPOINT=ipdb.set_trace PY_COLORS=1 -passenv = +pass_env = PYTHONPATH CHARM_BUILD_DIR MODEL_SETTINGS RESTART_MACHINE_TEST -[testenv:fmt] +[testenv:format] description = Apply coding style standards to code deps = black @@ -45,8 +45,8 @@ deps = isort codespell commands = - codespell {toxinidir}/*.yaml {toxinidir}/*.ini {toxinidir}/*.md \ - {toxinidir}/*.toml {toxinidir}/*.txt {toxinidir}/.github + codespell {tox_root}/*.yaml {tox_root}/*.ini {tox_root}/*.md \ + {tox_root}/*.toml {tox_root}/*.txt {tox_root}/.github # pflake8 wrapper supports config from pyproject.toml pflake8 {[vars]all_path} isort --check-only --diff {[vars]all_path} @@ -61,10 +61,10 @@ deps = pytest-asyncio coverage[toml] jinja2 - -r{toxinidir}/requirements.txt + -r {tox_root}/requirements.txt commands = coverage run --source={[vars]src_path} \ - -m pytest --ignore={[vars]tst_path}integration -v --tb native -s {posargs} + -m pytest -v --tb native -s {posargs} {[vars]tests_path}/unit coverage report coverage xml @@ -77,11 +77,11 @@ deps = mailmanclient pytest-operator psycopg2-binary - -r{toxinidir}/requirements.txt + -r {tox_root}/requirements.txt commands = # Download patroni resource to use in the charm deployment. sh -c 'stat patroni.tar.gz > /dev/null 2>&1 || curl "https://github.com/zalando/patroni/archive/refs/tags/v2.1.4.tar.gz" -L -s > patroni.tar.gz' - pytest -v --tb native --ignore={[vars]tst_path}unit --log-cli-level=INFO -s {posargs} -m charm_tests + pytest -v --tb native --log-cli-level=INFO -s {posargs} {[vars]tests_path}/integration/test_charm.py # Remove the downloaded resource. sh -c 'rm -f patroni.tar.gz' allowlist_externals = @@ -89,6 +89,10 @@ allowlist_externals = [testenv:database-relation-integration] description = Run database relation integration tests +pass_env = + {[testenv]pass_env} + CI + CI_PACKED_CHARMS deps = pytest juju~=2.9.0 # Latest juju 2 @@ -96,11 +100,11 @@ deps = mailmanclient pytest-operator psycopg2-binary - -r{toxinidir}/requirements.txt + -r {tox_root}/requirements.txt commands = # Download patroni resource to use in the charm deployment. sh -c 'stat patroni.tar.gz > /dev/null 2>&1 || curl "https://github.com/zalando/patroni/archive/refs/tags/v2.1.4.tar.gz" -L -s > patroni.tar.gz' - pytest -v --tb native --ignore={[vars]tst_path}unit --log-cli-level=INFO -s {posargs} -m database_relation_tests + pytest -v --tb native --log-cli-level=INFO -s {posargs} {[vars]tests_path}/integration/new_relations/test_new_relations.py # Remove the downloaded resource. sh -c 'rm -f patroni.tar.gz' allowlist_externals = @@ -108,6 +112,10 @@ allowlist_externals = [testenv:db-relation-integration] description = Run db relation integration tests +pass_env = + {[testenv]pass_env} + CI + CI_PACKED_CHARMS deps = pytest juju~=2.9.0 # Latest juju 2 @@ -115,11 +123,11 @@ deps = mailmanclient pytest-operator psycopg2-binary - -r{toxinidir}/requirements.txt + -r {tox_root}/requirements.txt commands = # Download patroni resource to use in the charm deployment. sh -c 'stat patroni.tar.gz > /dev/null 2>&1 || curl "https://github.com/zalando/patroni/archive/refs/tags/v2.1.4.tar.gz" -L -s > patroni.tar.gz' - pytest -v --tb native --ignore={[vars]tst_path}unit --log-cli-level=INFO -s {posargs} -m db_relation_tests + pytest -v --tb native --log-cli-level=INFO -s {posargs} {[vars]tests_path}/integration/test_db.py # Remove the downloaded resource. sh -c 'rm -f patroni.tar.gz' allowlist_externals = @@ -127,6 +135,10 @@ allowlist_externals = [testenv:db-admin-relation-integration] description = Run db-admin relation integration tests +pass_env = + {[testenv]pass_env} + CI + CI_PACKED_CHARMS deps = pytest juju~=2.9.0 # Latest juju 2 @@ -134,11 +146,11 @@ deps = mailmanclient pytest-operator psycopg2-binary - -r{toxinidir}/requirements.txt + -r {tox_root}/requirements.txt commands = # Download patroni resource to use in the charm deployment. sh -c 'stat patroni.tar.gz > /dev/null 2>&1 || curl "https://github.com/zalando/patroni/archive/refs/tags/v2.1.4.tar.gz" -L -s > patroni.tar.gz' - pytest -v --tb native --ignore={[vars]tst_path}unit --log-cli-level=INFO -s {posargs} -m db_admin_relation_tests + pytest -v --tb native --log-cli-level=INFO -s {posargs} {[vars]tests_path}/integration/test_db_admin.py # Remove the downloaded resource. sh -c 'rm -f patroni.tar.gz' allowlist_externals = @@ -146,6 +158,10 @@ allowlist_externals = [testenv:ha-self-healing-integration] description = Run high availability self healing integration tests +pass_env = + {[testenv]pass_env} + CI + CI_PACKED_CHARMS deps = pytest juju~=2.9.0 # Latest juju 2 @@ -153,11 +169,11 @@ deps = mailmanclient pytest-operator psycopg2-binary - -r{toxinidir}/requirements.txt + -r {tox_root}/requirements.txt commands = # Download patroni resource to use in the charm deployment. sh -c 'stat patroni.tar.gz > /dev/null 2>&1 || curl "https://github.com/zalando/patroni/archive/refs/tags/v2.1.4.tar.gz" -L -s > patroni.tar.gz' - pytest -v --tb native --ignore={[vars]tst_path}unit --log-cli-level=INFO -s {posargs} -m ha_self_healing_tests + pytest -v --tb native --log-cli-level=INFO -s {posargs} {[vars]tests_path}/integration/ha_tests/test_self_healing.py # Remove the downloaded resource. sh -c 'rm -f patroni.tar.gz' allowlist_externals = @@ -165,6 +181,10 @@ allowlist_externals = [testenv:password-rotation-integration] description = Run password rotation integration tests +pass_env = + {[testenv]pass_env} + CI + CI_PACKED_CHARMS deps = pytest juju~=2.9.0 # Latest juju 2 @@ -172,11 +192,11 @@ deps = mailmanclient pytest-operator psycopg2-binary - -r{toxinidir}/requirements.txt + -r {tox_root}/requirements.txt commands = # Download patroni resource to use in the charm deployment. sh -c 'stat patroni.tar.gz > /dev/null 2>&1 || curl "https://github.com/zalando/patroni/archive/refs/tags/v2.1.4.tar.gz" -L -s > patroni.tar.gz' - pytest -v --tb native --ignore={[vars]tst_path}unit --log-cli-level=INFO -s {posargs} -m password_rotation_tests + pytest -v --tb native --log-cli-level=INFO -s {posargs} {[vars]tests_path}/integration/test_password_rotation.py # Remove the downloaded resource. sh -c 'rm -f patroni.tar.gz' allowlist_externals = @@ -184,6 +204,10 @@ allowlist_externals = [testenv:tls-integration] description = Run TLS integration tests +pass_env = + {[testenv]pass_env} + CI + CI_PACKED_CHARMS deps = pytest juju~=2.9.0 # Latest juju 2 @@ -191,11 +215,11 @@ deps = mailmanclient pytest-operator psycopg2-binary - -r{toxinidir}/requirements.txt + -r {tox_root}/requirements.txt commands = # Download patroni resource to use in the charm deployment. sh -c 'stat patroni.tar.gz > /dev/null 2>&1 || curl "https://github.com/zalando/patroni/archive/refs/tags/v2.1.4.tar.gz" -L -s > patroni.tar.gz' - pytest -v --tb native --ignore={[vars]tst_path}unit --log-cli-level=INFO -s {posargs} -m tls_tests + pytest -v --tb native --log-cli-level=INFO -s {posargs} {[vars]tests_path}/integration/test_tls.py # Remove the downloaded resource. sh -c 'rm -f patroni.tar.gz' allowlist_externals = @@ -203,6 +227,10 @@ allowlist_externals = [testenv:integration] description = Run all integration tests +pass_env = + {[testenv]pass_env} + CI + CI_PACKED_CHARMS deps = pytest juju~=2.9.0 # Latest juju 2 @@ -210,11 +238,11 @@ deps = mailmanclient pytest-operator psycopg2-binary - -r{toxinidir}/requirements.txt + -r {tox_root}/requirements.txt commands = # Download patroni resource to use in the charm deployment. sh -c 'stat patroni.tar.gz > /dev/null 2>&1 || curl "https://github.com/zalando/patroni/archive/refs/tags/v2.1.4.tar.gz" -L -s > patroni.tar.gz' - pytest -v --tb native --ignore={[vars]tst_path}unit --log-cli-level=INFO -s {posargs} + pytest -v --tb native --log-cli-level=INFO -s {posargs} {[vars]tests_path}/integration/ # Remove the downloaded resource. sh -c 'rm -f patroni.tar.gz' allowlist_externals =