Skip to content

Commit

Permalink
Update VM IP after restore replace
Browse files Browse the repository at this point in the history
  • Loading branch information
albinsun authored and khushboo-rancher committed Aug 28, 2024
1 parent 958ff03 commit 5021574
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions harvester_e2e_tests/integrations/test_4_vm_backup_restore.py
Original file line number Diff line number Diff line change
Expand Up @@ -480,8 +480,18 @@ def test_restore_replace_with_delete_vols(
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)

endtime = datetime.now() + timedelta(seconds=wait_timeout)
while endtime > datetime.now():
code, data = api_client.vms.get(unique_vm_name)
if 200 == code and "Running" == data.get('status', {}).get('printableStatus'):
break
sleep(3)
else:
raise AssertionError(
f"Failed to restore VM({unique_vm_name}) with errors:\n"
f"Status({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 All @@ -495,6 +505,7 @@ def test_restore_replace_with_delete_vols(
code, data = api_client.hosts.get(data['status']['nodeName'])
host_ip = next(addr['address'] for addr in data['status']['addresses']
if addr['type'] == 'InternalIP')
base_vm_with_data['host_ip'], base_vm_with_data['vm_ip'] = host_ip, vm_ip

# Login to the new VM and check data is existing
with vm_shell_from_host(host_ip, vm_ip, base_vm_with_data['ssh_user'], pkey=pri_key) as sh:
Expand Down

0 comments on commit 5021574

Please sign in to comment.