Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
BalabaDmitri committed Apr 4, 2024
1 parent 1eb10e9 commit f9113e2
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
7 changes: 5 additions & 2 deletions src/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# See LICENSE file for licensing details.

"""Helper class used to manage cluster lifecycle."""

import glob
import logging
import os
Expand Down Expand Up @@ -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.
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion tests/integration/ha_tests/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/ha_tests/test_restore_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
10 changes: 7 additions & 3 deletions tests/integration/ha_tests/test_self_healing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -58,6 +57,7 @@
validate_test_data,
wait_network_restore,
)
from .test_restore_cluster import SECOND_APPLICATION

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -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")
Expand All @@ -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)
Expand Down

0 comments on commit f9113e2

Please sign in to comment.