Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitry-ratushnyy committed Apr 26, 2024
1 parent 1868a38 commit abdfd61
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 33 deletions.
5 changes: 0 additions & 5 deletions tests/integration/metrics_tests/test_metrics.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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."""
Expand Down
41 changes: 13 additions & 28 deletions tests/integration/relation_tests/test_charm_relations.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand All @@ -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
)
Expand Down Expand Up @@ -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}",
Expand Down Expand Up @@ -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
)
Expand All @@ -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"
)
Expand Down

0 comments on commit abdfd61

Please sign in to comment.