From cf1c57c9a6cb61d78ab1c15acfe72321222302b4 Mon Sep 17 00:00:00 2001 From: Dragomir Penev Date: Fri, 27 Oct 2023 18:06:41 +0300 Subject: [PATCH] Enable connection logging properly --- tests/integration/helpers/postgresql_helpers.py | 15 --------------- .../relations/test_backend_database.py | 6 ++---- 2 files changed, 2 insertions(+), 19 deletions(-) diff --git a/tests/integration/helpers/postgresql_helpers.py b/tests/integration/helpers/postgresql_helpers.py index 7e2cd3d91..62bc6185f 100644 --- a/tests/integration/helpers/postgresql_helpers.py +++ b/tests/integration/helpers/postgresql_helpers.py @@ -91,21 +91,6 @@ async def check_database_creation( assert len(output) -async def enable_connections_logging(ops_test: OpsTest, unit_name: str) -> None: - """Turn on the log of all connections made to a PostgreSQL instance. - - Args: - ops_test: The ops test framework instance - unit_name: The name of the unit to turn on the connection logs - """ - unit_address = await get_unit_address(ops_test, unit_name) - requests.patch( - f"https://{unit_address}:8008/config", - json={"postgresql": {"parameters": {"log_connections": True}}}, - verify=False, - ) - - async def execute_query_on_unit( unit_address: str, user: str, diff --git a/tests/integration/relations/test_backend_database.py b/tests/integration/relations/test_backend_database.py index ce957335f..e48661ca5 100644 --- a/tests/integration/relations/test_backend_database.py +++ b/tests/integration/relations/test_backend_database.py @@ -23,7 +23,6 @@ ) from ..helpers.postgresql_helpers import ( check_database_users_existence, - enable_connections_logging, get_postgres_primary, run_command_on_unit, ) @@ -122,9 +121,8 @@ async def test_tls_encrypted_connection_to_postgres(ops_test: OpsTest): await ops_test.model.relate(PG, TLS) await ops_test.model.wait_for_idle(status="active", timeout=1000) - # Enable additional logs on the PostgreSQL instance to check TLS - # being used in a later step. - await enable_connections_logging(ops_test, f"{PG}/0") + await ops_test.model.applications[PG].set_config({"logging_log_connections": "True"}) + await ops_test.model.wait_for_idle(apps=[PG], status="active", idle_period=30) # Deploy an app and relate it to PgBouncer to open a connection # between PgBouncer and PostgreSQL.