Skip to content

Commit

Permalink
resolving enrico comments
Browse files Browse the repository at this point in the history
  • Loading branch information
MiaAltieri committed Aug 31, 2023
1 parent e4eb574 commit a6fe84a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
8 changes: 4 additions & 4 deletions tests/integration/ha_tests/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,7 @@ async def reused_storage(ops_test: OpsTest, reused_unit: Unit, removal_time: dat
return_code == 0
), f"Failed catting mongodb logs, unit={reused_unit.name}, container={MONGODB_CONTAINER_NAME}"

filtered_logs = filter(filter_logs.split("\n"), logs)
filtered_logs = filter(filter_logs, logs.split("\n"))

for log in filtered_logs:
item = json.loads(log)
Expand All @@ -780,12 +780,12 @@ def convert_time(time_as_str: str) -> int:
return time.mktime(d.timetuple())


def get_newest_unit(ops_test: OpsTest, app_name: str) -> Unit:
def get_highest_unit(ops_test: OpsTest, app_name: str) -> Unit:
"""Retrieves the most recently added unit to the MongoDB application."""
num_units = len(ops_test.model.applications[app_name].units)
newest_unit_name = f"mongodb-k8s/{num_units-1}"
highest_unit_name = f"mongodb-k8s/{num_units-1}"
for unit in ops_test.model.applications[app_name].units:
if unit.name == newest_unit_name:
if unit.name == highest_unit_name:
return unit


Expand Down
6 changes: 4 additions & 2 deletions tests/integration/ha_tests/test_ha.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
find_record_in_collection,
find_unit,
get_application_name,
get_highest_unit,
get_mongo_client,
get_newest_unit,
get_other_mongodb_direct_client,
get_process_pid,
get_replica_set_primary,
Expand Down Expand Up @@ -618,7 +618,9 @@ async def test_storage_re_use(ops_test, continuous_writes):
apps=[app], status="active", timeout=1000, wait_for_exact_units=(current_number_units)
)

new_unit = get_newest_unit(ops_test, app)
# for this test, we only scaled up the application by one unit. So it the highest unit will be
# the newest unit.
new_unit = get_highest_unit(ops_test, app)
assert await reused_storage(
ops_test, new_unit, removal_time
), "attached storage not properly re-used by MongoDB."
Expand Down

0 comments on commit a6fe84a

Please sign in to comment.