Skip to content

Commit

Permalink
fix: wait for backing image restoration finished before checking volu…
Browse files Browse the repository at this point in the history
…me restoration

ref: longhorn/longhorn 8515

Signed-off-by: Jack Lin <jack.lin@suse.com>
  • Loading branch information
ChanYiLin committed May 24, 2024
1 parent 1072de2 commit b854c8d
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion manager/integration/tests/test_system_backup_restore.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from common import client # NOQA
from common import volume_name # NOQA

from common import core_api
from common import check_volume_data
from common import cleanup_volume
from common import create_and_check_volume
Expand All @@ -24,6 +25,11 @@
from common import BACKING_IMAGE_NAME
from common import BACKING_IMAGE_RAW_URL
from common import BACKING_IMAGE_SOURCE_TYPE_RESTORE
from common import create_pv_for_volume
from common import create_pvc_for_volume
from common import check_pvc_existence
from common import check_pv_existence
from common import check_backing_image_disk_map_status

from common import SETTING_BACKUPSTORE_POLL_INTERVAL

Expand Down Expand Up @@ -118,7 +124,7 @@ def test_system_backup_and_restore_volume_with_data(client, volume_name, set_ran
check_volume_data(restored_volume, data)

@pytest.mark.system_backup_restore # NOQA
def test_system_backup_and_restore_volume_with_backingimage(client, volume_name, set_random_backupstore): # NOQA
def test_system_backup_and_restore_volume_with_backingimage(client, core_api, volume_name, set_random_backupstore): # NOQA
"""
Scenario: test system backup and restore volume with backingimage
Expand All @@ -132,6 +138,8 @@ def test_system_backup_and_restore_volume_with_backingimage(client, volume_name,
Given a backingimage
And a volume created with the backingimage
And a PVC for the volume
And a PV for the volume
When system backup created
Then system backup in state Ready
Expand All @@ -141,6 +149,8 @@ def test_system_backup_and_restore_volume_with_backingimage(client, volume_name,
Then system restore should be in state Completed
And wait for backingimage restoration to complete
And wait for volume restoration to complete
And wait for PVC restoration to complete
And wait for PV restoration to complete
And volume should be detached
When attach volume
Expand All @@ -154,6 +164,11 @@ def test_system_backup_and_restore_volume_with_backingimage(client, volume_name,

volume = create_and_check_volume(
client, volume_name, backing_image=BACKING_IMAGE_NAME)
pvc_name = volume_name + "-pvc"
pv_name = volume_name + "-pv"
create_pv_for_volume(client, core_api, volume, pv_name)
create_pvc_for_volume(client, core_api, volume, pvc_name)

volume.attach(hostId=host_id)
volume = wait_for_volume_healthy(client, volume_name)

Expand All @@ -173,10 +188,13 @@ def test_system_backup_and_restore_volume_with_backingimage(client, volume_name,

backing_image = client.by_id_backing_image(BACKING_IMAGE_NAME)
assert backing_image.sourceType == BACKING_IMAGE_SOURCE_TYPE_RESTORE
check_backing_image_disk_map_status(client, BACKING_IMAGE_NAME, 3, "ready")

restored_volume = client.by_id_volume(volume_name)
wait_for_volume_restoration_completed(client, volume_name)
wait_for_volume_detached(client, volume_name)
assert check_pvc_existence(core_api, pvc_name)
assert check_pv_existence(core_api, pv_name)

restored_volume.attach(hostId=host_id)
restored_volume = wait_for_volume_healthy(client, volume_name)
Expand Down

0 comments on commit b854c8d

Please sign in to comment.