diff --git a/tests/integration/metrics_tests/test_metrics.py b/tests/integration/metrics_tests/test_metrics.py index d7d0b5e7..5bc1a33d 100644 --- a/tests/integration/metrics_tests/test_metrics.py +++ b/tests/integration/metrics_tests/test_metrics.py @@ -1,7 +1,6 @@ #!/usr/bin/env python3 # Copyright 2023 Canonical Ltd. # See LICENSE file for licensing details. -import os import time from pathlib import Path @@ -51,10 +50,6 @@ async def verify_endpoints(ops_test: OpsTest, app_name=DATABASE_APP_NAME): assert mongodb_metrics.count("mongo") > 10 -@pytest.mark.skipif( - os.environ.get("PYTEST_SKIP_DEPLOY", False), - reason="skipping deploy, model expected to be provided.", -) @pytest.mark.abort_on_fail async def test_build_and_deploy(ops_test: OpsTest) -> None: """Build and deploy three units of MongoDB and one unit of TLS.""" diff --git a/tests/integration/relation_tests/test_charm_relations.py b/tests/integration/relation_tests/test_charm_relations.py index 13d99a15..940e11f5 100644 --- a/tests/integration/relation_tests/test_charm_relations.py +++ b/tests/integration/relation_tests/test_charm_relations.py @@ -146,10 +146,8 @@ async def verify_crud_operations(ops_test: OpsTest, connection_string: str): async def test_database_relation_with_charm_libraries(ops_test: OpsTest): """Test basic functionality of database relation interface.""" # Relate the charms and wait for them exchanging some connection data. - db_app_name = ( - await get_app_name(ops_test, test_deployments=[ANOTHER_DATABASE_APP_NAME]) - or DATABASE_APP_NAME - ) + db_app_name = await get_app_name(ops_test, test_deployments=[ANOTHER_DATABASE_APP_NAME]) + await ops_test.model.integrate( f"{APPLICATION_APP_NAME}:{FIRST_DATABASE_RELATION_NAME}", db_app_name ) @@ -181,10 +179,8 @@ async def verify_primary(ops_test: OpsTest, application_name: str): async def test_app_relation_metadata_change(ops_test: OpsTest) -> None: """Verifies that the app metadata changes with db relation joined and departed events.""" # verify application metadata is correct before adding/removing units. - db_app_name = ( - await get_app_name(ops_test, test_deployments=[ANOTHER_DATABASE_APP_NAME]) - or DATABASE_APP_NAME - ) + db_app_name = await get_app_name(ops_test, test_deployments=[ANOTHER_DATABASE_APP_NAME]) + try: await verify_application_data( ops_test, APPLICATION_APP_NAME, db_app_name, FIRST_DATABASE_RELATION_NAME @@ -334,10 +330,8 @@ async def test_two_applications_doesnt_share_the_same_relation_data(ops_test: Op ) await ops_test.model.wait_for_idle(apps=all_app_names, status="active") - db_app_name = ( - await get_app_name(ops_test, test_deployments=[ANOTHER_DATABASE_APP_NAME]) - or DATABASE_APP_NAME - ) + db_app_name = await get_app_name(ops_test, test_deployments=[ANOTHER_DATABASE_APP_NAME]) + # Relate the new application with the database # and wait for them exchanging some connection data. await ops_test.model.integrate( @@ -359,10 +353,8 @@ async def test_an_application_can_connect_to_multiple_database_clusters(ops_test """Test that an application can connect to different clusters of the same database.""" # Relate the application with both database clusters # and wait for them exchanging some connection data. - db_app_name = ( - await get_app_name(ops_test, test_deployments=[ANOTHER_DATABASE_APP_NAME]) - or DATABASE_APP_NAME - ) + db_app_name = await get_app_name(ops_test, test_deployments=[ANOTHER_DATABASE_APP_NAME]) + first_cluster_relation = await ops_test.model.integrate( f"{APPLICATION_APP_NAME}:{MULTIPLE_DATABASE_CLUSTERS_RELATION_NAME}", db_app_name ) @@ -395,10 +387,7 @@ async def test_an_application_can_connect_to_multiple_aliased_database_clusters( """Test that an application can connect to different clusters of the same database.""" # Relate the application with both database clusters # and wait for them exchanging some connection data. - db_app_name = ( - await get_app_name(ops_test, test_deployments=[ANOTHER_DATABASE_APP_NAME]) - or DATABASE_APP_NAME - ) + db_app_name = await get_app_name(ops_test, test_deployments=[ANOTHER_DATABASE_APP_NAME]) await asyncio.gather( ops_test.model.integrate( f"{APPLICATION_APP_NAME}:{ALIASED_MULTIPLE_DATABASE_CLUSTERS_RELATION_NAME}", @@ -434,10 +423,8 @@ async def test_an_application_can_connect_to_multiple_aliased_database_clusters( async def test_an_application_can_request_multiple_databases(ops_test: OpsTest): """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. - db_app_name = ( - await get_app_name(ops_test, test_deployments=[ANOTHER_DATABASE_APP_NAME]) - or DATABASE_APP_NAME - ) + db_app_name = await get_app_name(ops_test, test_deployments=[ANOTHER_DATABASE_APP_NAME]) + await ops_test.model.integrate( f"{APPLICATION_APP_NAME}:{SECOND_DATABASE_RELATION_NAME}", db_app_name ) @@ -461,10 +448,8 @@ async def test_removed_relation_no_longer_has_access(ops_test: OpsTest): connection_string = await get_connection_string( ops_test, APPLICATION_APP_NAME, FIRST_DATABASE_RELATION_NAME ) - db_app_name = ( - await get_app_name(ops_test, test_deployments=[ANOTHER_DATABASE_APP_NAME]) - or DATABASE_APP_NAME - ) + db_app_name = await get_app_name(ops_test, test_deployments=[ANOTHER_DATABASE_APP_NAME]) + await ops_test.model.applications[db_app_name].remove_relation( f"{APPLICATION_APP_NAME}:{FIRST_DATABASE_RELATION_NAME}", f"{db_app_name}:database" )