Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
marceloneppel committed Oct 23, 2023
1 parent 1825ebc commit ef9b0aa
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/backups.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ def _empty_data_files(self) -> None:
def _change_connectivity_to_database(self, connectivity: bool) -> None:
"""Enable or disable the connectivity to the database."""
self.charm.unit_peer_data.update({"connectivity": "on" if connectivity else "off"})
self.charm.update_config()
self.charm.update_config(is_creating_backup=True)

def _execute_command(
self, command: List[str], timeout: float = None
Expand Down
3 changes: 2 additions & 1 deletion src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -1410,7 +1410,8 @@ def update_config(self, is_creating_backup: bool = False) -> bool:
logger.debug("Early exit update_config: Patroni not started yet")
return False

self._validate_config_options()
if not is_creating_backup:
self._validate_config_options()

self._patroni.update_parameter_controller_by_patroni(
"max_connections", max(4 * available_cpu_cores, 100)
Expand Down
15 changes: 0 additions & 15 deletions tests/integration/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,21 +294,6 @@ async def deploy_and_relate_application_with_postgresql(
return relation.id


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,
password: str,
Expand Down
8 changes: 6 additions & 2 deletions tests/integration/test_tls.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
check_tls_patroni_api,
db_connect,
deploy_and_relate_application_with_postgresql,
enable_connections_logging,
get_password,
get_primary,
get_unit_address,
Expand Down Expand Up @@ -95,7 +94,12 @@ async def test_mattermost_db(ops_test: OpsTest) -> None:

# Enable additional logs on the PostgreSQL instance to check TLS
# being used in a later step.
await enable_connections_logging(ops_test, primary)
await ops_test.model.applications[DATABASE_APP_NAME].set_config(
{"logging_log_connections": "True"}
)
await ops_test.model.wait_for_idle(
apps=[DATABASE_APP_NAME], status="active", idle_period=30
)

for attempt in Retrying(stop=stop_after_delay(60), wait=wait_fixed(2), reraise=True):
with attempt:
Expand Down

0 comments on commit ef9b0aa

Please sign in to comment.