From f9113e23749b4754b2dfd090722e17922a8e39d8 Mon Sep 17 00:00:00 2001 From: BalabaDmintri Date: Thu, 4 Apr 2024 15:53:12 +0300 Subject: [PATCH] format --- src/cluster.py | 7 +++++-- tests/integration/ha_tests/helpers.py | 2 +- tests/integration/ha_tests/test_restore_cluster.py | 2 +- tests/integration/ha_tests/test_self_healing.py | 10 +++++++--- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/cluster.py b/src/cluster.py index b20795d99b..38696d7036 100644 --- a/src/cluster.py +++ b/src/cluster.py @@ -3,6 +3,7 @@ # See LICENSE file for licensing details. """Helper class used to manage cluster lifecycle.""" + import glob import logging import os @@ -648,7 +649,6 @@ def update_synchronous_node_count(self, units: int = None) -> None: if r.status_code != 200: raise UpdateSyncNodeCountError(f"received {r.status_code}") - def cluster_system_id_mismatch(self, unit_name: str) -> bool: """Check if the Patroni service is down. @@ -659,7 +659,10 @@ def cluster_system_id_mismatch(self, unit_name: str) -> bool: """ last_log_file = self._last_patroni_log_file() unit_name = unit_name.replace("/", "-") - if f" CRITICAL: system ID mismatch, node {unit_name} belongs to a different cluster:" in last_log_file: + if ( + f" CRITICAL: system ID mismatch, node {unit_name} belongs to a different cluster:" + in last_log_file + ): return True return False diff --git a/tests/integration/ha_tests/helpers.py b/tests/integration/ha_tests/helpers.py index 4bdc57f9e7..dc97f399a9 100644 --- a/tests/integration/ha_tests/helpers.py +++ b/tests/integration/ha_tests/helpers.py @@ -807,7 +807,7 @@ def storage_id(ops_test, unit_name): return line.split()[1] -async def add_unit_with_storage(ops_test, app, storage, is_blocked: bool= False): +async def add_unit_with_storage(ops_test, app, storage, is_blocked: bool = False): """Adds unit with storage. Note: this function exists as a temporary solution until this issue is resolved: diff --git a/tests/integration/ha_tests/test_restore_cluster.py b/tests/integration/ha_tests/test_restore_cluster.py index d6f08321c2..19445a084a 100644 --- a/tests/integration/ha_tests/test_restore_cluster.py +++ b/tests/integration/ha_tests/test_restore_cluster.py @@ -53,7 +53,7 @@ async def test_build_and_deploy(ops_test: OpsTest) -> None: num_units=1, series=CHARM_SERIES, config={"profile": "testing"}, - ) + ), ) await ops_test.model.wait_for_idle(status="active", timeout=1500) diff --git a/tests/integration/ha_tests/test_self_healing.py b/tests/integration/ha_tests/test_self_healing.py index ac39d738db..40c0fc1c86 100644 --- a/tests/integration/ha_tests/test_self_healing.py +++ b/tests/integration/ha_tests/test_self_healing.py @@ -9,7 +9,6 @@ from pytest_operator.plugin import OpsTest from tenacity import Retrying, stop_after_delay, wait_fixed -from .test_restore_cluster import SECOND_APPLICATION from ..helpers import ( CHARM_SERIES, db_connect, @@ -58,6 +57,7 @@ validate_test_data, wait_network_restore, ) +from .test_restore_cluster import SECOND_APPLICATION logger = logging.getLogger(__name__) @@ -615,7 +615,9 @@ async def test_deploy_zero_units(ops_test: OpsTest, charm): # Scale up to one unit. logger.info("scaling database to one unit") await add_unit_with_storage(ops_test, app=app, storage=primary_storage) - await ops_test.model.wait_for_idle(apps=[APP_NAME, APPLICATION_NAME], status="active", timeout=1500) + await ops_test.model.wait_for_idle( + apps=[APP_NAME, APPLICATION_NAME], status="active", timeout=1500 + ) connection_string, _ = await get_db_connection(ops_test, dbname=dbname) logger.info("checking whether writes are increasing") @@ -625,7 +627,9 @@ async def test_deploy_zero_units(ops_test: OpsTest, charm): await validate_test_data(connection_string) logger.info("database scaling up to two units using third-party cluster storage") - new_unit = await add_unit_with_storage(ops_test, app=app, storage=second_storage, is_blocked=True) + new_unit = await add_unit_with_storage( + ops_test, app=app, storage=second_storage, is_blocked=True + ) logger.info(f"remove unit {new_unit.name} with storage from application {SECOND_APPLICATION}") await ops_test.model.destroy_units(new_unit.name)