Skip to content

Commit

Permalink
Enable connection logging properly
Browse files Browse the repository at this point in the history
  • Loading branch information
dragomirp committed Oct 27, 2023
1 parent 529e880 commit cf1c57c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 19 deletions.
15 changes: 0 additions & 15 deletions tests/integration/helpers/postgresql_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 2 additions & 4 deletions tests/integration/relations/test_backend_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
)
from ..helpers.postgresql_helpers import (
check_database_users_existence,
enable_connections_logging,
get_postgres_primary,
run_command_on_unit,
)
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit cf1c57c

Please sign in to comment.