Skip to content

Commit 4d18611

Browse files
committed
fix(regression): fix test_inc_restoration_with_multiple_rebuild_and_expansion
Adjust test_inc_restoration_with_multiple_rebuild_and_expansion for the v2 data engine snapshot model. The old v2 assertions expected the DR volume to contain only volume-head after incremental restore and expansion. That does not match the current SPDK restore flow, which preserves the latest restore-* snapshot for traceability and may create temporary rebuild system snapshots during recovery. Update the test to: - wait for temporary v2 system snapshots to be purged - expect restore-* plus volume-head as the stable snapshot layout - verify the restore snapshot/volume-head parent-child relationship This keeps the v1 expectations unchanged while making the HA DR test match v2 restore behavior. Longhorn 13075 Signed-off-by: Derek Su <derek.su@suse.com>
1 parent aac0df4 commit 4d18611

1 file changed

Lines changed: 32 additions & 16 deletions

File tree

manager/integration/tests/test_ha.py

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
from common import wait_for_backup_volume_backing_image_synced
8080
from common import RETRY_COMMAND_COUNT
8181
from common import wait_for_snapshot_count
82+
from common import wait_for_system_snapshot_count
8283
from common import DEFAULT_BACKUP_COMPRESSION_METHOD
8384
from common import wait_scheduling_failure
8485
from common import set_tags_for_node_and_its_disks
@@ -1015,6 +1016,34 @@ def test_rebuild_with_inc_restoration(set_random_backupstore, client, core_api,
10151016
backupstore_cleanup(client)
10161017

10171018

1019+
def verify_v2_restored_snapshot_info(volume, vol_name):
1020+
# For V2, restore completion leaves the latest restore snapshot as the
1021+
# only non-system snapshot and volume-head points to it. Rebuild may
1022+
# create temporary system snapshots, so wait for them to be purged.
1023+
wait_for_system_snapshot_count(volume, 0)
1024+
wait_for_snapshot_count(volume, 2, count_removed=True)
1025+
snapshots = volume.snapshotList(volume=vol_name)
1026+
assert len(snapshots.data) == 2
1027+
1028+
snapshot_map = {snap["name"]: snap for snap in snapshots.data}
1029+
assert "volume-head" in snapshot_map
1030+
1031+
restore_snapshot_names = [
1032+
name for name in snapshot_map if name != "volume-head"
1033+
]
1034+
assert len(restore_snapshot_names) == 1
1035+
1036+
restore_snapshot_name = restore_snapshot_names[0]
1037+
restore_snapshot = snapshot_map[restore_snapshot_name]
1038+
volume_head = snapshot_map["volume-head"]
1039+
1040+
assert restore_snapshot_name.startswith("restore-")
1041+
assert restore_snapshot["usercreated"]
1042+
assert restore_snapshot["parent"] == ""
1043+
assert "volume-head" in restore_snapshot["children"]
1044+
assert volume_head["parent"] == restore_snapshot_name
1045+
1046+
10181047
@pytest.mark.v2_volume_test # NOQA
10191048
def test_inc_restoration_with_multiple_rebuild_and_expansion(set_random_backupstore, client, core_api, volume_name, storage_class, csi_pv, pvc, pod_make): # NOQA
10201049
"""
@@ -1034,8 +1063,7 @@ def test_inc_restoration_with_multiple_rebuild_and_expansion(set_random_backupst
10341063
11. For the DR volume, delete one replica and trigger incremental restore
10351064
simultaneously.
10361065
12. Wait for the inc restoration complete and the volume becoming Healthy.
1037-
13. Check the DR volume size and snapshot info. Make sure there is only
1038-
one snapshot in the volume.
1066+
13. Check the DR volume size and snapshot info.
10391067
14. Online expand the std volume and wait for expansion complete.
10401068
15. Write data to the std volume then create the 3rd backup.
10411069
16. Trigger the inc restore then re-verify the snapshot info.
@@ -1162,14 +1190,7 @@ def test_inc_restoration_with_multiple_rebuild_and_expansion(set_random_backupst
11621190
assert not snap["usercreated"]
11631191
assert "volume-head" in snap["children"]
11641192
else:
1165-
# v2 expansion resizes lvol bdevs directly without creating an
1166-
# expand-<size> snapshot, so only volume-head remains.
1167-
wait_for_snapshot_count(dr_volume, 1, count_removed=True)
1168-
snapshots = dr_volume.snapshotList(volume=dr_volume_name)
1169-
assert len(snapshots.data) == 1
1170-
snap = snapshots.data[0]
1171-
assert snap["name"] == "volume-head"
1172-
assert snap["parent"] == ""
1193+
verify_v2_restored_snapshot_info(dr_volume, dr_volume_name)
11731194

11741195
# Step 14: Do online expansion for the std volume.
11751196
expand_size2 = 3 * Gi
@@ -1207,12 +1228,7 @@ def test_inc_restoration_with_multiple_rebuild_and_expansion(set_random_backupst
12071228
assert not snap["usercreated"]
12081229
assert "volume-head" in snap["children"]
12091230
else:
1210-
wait_for_snapshot_count(dr_volume, 1, count_removed=True)
1211-
snapshots = dr_volume.snapshotList(volume=dr_volume_name)
1212-
assert len(snapshots.data) == 1
1213-
snap = snapshots.data[0]
1214-
assert snap["name"] == "volume-head"
1215-
assert snap["parent"] == ""
1231+
verify_v2_restored_snapshot_info(dr_volume, dr_volume_name)
12161232

12171233
activate_standby_volume(client, dr_volume_name)
12181234
wait_for_volume_detached(client, dr_volume_name)

0 commit comments

Comments
 (0)