From b9ffaa1a050b878b25788385a30ecbc0a717d82e Mon Sep 17 00:00:00 2001 From: davidtclin Date: Sun, 21 Jul 2024 23:54:16 +0800 Subject: [PATCH] Set specific backup name and check retain volume exists --- .../integrations/test_4_vm_backup_restore.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/harvester_e2e_tests/integrations/test_4_vm_backup_restore.py b/harvester_e2e_tests/integrations/test_4_vm_backup_restore.py index 21e2fe313..d7ae1226c 100644 --- a/harvester_e2e_tests/integrations/test_4_vm_backup_restore.py +++ b/harvester_e2e_tests/integrations/test_4_vm_backup_restore.py @@ -648,20 +648,20 @@ def test_connection(self, api_client, backup_config, config_backup_target): @pytest.mark.dependency(depends=["TestBackupRestoreWithSnapshot::test_connection"], param=True) def tests_backup_vm(self, api_client, wait_timeout, backup_config, base_vm_with_data): unique_vm_name = base_vm_with_data['name'] - + unique_backup_name = f"{unique_vm_name}-backup-with-snapshot" # Create backup with the name as VM's name - code, data = api_client.vms.backup(unique_vm_name, unique_vm_name) + code, data = api_client.vms.backup(unique_vm_name, unique_backup_name) assert 204 == code, (code, data) # Check backup is ready endtime = datetime.now() + timedelta(seconds=wait_timeout) while endtime > datetime.now(): - code, backup = api_client.backups.get(unique_vm_name) + code, backup = api_client.backups.get(unique_backup_name) if 200 == code and backup.get('status', {}).get('readyToUse'): break sleep(3) else: raise AssertionError( - f'Timed-out waiting for the backup \'{unique_vm_name}\' to be ready.' + f'Timed-out waiting for the backup \'{unique_backup_name}\' to be ready.' ) @pytest.mark.dependency(depends=["TestBackupRestoreWithSnapshot::tests_backup_vm"], param=True) @@ -673,6 +673,7 @@ def test_with_snapshot_restore_with_new_vm( pub_key, pri_key = ssh_keypair vm_snapshot_name = unique_vm_name + '-snapshot' + unique_backup_name = f"{unique_vm_name}-backup-with-snapshot" # take vm snapshot code, data = api_client.vm_snapshots.create(unique_vm_name, vm_snapshot_name) assert 201 == code @@ -700,9 +701,9 @@ def test_with_snapshot_restore_with_new_vm( sh.exec_command('sync') # Restore VM into new - restored_vm_name = f"{backup_config[0].lower()}-restore-{unique_vm_name}" + restored_vm_name = f"{backup_config[0].lower()}-restore-{unique_vm_name}-with-snapshot" spec = api_client.backups.RestoreSpec.for_new(restored_vm_name) - code, data = api_client.backups.restore(unique_vm_name, spec) + code, data = api_client.backups.restore(unique_backup_name, spec) assert 201 == code, (code, data) # Check VM Started then get IPs (vm and host) @@ -768,6 +769,7 @@ def test_with_snapshot_restore_replace_retain_vols( pub_key, pri_key = ssh_keypair vm_snapshot_name = unique_vm_name + '-snapshot-retain' + unique_backup_name = f"{unique_vm_name}-backup-with-snapshot" # take vm snapshot code, data = api_client.vm_snapshots.create(unique_vm_name, vm_snapshot_name) assert 201 == code @@ -802,7 +804,7 @@ def test_with_snapshot_restore_replace_retain_vols( ) spec = api_client.backups.RestoreSpec.for_existing(delete_volumes=False) - code, data = api_client.backups.restore(unique_vm_name, spec) + code, data = api_client.backups.restore(unique_backup_name, spec) assert 201 == code, f'Failed to restore backup with current VM replaced, {data}' # Check VM Started then get IPs (vm and host)