From c8d4413efce52d9f3af80dac7dc061a38ec10cfb Mon Sep 17 00:00:00 2001 From: Dragomir Penev <6687393+dragomirp@users.noreply.github.com> Date: Wed, 31 Jul 2024 17:34:06 +0300 Subject: [PATCH] [MISC] Switch test app interface (#595) * Switch test app interface * Missed changes * Switch to edge --- tests/integration/ha_tests/helpers.py | 8 ++++---- tests/integration/ha_tests/test_async_replication.py | 6 +++--- tests/integration/new_relations/test_new_relations.py | 10 +++++----- .../new_relations/test_relations_coherence.py | 2 +- tests/integration/relations/helpers.py | 2 +- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/tests/integration/ha_tests/helpers.py b/tests/integration/ha_tests/helpers.py index ae027edc25..075bff0d32 100644 --- a/tests/integration/ha_tests/helpers.py +++ b/tests/integration/ha_tests/helpers.py @@ -315,7 +315,7 @@ async def count_writes( ip = service.status.podIP connection_string = ( - f"dbname='{APPLICATION_NAME.replace('-', '_')}_first_database' user='operator'" + f"dbname='{APPLICATION_NAME.replace('-', '_')}_database' user='operator'" f" host='{ip}' password='{password}' connect_timeout=10" ) @@ -723,7 +723,7 @@ async def is_secondary_up_to_date(ops_test: OpsTest, unit_name: str, expected_wr status = await ops_test.model.get_status() host = status["applications"][app]["units"][unit_name]["address"] connection_string = ( - f"dbname='{APPLICATION_NAME.replace('-', '_')}_first_database' user='operator'" + f"dbname='{APPLICATION_NAME.replace('-', '_')}_database' user='operator'" f" host='{host}' password='{password}' connect_timeout=10" ) @@ -843,10 +843,10 @@ async def start_continuous_writes(ops_test: OpsTest, app: str, model: Model = No for relation in model.applications[app].relations if not relation.is_peer and f"{relation.requires.application_name}:{relation.requires.name}" - == f"{APPLICATION_NAME}:first-database" + == f"{APPLICATION_NAME}:database" ] if not relations: - await model.relate(app, f"{APPLICATION_NAME}:first-database") + await model.relate(app, f"{APPLICATION_NAME}:database") await model.wait_for_idle(status="active", timeout=1000) else: action = ( diff --git a/tests/integration/ha_tests/test_async_replication.py b/tests/integration/ha_tests/test_async_replication.py index 451f6417c5..fd113bda36 100644 --- a/tests/integration/ha_tests/test_async_replication.py +++ b/tests/integration/ha_tests/test_async_replication.py @@ -112,8 +112,8 @@ async def test_deploy_async_replication_setup( """Build and deploy two PostgreSQL cluster in two separate models to test async replication.""" await build_and_deploy(ops_test, CLUSTER_SIZE, wait_for_idle=False) await build_and_deploy(ops_test, CLUSTER_SIZE, wait_for_idle=False, model=second_model) - await ops_test.model.deploy(APPLICATION_NAME, num_units=1) - await second_model.deploy(APPLICATION_NAME, num_units=1) + await ops_test.model.deploy(APPLICATION_NAME, channel="latest/edge", num_units=1) + await second_model.deploy(APPLICATION_NAME, channel="latest/edge", num_units=1) async with ops_test.fast_forward(), fast_forward(second_model): await gather( @@ -318,7 +318,7 @@ async def test_promote_standby( primary = await get_primary(ops_test) address = await get_unit_address(ops_test, primary) password = await get_password(ops_test) - database_name = f'{APPLICATION_NAME.replace("-", "_")}_first_database' + database_name = f'{APPLICATION_NAME.replace("-", "_")}_database' connection = None try: connection = psycopg2.connect( diff --git a/tests/integration/new_relations/test_new_relations.py b/tests/integration/new_relations/test_new_relations.py index 829dfaad42..c3aa7a271c 100644 --- a/tests/integration/new_relations/test_new_relations.py +++ b/tests/integration/new_relations/test_new_relations.py @@ -36,7 +36,7 @@ REDIS_APP_NAME = "redis-k8s" APP_NAMES = [APPLICATION_APP_NAME, DATABASE_APP_NAME, ANOTHER_DATABASE_APP_NAME] DATABASE_APP_METADATA = yaml.safe_load(Path("./metadata.yaml").read_text()) -FIRST_DATABASE_RELATION_NAME = "first-database" +FIRST_DATABASE_RELATION_NAME = "database" SECOND_DATABASE_RELATION_NAME = "second-database" MULTIPLE_DATABASE_CLUSTERS_RELATION_NAME = "multiple-database-clusters" ALIASED_MULTIPLE_DATABASE_CLUSTERS_RELATION_NAME = "aliased-multiple-database-clusters" @@ -216,8 +216,8 @@ async def test_two_applications_doesnt_share_the_same_relation_data(ops_test: Op # Check that the user cannot access other databases. for application, other_application_database in [ - (APPLICATION_APP_NAME, "another_application_first_database"), - (another_application_app_name, f"{APPLICATION_APP_NAME.replace('-', '_')}_first_database"), + (APPLICATION_APP_NAME, "another_application_database"), + (another_application_app_name, f"{APPLICATION_APP_NAME.replace('-', '_')}_database"), ]: connection_string = await build_connection_string( ops_test, application, FIRST_DATABASE_RELATION_NAME, database="postgres" @@ -462,8 +462,8 @@ async def test_admin_role(ops_test: OpsTest): # Check that the user can access all the databases. for database in [ "postgres", - f"{APPLICATION_APP_NAME.replace('-', '_')}_first_database", - "another_application_first_database", + f"{APPLICATION_APP_NAME.replace('-', '_')}_database", + "another_application_database", ]: logger.info(f"connecting to the following database: {database}") connection_string = await build_connection_string( diff --git a/tests/integration/new_relations/test_relations_coherence.py b/tests/integration/new_relations/test_relations_coherence.py index 4a6e372e4e..cb08f2b560 100644 --- a/tests/integration/new_relations/test_relations_coherence.py +++ b/tests/integration/new_relations/test_relations_coherence.py @@ -17,7 +17,7 @@ APPLICATION_APP_NAME = "postgresql-test-app" APP_NAMES = [DATABASE_APP_NAME, DATA_INTEGRATOR_APP_NAME] -FIRST_DATABASE_RELATION_NAME = "first-database" +FIRST_DATABASE_RELATION_NAME = "database" @pytest.mark.group(1) diff --git a/tests/integration/relations/helpers.py b/tests/integration/relations/helpers.py index 0970f657fa..fc3f5e6b4c 100644 --- a/tests/integration/relations/helpers.py +++ b/tests/integration/relations/helpers.py @@ -11,5 +11,5 @@ APP_NAME = METADATA["name"] DB_RELATION = "db" DATABASE_RELATION = "database" -FIRST_DATABASE_RELATION = "first-database" +FIRST_DATABASE_RELATION = "database" APP_NAMES = [APP_NAME, APPLICATION_APP_NAME]