Skip to content

Commit

Permalink
format & lint
Browse files Browse the repository at this point in the history
  • Loading branch information
BalabaDmitri committed Apr 29, 2024
1 parent 19574bd commit 6873326
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 30 deletions.
12 changes: 6 additions & 6 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@
MONITORING_USER,
PATRONI_CONF_PATH,
PEER,
UPGRADE_RELATION,
POSTGRESQL_SNAP_NAME,
REPLICATION_PASSWORD_KEY,
REWIND_PASSWORD_KEY,
Expand All @@ -84,6 +83,7 @@
TLS_CERT_FILE,
TLS_KEY_FILE,
UNIT_SCOPE,
UPGRADE_RELATION,
USER,
USER_PASSWORD_KEY,
)
Expand All @@ -96,9 +96,7 @@

PRIMARY_NOT_REACHABLE_MESSAGE = "waiting for primary to be reachable from this unit"
EXTENSIONS_DEPENDENCY_MESSAGE = "Unsatisfied plugin dependencies. Please check the logs"
DIFFERENT_VERSIONS_PSQL_BLOCKING_MESSAGE = (
"Please select the correct version of postgresql to use. You cannot use different versions of postgresql!"
)
DIFFERENT_VERSIONS_PSQL_BLOCKING_MESSAGE = "Please select the correct version of postgresql to use. You cannot use different versions of postgresql!"

Scopes = Literal[APP_SCOPE, UNIT_SCOPE]

Expand Down Expand Up @@ -160,7 +158,9 @@ def __init__(self, *args):
self.framework.observe(self.on.config_changed, self._on_config_changed)
self.framework.observe(self.on.get_primary_action, self._on_get_primary)
self.framework.observe(self.on[PEER].relation_changed, self._on_peer_relation_changed)
self.framework.observe(self.on[UPGRADE_RELATION].relation_changed, self._on_upgrade_relation_changed)
self.framework.observe(
self.on[UPGRADE_RELATION].relation_changed, self._on_upgrade_relation_changed
)
self.framework.observe(self.on.secret_changed, self._on_peer_relation_changed)
self.framework.observe(self.on.secret_remove, self._on_peer_relation_changed)
self.framework.observe(self.on[PEER].relation_departed, self._on_peer_relation_departed)
Expand Down Expand Up @@ -1620,7 +1620,7 @@ def client_relations(self) -> List[Relation]:
return relations

def _set_workload_version(self, psql_version):
"""Record the version of the software running as the workload. Also writes the version into the databags"""
"""Record the version of the software running as the workload. Also writes the version into the databags."""
self.unit.set_workload_version(psql_version)
if self.unit.is_leader():
self.app_peer_data.update({"database-version": psql_version})
Expand Down
44 changes: 22 additions & 22 deletions tests/integration/ha_tests/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -875,15 +875,15 @@ async def reused_full_cluster_recovery_storage(ops_test: OpsTest, unit_name) ->
async def get_db_connection(ops_test, dbname, is_primary=True, replica_unit_name=""):
"""Returns a PostgreSQL connection string.
Args:
ops_test: The ops test framework instance
dbname: The name of the database
is_primary: Whether to use a primary unit (default is True, so it uses the primary
replica_unit_name: The name of the replica unit
Returns:
a PostgreSQL connection string
"""
Args:
ops_test: The ops test framework instance
dbname: The name of the database
is_primary: Whether to use a primary unit (default is True, so it uses the primary
replica_unit_name: The name of the replica unit
Returns:
a PostgreSQL connection string
"""
unit_name = await get_primary(ops_test, APP_NAME)
password = await get_password(ops_test, APP_NAME)
address = get_unit_address(ops_test, unit_name)
Expand All @@ -900,9 +900,9 @@ async def get_db_connection(ops_test, dbname, is_primary=True, replica_unit_name
async def validate_test_data(connection_string):
"""Checking test data.
Args:
connection_string: Database connection string
"""
Args:
connection_string: Database connection string
"""
with psycopg2.connect(connection_string) as connection:
connection.autocommit = True
with connection.cursor() as cursor:
Expand All @@ -915,9 +915,9 @@ async def validate_test_data(connection_string):
async def create_test_data(connection_string):
"""Creating test data in the database.
Args:
connection_string: Database connection string
"""
Args:
connection_string: Database connection string
"""
with psycopg2.connect(connection_string) as connection:
connection.autocommit = True
with connection.cursor() as cursor:
Expand All @@ -935,14 +935,14 @@ async def create_test_data(connection_string):
async def get_last_added_unit(ops_test, app, prev_units):
"""Returns a unit.
Args:
ops_test: The ops test framework instance
app: The name of the application
prev_units: List of unit names before adding the last unit
Args:
ops_test: The ops test framework instance
app: The name of the application
prev_units: List of unit names before adding the last unit
Returns:
last added unit
"""
Returns:
last added unit
"""
curr_units = [unit.name for unit in ops_test.model.applications[app].units]
new_unit = list(set(curr_units) - set(prev_units))[0]
for unit in ops_test.model.applications[app].units:
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 @@ -17,10 +17,10 @@
set_password,
)
from .helpers import (
SECOND_APPLICATION,
add_unit_with_storage,
reused_full_cluster_recovery_storage,
storage_id,
SECOND_APPLICATION,
)

FIRST_APPLICATION = "first-cluster"
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/ha_tests/test_self_healing.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from .helpers import (
METADATA,
ORIGINAL_RESTART_CONDITION,
SECOND_APPLICATION,
add_unit_with_storage,
app_name,
are_all_db_processes_down,
Expand Down Expand Up @@ -56,7 +57,6 @@
update_restart_condition,
validate_test_data,
wait_network_restore,
SECOND_APPLICATION,
)

logger = logging.getLogger(__name__)
Expand Down

0 comments on commit 6873326

Please sign in to comment.