Skip to content

Commit

Permalink
Update with review request part1
Browse files Browse the repository at this point in the history
  • Loading branch information
TachunLin committed Sep 13, 2024
1 parent 206612a commit 534f329
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions harvester_e2e_tests/integrations/test_4_vm_backup_restore.py
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,8 @@ def test_restore_replace_with_vm_shutdown_command(
spec = api_client.backups.RestoreSpec.for_existing(delete_volumes=True)
code, data = api_client.backups.restore(unique_vm_name, spec)
assert 201 == code, f'Failed to restore backup with current VM replaced, {data}'
vm_getable, (code, data) = vm_checker.wait_getable(unique_vm_name)
assert vm_getable, (code, data)

# Check VM Started then get IPs (vm and host)
vm_got_ips, (code, data) = vm_checker.wait_ip_addresses(unique_vm_name, ['default'])
Expand Down Expand Up @@ -652,25 +654,26 @@ def test_with_snapshot_restore_with_new_vm(
while deadline > datetime.now():
code, data = api_client.vm_snapshots.get(vm_snapshot_name)
if data.get("status", {}).get("readyToUse"):
assert 200 == code
break
print(f"waiting for {vm_snapshot_name} to be ready")
sleep(3)
else:
raise AssertionError(f"timed out waiting for {vm_snapshot_name} to be ready")

assert 200 == code
assert data.get("status", {}).get("readyToUse") is True
raise AssertionError(
f"timed out waiting for {vm_snapshot_name} to be ready:\n"
f"Status({code}): {data}"
)

vm_running, (code, data) = vm_checker.wait_status_running(unique_vm_name)
assert vm_running, (
f"Failed to restore VM({unique_vm_name}) with errors:\n"
f"Status({code}): {data}"
)

# Check VM Started then get IPs (vm and host)
# Check VM is still running and can get IPs (vm and host)
vm_got_ips, (code, data) = vm_checker.wait_ip_addresses(unique_vm_name, ['default'])
assert vm_got_ips, (
f"Failed to Start VM({unique_vm_name}) with errors:\n"
f"Failed to check the VM({unique_vm_name}) is sill in running state:\n"
f"Status: {data.get('status')}\n"
f"API Status({code}): {data}"
)
Expand Down Expand Up @@ -771,25 +774,26 @@ def test_with_snapshot_restore_replace_retain_vols(
while deadline > datetime.now():
code, data = api_client.vm_snapshots.get(vm_snapshot_name)
if data.get("status", {}).get("readyToUse"):
assert 200 == code
break
print(f"waiting for {vm_snapshot_name} to be ready")
sleep(3)
else:
raise AssertionError(f"timed out waiting for {vm_snapshot_name} to be ready")

assert 200 == code
assert data.get("status", {}).get("readyToUse") is True
raise AssertionError(
f"timed out waiting for {vm_snapshot_name} to be ready:\n"
f"Status({code}): {data}"
)

vm_running, (code, data) = vm_checker.wait_status_running(unique_vm_name)
assert vm_running, (
f"Failed to restore VM({unique_vm_name}) with errors:\n"
f"Status({code}): {data}"
)

# Check VM Started then get IPs (vm and host)
# Check VM is still running and can get IPs (vm and host)
vm_got_ips, (code, data) = vm_checker.wait_ip_addresses(unique_vm_name, ['default'])
assert vm_got_ips, (
f"Failed to Start VM({unique_vm_name}) with errors:\n"
f"Failed to check the VM({unique_vm_name}) is sill in running state:\n"
f"Status: {data.get('status')}\n"
f"API Status({code}): {data}"
)
Expand Down

0 comments on commit 534f329

Please sign in to comment.