From 61bd2618d0fa59d5936b4838884dc0ea98a74b78 Mon Sep 17 00:00:00 2001 From: Tony Meyer Date: Thu, 12 Sep 2024 02:14:58 +1200 Subject: [PATCH 1/2] Remove patching of private ops class. (#617) --- tests/helpers.py | 20 ------------- tests/unit/test_backups.py | 8 ----- tests/unit/test_charm.py | 41 ++++---------------------- tests/unit/test_db.py | 10 ------- tests/unit/test_postgresql_provider.py | 5 ---- tests/unit/test_upgrade.py | 4 --- 6 files changed, 6 insertions(+), 82 deletions(-) diff --git a/tests/helpers.py b/tests/helpers.py index f1775b9652..029c42a446 100644 --- a/tests/helpers.py +++ b/tests/helpers.py @@ -3,28 +3,8 @@ from pathlib import Path -from typing import Callable -from unittest.mock import patch import yaml METADATA = yaml.safe_load(Path("./metadata.yaml").read_text()) STORAGE_PATH = METADATA["storage"]["pgdata"]["location"] - - -def patch_network_get(private_address="1.1.1.1") -> Callable: - def network_get(*args, **kwargs) -> dict: - """Patch for the not-yet-implemented testing backend needed for `bind_address`. - - This patch decorator can be used for cases such as: - self.model.get_binding(event.relation).network.bind_address - """ - return { - "bind-addresses": [ - { - "addresses": [{"value": private_address}], - } - ] - } - - return patch("ops.testing._TestingModelBackend.network_get", network_get) diff --git a/tests/unit/test_backups.py b/tests/unit/test_backups.py index fbca3c691b..c46a4e272d 100644 --- a/tests/unit/test_backups.py +++ b/tests/unit/test_backups.py @@ -18,7 +18,6 @@ from backups import ListBackupsError from charm import PostgresqlOperatorCharm from constants import PEER -from tests.helpers import patch_network_get ANOTHER_CLUSTER_REPOSITORY_ERROR_MESSAGE = "the S3 repository has backups from another cluster" FAILED_TO_ACCESS_CREATE_BUCKET_ERROR_MESSAGE = ( @@ -133,7 +132,6 @@ def test_can_initialise_stanza(harness): ) -@patch_network_get(private_address="1.1.1.1") def test_can_unit_perform_backup(harness): with ( patch("charm.PostgreSQLBackups._are_backup_settings_ok") as _are_backup_settings_ok, @@ -223,7 +221,6 @@ def test_can_unit_perform_backup(harness): ) -@patch_network_get(private_address="1.1.1.1") def test_can_use_s3_repository(harness): with ( patch("charm.Patroni.reload_patroni_configuration") as _reload_patroni_configuration, @@ -733,7 +730,6 @@ def test_list_backups(harness): ) -@patch_network_get(private_address="1.1.1.1") def test_initialise_stanza(harness): with ( patch("charm.Patroni.reload_patroni_configuration") as _reload_patroni_configuration, @@ -822,7 +818,6 @@ def test_initialise_stanza(harness): tc.assertIsInstance(harness.charm.unit.status, MaintenanceStatus) -@patch_network_get(private_address="1.1.1.1") def test_check_stanza(harness): with ( patch("charm.Patroni.reload_patroni_configuration") as _reload_patroni_configuration, @@ -1445,7 +1440,6 @@ def test_on_list_backups_action(harness): mock_event.fail.assert_not_called() -@patch_network_get(private_address="1.1.1.1") def test_on_restore_action(harness): with ( patch("charm.Patroni.start_patroni") as _start_patroni, @@ -1617,7 +1611,6 @@ def test_pre_restore_checks(harness): mock_event.fail.assert_not_called() -@patch_network_get(private_address="1.1.1.1") @pytest.mark.parametrize( "tls_ca_chain_filename", ["", "/var/snap/charmed-postgresql/common/pgbackrest-tls-ca-chain.crt"], @@ -1706,7 +1699,6 @@ def test_render_pgbackrest_conf_file(harness, tls_ca_chain_filename): _render_file.assert_has_calls(calls) -@patch_network_get(private_address="1.1.1.1") def test_restart_database(harness): with ( patch("charm.Patroni.start_patroni") as _start_patroni, diff --git a/tests/unit/test_charm.py b/tests/unit/test_charm.py index 761322d95a..80ec9f1975 100644 --- a/tests/unit/test_charm.py +++ b/tests/unit/test_charm.py @@ -38,7 +38,6 @@ ) from cluster import NotReadyError, RemoveRaftMemberFailedError from constants import PEER, POSTGRESQL_SNAP_NAME, SECRET_INTERNAL_LABEL, SNAP_PACKAGES -from tests.helpers import patch_network_get CREATE_CLUSTER_CONF_PATH = "/etc/postgresql-common/createcluster.d/pgcharm.conf" @@ -57,7 +56,6 @@ def harness(): harness.cleanup() -@patch_network_get(private_address="1.1.1.1") def test_on_install(harness): with patch("charm.subprocess.check_call") as _check_call, patch( "charm.snap.SnapCache" @@ -91,7 +89,6 @@ def test_on_install(harness): assert isinstance(harness.model.unit.status, WaitingStatus) -@patch_network_get(private_address="1.1.1.1") def test_on_install_failed_to_create_home(harness): with patch("charm.subprocess.check_call") as _check_call, patch( "charm.snap.SnapCache" @@ -123,7 +120,6 @@ def test_on_install_failed_to_create_home(harness): assert isinstance(harness.model.unit.status, WaitingStatus) -@patch_network_get(private_address="1.1.1.1") def test_on_install_snap_failure(harness): with patch( "charm.PostgresqlOperatorCharm._install_snap_packages" @@ -139,7 +135,6 @@ def test_on_install_snap_failure(harness): assert isinstance(harness.model.unit.status, BlockedStatus) -@patch_network_get(private_address="1.1.1.1") def test_patroni_scrape_config_no_tls(harness): result = harness.charm.patroni_scrape_config() @@ -147,13 +142,12 @@ def test_patroni_scrape_config_no_tls(harness): { "metrics_path": "/metrics", "scheme": "http", - "static_configs": [{"targets": ["1.1.1.1:8008"]}], + "static_configs": [{"targets": ["192.0.2.0:8008"]}], "tls_config": {"insecure_skip_verify": True}, }, ] -@patch_network_get(private_address="1.1.1.1") def test_patroni_scrape_config_tls(harness): with patch( "charm.PostgresqlOperatorCharm.is_tls_enabled", @@ -166,7 +160,7 @@ def test_patroni_scrape_config_tls(harness): { "metrics_path": "/metrics", "scheme": "https", - "static_configs": [{"targets": ["1.1.1.1:8008"]}], + "static_configs": [{"targets": ["192.0.2.0:8008"]}], "tls_config": {"insecure_skip_verify": True}, }, ] @@ -206,7 +200,6 @@ def test_primary_endpoint_no_peers(harness): assert not _patroni.return_value.get_primary.called -@patch_network_get(private_address="1.1.1.1") def test_on_leader_elected(harness): with patch( "charm.PostgresqlOperatorCharm._update_relation_endpoints", new_callable=PropertyMock @@ -570,7 +563,6 @@ def test_enable_disable_extensions(harness, caplog): assert isinstance(harness.charm.unit.status, ActiveStatus) -@patch_network_get(private_address="1.1.1.1") def test_on_start(harness): with ( patch( @@ -669,7 +661,6 @@ def test_on_start(harness): _restart_services_after_reboot.assert_called_once() -@patch_network_get(private_address="1.1.1.1") def test_on_start_replica(harness): with ( patch("charm.snap.SnapCache") as _snap_cache, @@ -734,7 +725,6 @@ def test_on_start_replica(harness): assert isinstance(harness.model.unit.status, WaitingStatus) -@patch_network_get(private_address="1.1.1.1") def test_on_start_no_patroni_member(harness): with ( patch("subprocess.check_output", return_value=b"C"), @@ -785,7 +775,6 @@ def test_on_start_after_blocked_state(harness): assert harness.model.unit.status == initial_status -@patch_network_get(private_address="1.1.1.1") def test_on_get_password(harness): with patch("charm.PostgresqlOperatorCharm.update_config"): rel_id = harness.model.get_relation(PEER).id @@ -820,7 +809,6 @@ def test_on_get_password(harness): mock_event.set_results.assert_called_once_with({"password": "replication-test-password"}) -@patch_network_get(private_address="1.1.1.1") def test_on_set_password(harness): with ( patch("charm.PostgresqlOperatorCharm.update_config"), @@ -883,7 +871,6 @@ def test_on_set_password(harness): ) -@patch_network_get(private_address="1.1.1.1") def test_on_update_status(harness): with ( patch("charm.ClusterTopologyObserver.start_observer") as _start_observer, @@ -992,7 +979,6 @@ def test_on_update_status(harness): _start_observer.assert_called_once() -@patch_network_get(private_address="1.1.1.1") def test_on_update_status_after_restore_operation(harness): with ( patch("charm.ClusterTopologyObserver.start_observer"), @@ -1218,7 +1204,6 @@ def test_reboot_on_detached_storage(harness): _check_call.assert_called_once_with(["systemctl", "reboot"]) -@patch_network_get(private_address="1.1.1.1") def test_restart(harness): with ( patch("charm.Patroni.restart_postgresql") as _restart_postgresql, @@ -1246,7 +1231,6 @@ def test_restart(harness): mock_event.defer.assert_not_called() -@patch_network_get(private_address="1.1.1.1") def test_update_config(harness): with ( patch("subprocess.check_output", return_value=b"C"), @@ -1457,7 +1441,6 @@ def test_validate_config_options(harness): assert str(e.value).startswith(message) -@patch_network_get(private_address="1.1.1.1") def test_on_peer_relation_changed(harness): with ( patch("charm.snap.SnapCache"), @@ -1501,7 +1484,7 @@ def test_on_peer_relation_changed(harness): harness.update_relation_data( rel_id, harness.charm.app.name, - {"cluster_initialised": "True", "members_ips": '["1.1.1.1"]'}, + {"cluster_initialised": "True", "members_ips": '["192.0.2.0"]'}, ) harness.set_leader() _reconfigure_cluster.return_value = False @@ -1515,7 +1498,7 @@ def test_on_peer_relation_changed(harness): _reconfigure_cluster.return_value = True _update_member_ip.return_value = False _member_started.return_value = True - _primary_endpoint.return_value = "1.1.1.1" + _primary_endpoint.return_value = "192.0.2.0" harness.model.unit.status = WaitingStatus("awaiting for cluster to start") harness.charm._on_peer_relation_changed(mock_event) mock_event.defer.assert_not_called() @@ -1600,7 +1583,6 @@ def test_on_peer_relation_changed(harness): _check_stanza.assert_called_once() -@patch_network_get(private_address="1.1.1.1") def test_reconfigure_cluster(harness): with ( patch("charm.PostgresqlOperatorCharm._add_members") as _add_members, @@ -1684,7 +1666,6 @@ def test_update_certificate(harness): assert harness.charm.get_secret("unit", "private-key") == private_key -@patch_network_get(private_address="1.1.1.1") def test_update_member_ip(harness): with ( patch("charm.PostgresqlOperatorCharm._update_certificate") as _update_certificate, @@ -1697,7 +1678,7 @@ def test_update_member_ip(harness): rel_id, harness.charm.unit.name, { - "ip": "1.1.1.1", + "ip": "192.0.2.0", }, ) assert not (harness.charm._update_member_ip()) @@ -1717,13 +1698,12 @@ def test_update_member_ip(harness): ) assert harness.charm._update_member_ip() relation_data = harness.get_relation_data(rel_id, harness.charm.unit.name) - assert relation_data.get("ip") == "1.1.1.1" + assert relation_data.get("ip") == "192.0.2.0" assert relation_data.get("ip-to-remove") == "2.2.2.2" _stop_patroni.assert_called_once() _update_certificate.assert_called_once() -@patch_network_get(private_address="1.1.1.1") def test_push_tls_files_to_workload(harness): with ( patch("charm.PostgresqlOperatorCharm.update_config") as _update_config, @@ -1874,7 +1854,6 @@ def test_scope_obj(harness): assert harness.charm._scope_obj("test") is None -@patch_network_get(private_address="1.1.1.1") def test_get_secret_from_databag(harness): """Asserts that get_secret method can read secrets from databag. @@ -1901,7 +1880,6 @@ def test_get_secret_from_databag(harness): assert harness.charm.get_secret("unit", "operator_password") == "test-password" -@patch_network_get(private_address="1.1.1.1") def test_on_get_password_secrets(harness): with ( patch("charm.PostgresqlOperatorCharm._on_leader_elected"), @@ -1932,7 +1910,6 @@ def test_on_get_password_secrets(harness): @pytest.mark.parametrize("scope,field", [("app", "operator-password"), ("unit", "csr")]) -@patch_network_get(private_address="1.1.1.1") def test_get_secret_secrets(harness, scope, field): with ( patch("charm.PostgresqlOperatorCharm._on_leader_elected"), @@ -1944,7 +1921,6 @@ def test_get_secret_secrets(harness, scope, field): assert harness.charm.get_secret(scope, field) == "test" -@patch_network_get(private_address="1.1.1.1") def test_set_secret_in_databag(harness, only_without_juju_secrets): """Asserts that set_secret method writes to relation databag. @@ -1979,7 +1955,6 @@ def test_set_secret_in_databag(harness, only_without_juju_secrets): @pytest.mark.parametrize("scope,is_leader", [("app", True), ("unit", True), ("unit", False)]) -@patch_network_get(private_address="1.1.1.1") def test_set_reset_new_secret(harness, scope, is_leader): with ( patch("charm.PostgresqlOperatorCharm._on_leader_elected"), @@ -2001,7 +1976,6 @@ def test_set_reset_new_secret(harness, scope, is_leader): @pytest.mark.parametrize("scope,is_leader", [("app", True), ("unit", True), ("unit", False)]) -@patch_network_get(private_address="1.1.1.1") def test_invalid_secret(harness, scope, is_leader): with ( patch("charm.PostgresqlOperatorCharm._on_leader_elected"), @@ -2016,7 +1990,6 @@ def test_invalid_secret(harness, scope, is_leader): assert harness.charm.get_secret(scope, "somekey") is None -@patch_network_get(private_address="1.1.1.1") def test_delete_password(harness, _has_secrets, caplog): with ( patch("charm.PostgresqlOperatorCharm._on_leader_elected"), @@ -2063,7 +2036,6 @@ def test_delete_password(harness, _has_secrets, caplog): @pytest.mark.parametrize("scope,is_leader", [("app", True), ("unit", True), ("unit", False)]) -@patch_network_get(private_address="1.1.1.1") def test_migration_from_databag(harness, only_with_juju_secrets, scope, is_leader): """Check if we're moving on to use secrets when live upgrade from databag to Secrets usage. @@ -2091,7 +2063,6 @@ def test_migration_from_databag(harness, only_with_juju_secrets, scope, is_leade @pytest.mark.parametrize("scope,is_leader", [("app", True), ("unit", True), ("unit", False)]) -@patch_network_get(private_address="1.1.1.1") def test_migration_from_single_secret(harness, only_with_juju_secrets, scope, is_leader): """Check if we're moving on to use secrets when live upgrade from databag to Secrets usage. diff --git a/tests/unit/test_db.py b/tests/unit/test_db.py index 9c29f47d3b..28f5e946c8 100644 --- a/tests/unit/test_db.py +++ b/tests/unit/test_db.py @@ -15,7 +15,6 @@ from charm import PostgresqlOperatorCharm from constants import DATABASE_PORT, PEER -from tests.helpers import patch_network_get DATABASE = "test_database" RELATION_NAME = "db" @@ -81,7 +80,6 @@ def request_database(_harness): ) -@patch_network_get(private_address="1.1.1.1") def test_on_relation_changed(harness): with ( patch("charm.DbProvides.set_up_relation") as _set_up_relation, @@ -127,7 +125,6 @@ def test_on_relation_changed(harness): _set_up_relation.assert_called_once() -@patch_network_get(private_address="1.1.1.1") def test_get_extensions(harness): # Test when there are no extensions in the relation databags. rel_id = harness.model.get_relation(RELATION_NAME).id @@ -181,7 +178,6 @@ def test_get_extensions(harness): ) -@patch_network_get(private_address="1.1.1.1") def test_set_up_relation(harness): with ( patch.object(PostgresqlOperatorCharm, "postgresql", Mock()) as postgresql_mock, @@ -305,7 +301,6 @@ def test_set_up_relation(harness): assert isinstance(harness.model.unit.status, BlockedStatus) -@patch_network_get(private_address="1.1.1.1") def test_update_unit_status(harness): with ( patch( @@ -347,7 +342,6 @@ def test_update_unit_status(harness): assert isinstance(harness.charm.unit.status, ActiveStatus) -@patch_network_get(private_address="1.1.1.1") def test_on_relation_broken_extensions_unblock(harness): with ( patch.object(PostgresqlOperatorCharm, "postgresql", Mock()) as postgresql_mock, @@ -380,7 +374,6 @@ def test_on_relation_broken_extensions_unblock(harness): assert isinstance(harness.model.unit.status, ActiveStatus) -@patch_network_get(private_address="1.1.1.1") def test_on_relation_broken_extensions_keep_block(harness): with ( patch.object(PostgresqlOperatorCharm, "postgresql", Mock()) as postgresql_mock, @@ -421,7 +414,6 @@ def test_on_relation_broken_extensions_keep_block(harness): assert isinstance(harness.model.unit.status, BlockedStatus) -@patch_network_get(private_address="1.1.1.1") def test_update_endpoints_with_relation(harness): with ( patch.object(PostgresqlOperatorCharm, "postgresql", Mock()) as postgresql_mock, @@ -541,7 +533,6 @@ def test_update_endpoints_with_relation(harness): ) -@patch_network_get(private_address="1.1.1.1") def test_update_endpoints_without_relation(harness): with ( patch.object(PostgresqlOperatorCharm, "postgresql", Mock()) as postgresql_mock, @@ -631,7 +622,6 @@ def test_update_endpoints_without_relation(harness): ) -@patch_network_get(private_address="1.1.1.1") def test_get_allowed_units(harness): # No allowed units from the current database application. peer_rel_id = harness.model.get_relation(PEER).id diff --git a/tests/unit/test_postgresql_provider.py b/tests/unit/test_postgresql_provider.py index e79cd4b20f..2ccb8a0d30 100644 --- a/tests/unit/test_postgresql_provider.py +++ b/tests/unit/test_postgresql_provider.py @@ -16,7 +16,6 @@ from charm import PostgresqlOperatorCharm from constants import PEER -from tests.helpers import patch_network_get DATABASE = "test_database" EXTRA_USER_ROLES = "CREATEDB,CREATEROLE" @@ -73,7 +72,6 @@ def request_database(_harness): ) -@patch_network_get(private_address="1.1.1.1") def test_on_database_requested(harness): with ( patch.object(PostgresqlOperatorCharm, "postgresql", Mock()) as postgresql_mock, @@ -170,7 +168,6 @@ def test_on_database_requested(harness): assert isinstance(harness.model.unit.status, BlockedStatus) -@patch_network_get(private_address="1.1.1.1") def test_oversee_users(harness): with patch.object(PostgresqlOperatorCharm, "postgresql", Mock()) as postgresql_mock: # Create two relations and add the username in their databags. @@ -210,7 +207,6 @@ def test_oversee_users(harness): postgresql_mock.delete_user.assert_called_once() # Only the previous call. -@patch_network_get(private_address="1.1.1.1") def test_update_endpoints_with_event(harness): with ( patch( @@ -270,7 +266,6 @@ def test_update_endpoints_with_event(harness): assert harness.get_relation_data(another_rel_id, harness.charm.app.name) == {} -@patch_network_get(private_address="1.1.1.1") def test_update_endpoints_without_event(harness): with ( patch( diff --git a/tests/unit/test_upgrade.py b/tests/unit/test_upgrade.py index 575fd1ee2c..7dfbfc521b 100644 --- a/tests/unit/test_upgrade.py +++ b/tests/unit/test_upgrade.py @@ -9,7 +9,6 @@ from charm import PostgresqlOperatorCharm from constants import SNAP_PACKAGES -from tests.helpers import patch_network_get @pytest.fixture(autouse=True) @@ -27,7 +26,6 @@ def harness(): harness.cleanup() -@patch_network_get(private_address="1.1.1.1") def test_build_upgrade_stack(harness): with ( patch("charm.Patroni.get_sync_standby_names") as _get_sync_standby_names, @@ -91,7 +89,6 @@ def test_on_upgrade_charm_check_legacy(harness, unit_states, is_cluster_initiali _member_started.assert_called_once() if call else _member_started.assert_not_called() -@patch_network_get(private_address="1.1.1.1") def test_on_upgrade_granted(harness): with ( patch("charm.Patroni.get_postgresql_version"), @@ -189,7 +186,6 @@ def test_on_upgrade_granted(harness): _on_upgrade_changed.assert_called_once() -@patch_network_get(private_address="1.1.1.1") def test_pre_upgrade_check(harness): with ( patch( From 01cfd3e268ecd5024ded6bb6aede43ff85417b78 Mon Sep 17 00:00:00 2001 From: shayancanonical <99665202+shayancanonical@users.noreply.github.com> Date: Wed, 11 Sep 2024 12:07:20 -0400 Subject: [PATCH 2/2] [DPE-4977] Run tests against juju 3.6 on a nightly schedule (#601) * Ensure that integration tests pass on juju 3.6 and amd64 * Correctly comment pull_request CI + always run integration tests against latest lxd version * Use juju-snap-channel instead of juju-agent-version * Update pylibjuju to 3.5.2.0 * Revert libjuju to 3.5.0.0 * Explicity specify base as ubuntu@22.04 instead of using series=jammy * Use libjuju 3.5.0.0 in juju 3.6 workflow * Only run juju 3.6 tests on nightly schedule * Add juju snap channel to the integration CI name --- .github/workflows/ci.yaml | 10 ++++++++-- poetry.lock | 2 +- pyproject.toml | 2 +- tests/integration/ha_tests/test_replication.py | 8 ++++---- .../ha_tests/test_restore_cluster.py | 6 +++--- .../integration/ha_tests/test_self_healing.py | 6 +++--- tests/integration/ha_tests/test_smoke.py | 8 ++++---- tests/integration/helpers.py | 4 ++-- .../new_relations/test_new_relations.py | 18 +++++++++++------- .../new_relations/test_relations_coherence.py | 6 +++--- tests/integration/relations/test_relations.py | 8 ++++---- tests/integration/test_backups.py | 8 +++++--- tests/integration/test_backups_pitr.py | 4 ++-- tests/integration/test_charm.py | 4 ++-- tests/integration/test_config.py | 4 ++-- tests/integration/test_db.py | 10 +++++----- tests/integration/test_db_admin.py | 4 ++-- tests/integration/test_password_rotation.py | 4 ++-- tests/integration/test_plugins.py | 4 ++-- tests/integration/test_subordinates.py | 6 ++++-- tests/integration/test_tls.py | 6 +++--- 21 files changed, 73 insertions(+), 59 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index c77a114ec3..06e16cd672 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -59,6 +59,8 @@ jobs: allure_on_amd64: false - agent: 3.4.5 # renovate: juju-agent-pin-minor allure_on_amd64: true + - snap_channel: 3.6/beta + allure_on_amd64: false architecture: - amd64 include: @@ -66,7 +68,11 @@ jobs: agent: 3.4.5 # renovate: juju-agent-pin-minor allure_on_amd64: true architecture: arm64 - name: Integration | ${{ matrix.juju.agent }} | ${{ matrix.architecture }} + - juju: + snap_channel: 3.6/beta + allure_on_amd64: false + architecture: arm64 + name: Integration | ${{ matrix.juju.agent || matrix.juju.snap_channel }} | ${{ matrix.architecture }} needs: - lint - unit-test @@ -76,8 +82,8 @@ jobs: artifact-prefix: ${{ needs.build.outputs.artifact-prefix }} architecture: ${{ matrix.architecture }} cloud: lxd - lxd-snap-channel: 5.21/stable juju-agent-version: ${{ matrix.juju.agent }} + juju-snap-channel: ${{ matrix.juju.snap_channel }} libjuju-version-constraint: ${{ matrix.juju.libjuju }} _beta_allure_report: ${{ matrix.juju.allure_on_amd64 && matrix.architecture == 'amd64' }} secrets: diff --git a/poetry.lock b/poetry.lock index 284064c709..3a394583cc 100644 --- a/poetry.lock +++ b/poetry.lock @@ -2520,4 +2520,4 @@ type = ["pytest-mypy"] [metadata] lock-version = "2.0" python-versions = "^3.10" -content-hash = "c6167147c89eb390254d9374a2675f93d104a70d8741317d621cc55bc6670722" +content-hash = "c5f0cebf18af4d4190ff720a1d4b3dfa7678cc05af442b45211d259ab6339c91" diff --git a/pyproject.toml b/pyproject.toml index 1e7bf20b89..fe840e1761 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -66,7 +66,7 @@ pytest-operator = "^0.36.0" pytest-operator-cache = {git = "https://github.com/canonical/data-platform-workflows", tag = "v21.0.1", subdirectory = "python/pytest_plugins/pytest_operator_cache"} pytest-operator-groups = {git = "https://github.com/canonical/data-platform-workflows", tag = "v21.0.1", subdirectory = "python/pytest_plugins/pytest_operator_groups"} # renovate caret doesn't work: https://github.com/renovatebot/renovate/issues/26940 -juju = "<=3.5.0.0" +juju = "3.5.0.0" boto3 = "*" tenacity = "*" landscape-api-py3 = "^0.9.0" diff --git a/tests/integration/ha_tests/test_replication.py b/tests/integration/ha_tests/test_replication.py index 600e2997d4..23fc30f08d 100644 --- a/tests/integration/ha_tests/test_replication.py +++ b/tests/integration/ha_tests/test_replication.py @@ -6,7 +6,7 @@ from pytest_operator.plugin import OpsTest from tenacity import Retrying, stop_after_delay, wait_fixed -from ..helpers import APPLICATION_NAME, CHARM_SERIES, db_connect, scale_application +from ..helpers import APPLICATION_NAME, CHARM_BASE, db_connect, scale_application from .helpers import ( app_name, are_writes_increasing, @@ -32,7 +32,7 @@ async def test_build_and_deploy(ops_test: OpsTest) -> None: await ops_test.model.deploy( charm, num_units=3, - series=CHARM_SERIES, + base=CHARM_BASE, config={"profile": "testing"}, ) # Deploy the continuous writes application charm if it wasn't already deployed. @@ -42,7 +42,7 @@ async def test_build_and_deploy(ops_test: OpsTest) -> None: await ops_test.model.deploy( APPLICATION_NAME, application_name=APPLICATION_NAME, - series=CHARM_SERIES, + base=CHARM_BASE, channel="edge", ) @@ -122,7 +122,7 @@ async def test_no_data_replicated_between_clusters(ops_test: OpsTest, continuous charm, application_name=new_cluster_app, num_units=2, - series=CHARM_SERIES, + base=CHARM_BASE, config={"profile": "testing"}, ) await ops_test.model.wait_for_idle( diff --git a/tests/integration/ha_tests/test_restore_cluster.py b/tests/integration/ha_tests/test_restore_cluster.py index d6af07e251..0d4c3f9f49 100644 --- a/tests/integration/ha_tests/test_restore_cluster.py +++ b/tests/integration/ha_tests/test_restore_cluster.py @@ -7,7 +7,7 @@ from pytest_operator.plugin import OpsTest from ..helpers import ( - CHARM_SERIES, + CHARM_BASE, db_connect, get_password, get_patroni_cluster, @@ -41,7 +41,7 @@ async def test_build_and_deploy(ops_test: OpsTest) -> None: charm, application_name=FIRST_APPLICATION, num_units=3, - series=CHARM_SERIES, + base=CHARM_BASE, storage={"pgdata": {"pool": "lxd-btrfs", "size": 2048}}, config={"profile": "testing"}, ) @@ -51,7 +51,7 @@ async def test_build_and_deploy(ops_test: OpsTest) -> None: charm, application_name=SECOND_APPLICATION, num_units=1, - series=CHARM_SERIES, + base=CHARM_BASE, config={"profile": "testing"}, ) diff --git a/tests/integration/ha_tests/test_self_healing.py b/tests/integration/ha_tests/test_self_healing.py index 0b37df9ff1..b68ba3dd4e 100644 --- a/tests/integration/ha_tests/test_self_healing.py +++ b/tests/integration/ha_tests/test_self_healing.py @@ -10,7 +10,7 @@ from tenacity import Retrying, stop_after_delay, wait_fixed from ..helpers import ( - CHARM_SERIES, + CHARM_BASE, db_connect, get_machine_from_unit, get_password, @@ -76,7 +76,7 @@ async def test_build_and_deploy(ops_test: OpsTest) -> None: await ops_test.model.deploy( charm, num_units=3, - series=CHARM_SERIES, + base=CHARM_BASE, storage={"pgdata": {"pool": "lxd-btrfs", "size": 2048}}, config={"profile": "testing"}, ) @@ -87,7 +87,7 @@ async def test_build_and_deploy(ops_test: OpsTest) -> None: await ops_test.model.deploy( APPLICATION_NAME, application_name=APPLICATION_NAME, - series=CHARM_SERIES, + base=CHARM_BASE, channel="edge", ) diff --git a/tests/integration/ha_tests/test_smoke.py b/tests/integration/ha_tests/test_smoke.py index 8da83ce3eb..2c954ee466 100644 --- a/tests/integration/ha_tests/test_smoke.py +++ b/tests/integration/ha_tests/test_smoke.py @@ -12,7 +12,7 @@ from ..helpers import ( APPLICATION_NAME, - CHARM_SERIES, + CHARM_BASE, ) from ..juju_ import juju_major_version from .helpers import ( @@ -44,7 +44,7 @@ async def test_app_force_removal(ops_test: OpsTest, charm: str): charm, application_name=APPLICATION_NAME, num_units=1, - series=CHARM_SERIES, + base=CHARM_BASE, storage={"pgdata": {"pool": "lxd-btrfs", "size": 8046}}, config={"profile": "testing"}, ) @@ -150,7 +150,7 @@ async def test_app_resources_conflicts_v3(ops_test: OpsTest, charm: str): charm, application_name=DUP_APPLICATION_NAME, num_units=1, - series=CHARM_SERIES, + base=CHARM_BASE, attach_storage=[tag.storage(garbage_storage)], config={"profile": "testing"}, ) @@ -191,7 +191,7 @@ async def test_app_resources_conflicts_v2(ops_test: OpsTest, charm: str): charm, application_name=DUP_APPLICATION_NAME, num_units=1, - series=CHARM_SERIES, + base=CHARM_BASE, config={"profile": "testing"}, ) diff --git a/tests/integration/helpers.py b/tests/integration/helpers.py index f6e81dd38f..904b3452f6 100644 --- a/tests/integration/helpers.py +++ b/tests/integration/helpers.py @@ -31,7 +31,7 @@ wait_fixed, ) -CHARM_SERIES = "jammy" +CHARM_BASE = "ubuntu@22.04" METADATA = yaml.safe_load(Path("./metadata.yaml").read_text()) DATABASE_APP_NAME = METADATA["name"] STORAGE_PATH = METADATA["storage"]["pgdata"]["location"] @@ -1118,7 +1118,7 @@ async def backup_operations( charm, application_name=database_app_name, num_units=2, - series=CHARM_SERIES, + base=CHARM_BASE, config={"profile": "testing"}, ) diff --git a/tests/integration/new_relations/test_new_relations.py b/tests/integration/new_relations/test_new_relations.py index 8b5457cc66..6ce4f14700 100644 --- a/tests/integration/new_relations/test_new_relations.py +++ b/tests/integration/new_relations/test_new_relations.py @@ -13,7 +13,7 @@ from pytest_operator.plugin import OpsTest from .. import markers -from ..helpers import CHARM_SERIES, assert_sync_standbys, get_leader_unit, scale_application +from ..helpers import CHARM_BASE, assert_sync_standbys, get_leader_unit, scale_application from ..juju_ import juju_major_version from .helpers import ( build_connection_string, @@ -49,21 +49,21 @@ async def test_deploy_charms(ops_test: OpsTest, charm): APPLICATION_APP_NAME, application_name=APPLICATION_APP_NAME, num_units=2, - series=CHARM_SERIES, + base=CHARM_BASE, channel="edge", ), ops_test.model.deploy( charm, application_name=DATABASE_APP_NAME, num_units=1, - series=CHARM_SERIES, + base=CHARM_BASE, config={"profile": "testing"}, ), ops_test.model.deploy( charm, application_name=ANOTHER_DATABASE_APP_NAME, num_units=2, - series=CHARM_SERIES, + base=CHARM_BASE, config={"profile": "testing"}, ), ) @@ -218,6 +218,7 @@ async def test_two_applications_doesnt_share_the_same_relation_data(ops_test: Op APPLICATION_APP_NAME, application_name=another_application_app_name, channel="edge", + base=CHARM_BASE, ) await ops_test.model.wait_for_idle(apps=all_app_names, status="active") @@ -446,7 +447,7 @@ async def test_admin_role(ops_test: OpsTest): all_app_names = [DATA_INTEGRATOR_APP_NAME] all_app_names.extend(APP_NAMES) async with ops_test.fast_forward(): - await ops_test.model.deploy(DATA_INTEGRATOR_APP_NAME) + await ops_test.model.deploy(DATA_INTEGRATOR_APP_NAME, base=CHARM_BASE) await ops_test.model.wait_for_idle(apps=[DATA_INTEGRATOR_APP_NAME], status="blocked") await ops_test.model.applications[DATA_INTEGRATOR_APP_NAME].set_config({ "database-name": DATA_INTEGRATOR_APP_NAME.replace("-", "_"), @@ -535,7 +536,9 @@ async def test_invalid_extra_user_roles(ops_test: OpsTest): another_data_integrator_app_name = f"another-{DATA_INTEGRATOR_APP_NAME}" data_integrator_apps_names = [DATA_INTEGRATOR_APP_NAME, another_data_integrator_app_name] await ops_test.model.deploy( - DATA_INTEGRATOR_APP_NAME, application_name=another_data_integrator_app_name + DATA_INTEGRATOR_APP_NAME, + application_name=another_data_integrator_app_name, + base=CHARM_BASE, ) await ops_test.model.wait_for_idle( apps=[another_data_integrator_app_name], status="blocked" @@ -592,7 +595,7 @@ async def test_nextcloud_db_blocked(ops_test: OpsTest, charm: str) -> None: charm, application_name=DATABASE_APP_NAME, num_units=1, - series=CHARM_SERIES, + base=CHARM_BASE, config={"profile": "testing"}, ), ops_test.model.deploy( @@ -600,6 +603,7 @@ async def test_nextcloud_db_blocked(ops_test: OpsTest, charm: str) -> None: channel="edge", application_name="nextcloud", num_units=1, + base=CHARM_BASE, ), ) await asyncio.gather( diff --git a/tests/integration/new_relations/test_relations_coherence.py b/tests/integration/new_relations/test_relations_coherence.py index 4955fe5d2b..3e2f1c2c8b 100644 --- a/tests/integration/new_relations/test_relations_coherence.py +++ b/tests/integration/new_relations/test_relations_coherence.py @@ -9,7 +9,7 @@ import pytest from pytest_operator.plugin import OpsTest -from ..helpers import CHARM_SERIES, DATABASE_APP_NAME +from ..helpers import CHARM_BASE, DATABASE_APP_NAME from .helpers import build_connection_string from .test_new_relations import DATA_INTEGRATOR_APP_NAME @@ -29,13 +29,13 @@ async def test_relations(ops_test: OpsTest, charm): charm, application_name=DATABASE_APP_NAME, num_units=1, - series=CHARM_SERIES, + base=CHARM_BASE, config={"profile": "testing"}, ) await ops_test.model.wait_for_idle(apps=[DATABASE_APP_NAME], status="active", timeout=3000) # Creating first time relation with user role - await ops_test.model.deploy(DATA_INTEGRATOR_APP_NAME) + await ops_test.model.deploy(DATA_INTEGRATOR_APP_NAME, base=CHARM_BASE) await ops_test.model.applications[DATA_INTEGRATOR_APP_NAME].set_config({ "database-name": DATA_INTEGRATOR_APP_NAME.replace("-", "_"), }) diff --git a/tests/integration/relations/test_relations.py b/tests/integration/relations/test_relations.py index a901856f6c..2a6522e114 100644 --- a/tests/integration/relations/test_relations.py +++ b/tests/integration/relations/test_relations.py @@ -9,7 +9,7 @@ from pytest_operator.plugin import OpsTest from tenacity import Retrying, stop_after_delay, wait_fixed -from ..helpers import CHARM_SERIES, METADATA +from ..helpers import CHARM_BASE, METADATA from ..new_relations.test_new_relations import APPLICATION_APP_NAME, build_connection_string from ..relations.helpers import get_legacy_db_connection_str @@ -37,14 +37,14 @@ async def test_deploy_charms(ops_test: OpsTest, charm): APPLICATION_APP_NAME, application_name=DATABASE_APP_NAME, num_units=1, - series=CHARM_SERIES, + base=CHARM_BASE, channel="edge", ), ops_test.model.deploy( charm, application_name=APP_NAME, num_units=1, - series=CHARM_SERIES, + base=CHARM_BASE, config={ "profile": "testing", "plugin_unaccent_enable": "True", @@ -55,7 +55,7 @@ async def test_deploy_charms(ops_test: OpsTest, charm): APPLICATION_APP_NAME, application_name=DB_APP_NAME, num_units=1, - series=CHARM_SERIES, + base=CHARM_BASE, channel="edge", ), ) diff --git a/tests/integration/test_backups.py b/tests/integration/test_backups.py index 6a83b981e5..70137b4f37 100644 --- a/tests/integration/test_backups.py +++ b/tests/integration/test_backups.py @@ -12,7 +12,7 @@ from . import architecture from .helpers import ( - CHARM_SERIES, + CHARM_BASE, DATABASE_APP_NAME, MOVE_RESTORED_CLUSTER_TO_ANOTHER_BUCKET, backup_operations, @@ -220,11 +220,13 @@ async def test_restore_on_new_cluster(ops_test: OpsTest, github_secrets, charm) """Test that is possible to restore a backup to another PostgreSQL cluster.""" previous_database_app_name = f"{DATABASE_APP_NAME}-gcp" database_app_name = f"new-{DATABASE_APP_NAME}" - await ops_test.model.deploy(charm, application_name=previous_database_app_name) + await ops_test.model.deploy( + charm, application_name=previous_database_app_name, base=CHARM_BASE + ) await ops_test.model.deploy( charm, application_name=database_app_name, - series=CHARM_SERIES, + base=CHARM_BASE, ) await ops_test.model.relate(previous_database_app_name, S3_INTEGRATOR_APP_NAME) await ops_test.model.relate(database_app_name, S3_INTEGRATOR_APP_NAME) diff --git a/tests/integration/test_backups_pitr.py b/tests/integration/test_backups_pitr.py index 5b5d22dfb4..500ac5fd7d 100644 --- a/tests/integration/test_backups_pitr.py +++ b/tests/integration/test_backups_pitr.py @@ -12,7 +12,7 @@ from . import architecture from .helpers import ( - CHARM_SERIES, + CHARM_BASE, DATABASE_APP_NAME, MOVE_RESTORED_CLUSTER_TO_ANOTHER_BUCKET, construct_endpoint, @@ -114,7 +114,7 @@ async def pitr_backup_operations( charm, application_name=database_app_name, num_units=2, - series=CHARM_SERIES, + base=CHARM_BASE, config={"profile": "testing"}, ) diff --git a/tests/integration/test_charm.py b/tests/integration/test_charm.py index f0769be5f5..a4093894cd 100644 --- a/tests/integration/test_charm.py +++ b/tests/integration/test_charm.py @@ -16,7 +16,7 @@ from locales import SNAP_LOCALES from .helpers import ( - CHARM_SERIES, + CHARM_BASE, DATABASE_APP_NAME, STORAGE_PATH, check_cluster_members, @@ -49,7 +49,7 @@ async def test_deploy(ops_test: OpsTest, charm: str): charm, application_name=DATABASE_APP_NAME, num_units=3, - series=CHARM_SERIES, + base=CHARM_BASE, config={"profile": "testing"}, ) diff --git a/tests/integration/test_config.py b/tests/integration/test_config.py index 25878e8253..e16a3d3d58 100644 --- a/tests/integration/test_config.py +++ b/tests/integration/test_config.py @@ -7,7 +7,7 @@ from pytest_operator.plugin import OpsTest from .helpers import ( - CHARM_SERIES, + CHARM_BASE, DATABASE_APP_NAME, get_leader_unit, ) @@ -25,7 +25,7 @@ async def test_config_parameters(ops_test: OpsTest) -> None: await ops_test.model.deploy( charm, num_units=1, - series=CHARM_SERIES, + base=CHARM_BASE, config={"profile": "testing"}, ) await ops_test.model.wait_for_idle(apps=[DATABASE_APP_NAME], status="active", timeout=1500) diff --git a/tests/integration/test_db.py b/tests/integration/test_db.py index 68b429ec57..822deb78a7 100644 --- a/tests/integration/test_db.py +++ b/tests/integration/test_db.py @@ -13,7 +13,7 @@ from . import markers from .helpers import ( APPLICATION_NAME, - CHARM_SERIES, + CHARM_BASE, DATABASE_APP_NAME, assert_sync_standbys, build_connection_string, @@ -50,7 +50,7 @@ async def test_mailman3_core_db(ops_test: OpsTest, charm: str) -> None: charm, application_name=DATABASE_APP_NAME, num_units=DATABASE_UNITS, - series=CHARM_SERIES, + base=CHARM_BASE, config={"profile": "testing"}, ) @@ -200,14 +200,14 @@ async def test_roles_blocking(ops_test: OpsTest, charm: str) -> None: APPLICATION_NAME, application_name=APPLICATION_NAME, config={"legacy_roles": True}, - series=CHARM_SERIES, + base=CHARM_BASE, channel="edge", ) await ops_test.model.deploy( APPLICATION_NAME, application_name=f"{APPLICATION_NAME}2", config={"legacy_roles": True}, - series=CHARM_SERIES, + base=CHARM_BASE, channel="edge", ) @@ -304,7 +304,7 @@ async def test_canonical_livepatch_onprem_bundle_db(ops_test: OpsTest) -> None: # aren't providing an Ubuntu Pro token (as this is just a test to ensure # the database works in the context of the relation with the Livepatch charm). overlay = { - "applications": {"ubuntu-advantage": {"charm": "ubuntu-advantage", "series": CHARM_SERIES}} + "applications": {"ubuntu-advantage": {"charm": "ubuntu-advantage", "base": CHARM_BASE}} } await deploy_and_relate_bundle_with_postgresql( ops_test, diff --git a/tests/integration/test_db_admin.py b/tests/integration/test_db_admin.py index 838ab48cac..3ac3d31d29 100644 --- a/tests/integration/test_db_admin.py +++ b/tests/integration/test_db_admin.py @@ -11,7 +11,7 @@ from tenacity import Retrying, stop_after_delay, wait_fixed from .helpers import ( - CHARM_SERIES, + CHARM_BASE, DATABASE_APP_NAME, build_connection_string, check_database_users_existence, @@ -44,7 +44,7 @@ async def test_landscape_scalable_bundle_db(ops_test: OpsTest, charm: str) -> No charm, application_name=DATABASE_APP_NAME, num_units=DATABASE_UNITS, - series=CHARM_SERIES, + base=CHARM_BASE, config={"profile": "testing", "plugin_plpython3u_enable": "True"}, ) diff --git a/tests/integration/test_password_rotation.py b/tests/integration/test_password_rotation.py index 2f7d5be767..c456585134 100644 --- a/tests/integration/test_password_rotation.py +++ b/tests/integration/test_password_rotation.py @@ -10,7 +10,7 @@ from . import markers from .helpers import ( - CHARM_SERIES, + CHARM_BASE, METADATA, check_patroni, db_connect, @@ -37,7 +37,7 @@ async def test_deploy_active(ops_test: OpsTest): charm, application_name=APP_NAME, num_units=3, - series=CHARM_SERIES, + base=CHARM_BASE, config={"profile": "testing"}, ) await ops_test.model.wait_for_idle(apps=[APP_NAME], status="active", timeout=1500) diff --git a/tests/integration/test_plugins.py b/tests/integration/test_plugins.py index 07e862403c..d927ec1e3e 100644 --- a/tests/integration/test_plugins.py +++ b/tests/integration/test_plugins.py @@ -8,7 +8,7 @@ from pytest_operator.plugin import OpsTest from .helpers import ( - CHARM_SERIES, + CHARM_BASE, DATABASE_APP_NAME, db_connect, get_password, @@ -98,7 +98,7 @@ async def test_plugins(ops_test: OpsTest) -> None: await ops_test.model.deploy( charm, num_units=2, - series=CHARM_SERIES, + base=CHARM_BASE, config={"profile": "testing"}, ) await ops_test.model.wait_for_idle(apps=[DATABASE_APP_NAME], status="active", timeout=1500) diff --git a/tests/integration/test_subordinates.py b/tests/integration/test_subordinates.py index f9d30dedba..be9be926cc 100644 --- a/tests/integration/test_subordinates.py +++ b/tests/integration/test_subordinates.py @@ -9,7 +9,7 @@ from pytest_operator.plugin import OpsTest from .helpers import ( - CHARM_SERIES, + CHARM_BASE, scale_application, ) @@ -28,13 +28,14 @@ async def test_deploy(ops_test: OpsTest, charm: str, github_secrets): charm, application_name=DATABASE_APP_NAME, num_units=3, - series=CHARM_SERIES, + base=CHARM_BASE, ), ops_test.model.deploy( UBUNTU_PRO_APP_NAME, config={"token": github_secrets["UBUNTU_PRO_TOKEN"]}, channel="latest/edge", num_units=0, + base=CHARM_BASE, ), ops_test.model.deploy( LS_CLIENT, @@ -45,6 +46,7 @@ async def test_deploy(ops_test: OpsTest, charm: str, github_secrets): }, channel="latest/edge", num_units=0, + base=CHARM_BASE, ), ) diff --git a/tests/integration/test_tls.py b/tests/integration/test_tls.py index 814d266267..73164112d4 100644 --- a/tests/integration/test_tls.py +++ b/tests/integration/test_tls.py @@ -12,7 +12,7 @@ change_patroni_setting, ) from .helpers import ( - CHARM_SERIES, + CHARM_BASE, DATABASE_APP_NAME, METADATA, change_primary_start_timeout, @@ -58,7 +58,7 @@ async def test_deploy_active(ops_test: OpsTest): charm, application_name=APP_NAME, num_units=3, - series=CHARM_SERIES, + base=CHARM_BASE, config={"profile": "testing"}, ) # No wait between deploying charms, since we can't guarantee users will wait. Furthermore, @@ -72,7 +72,7 @@ async def test_tls_enabled(ops_test: OpsTest) -> None: async with ops_test.fast_forward(): # Deploy TLS Certificates operator. await ops_test.model.deploy( - tls_certificates_app_name, config=tls_config, channel=tls_channel + tls_certificates_app_name, config=tls_config, channel=tls_channel, base=CHARM_BASE ) # Relate it to the PostgreSQL to enable TLS.