Skip to content

Commit

Permalink
[MISC] Switch test app interface (#595)
Browse files Browse the repository at this point in the history
* Switch test app interface

* Missed changes

* Switch to edge
  • Loading branch information
dragomirp authored Jul 31, 2024
1 parent 6bb4bdc commit c8d4413
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
8 changes: 4 additions & 4 deletions tests/integration/ha_tests/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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"
)

Expand Down Expand Up @@ -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 = (
Expand Down
6 changes: 3 additions & 3 deletions tests/integration/ha_tests/test_async_replication.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down
10 changes: 5 additions & 5 deletions tests/integration/new_relations/test_new_relations.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/relations/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]

0 comments on commit c8d4413

Please sign in to comment.