Skip to content

Commit 6f39390

Browse files
committed
Added Cross-zone instance creation in test_backup_recovery_nas.py
1 parent bc7055d commit 6f39390

File tree

1 file changed

+55
-34
lines changed

1 file changed

+55
-34
lines changed

test/integration/smoke/test_backup_recovery_nas.py

Lines changed: 55 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
# specific language governing permissions and limitations
1717
# under the License.
1818

19+
from marvin.cloudstackAPI import listZones
1920
from marvin.cloudstackTestCase import cloudstackTestCase
2021
from marvin.lib.utils import (cleanup_resources)
2122
from marvin.lib.base import (Account, ServiceOffering, DiskOffering, VirtualMachine, BackupOffering,
@@ -109,40 +110,7 @@ def tearDown(self):
109110
except Exception as e:
110111
raise Exception("Warning: Exception during cleanup : %s" % e)
111112

112-
@attr(tags=["advanced", "backup"], required_hardware="true")
113-
def test_vm_backup_lifecycle(self):
114-
"""
115-
Test VM backup lifecycle
116-
"""
117-
118-
# Verify there are no backups for the VM
119-
backups = Backup.list(self.apiclient, self.vm.id)
120-
self.assertEqual(backups, None, "There should not exist any backup for the VM")
121-
122-
# Assign VM to offering and create ad-hoc backup
123-
self.backup_offering.assignOffering(self.apiclient, self.vm.id)
124-
Backup.create(self.apiclient, self.vm.id)
125-
126-
# Verify backup is created for the VM
127-
backups = Backup.list(self.apiclient, self.vm.id)
128-
self.assertEqual(len(backups), 1, "There should exist only one backup for the VM")
129-
backup = backups[0]
130-
131-
# Delete backup
132-
Backup.delete(self.apiclient, backup.id)
133-
134-
# Verify backup is deleted
135-
backups = Backup.list(self.apiclient, self.vm.id)
136-
self.assertEqual(backups, None, "There should not exist any backup for the VM")
137-
138-
# Remove VM from offering
139-
self.backup_offering.removeOffering(self.apiclient, self.vm.id)
140-
141-
@attr(tags=["advanced", "backup"], required_hardware="true")
142-
def test_vm_backup_create_vm_from_backup(self):
143-
"""
144-
Test creating a new VM from a backup
145-
"""
113+
def vm_backup_create_vm_from_backup_int(self, destination_zone):
146114
self.backup_offering.assignOffering(self.apiclient, self.vm.id)
147115

148116
# Create a file and take backup
@@ -217,3 +185,56 @@ def test_vm_backup_create_vm_from_backup(self):
217185
# Delete backups
218186
Backup.delete(self.apiclient, backups[0].id)
219187
Backup.delete(self.apiclient, backups[1].id)
188+
189+
@attr(tags=["advanced", "backup"], required_hardware="true")
190+
def test_vm_backup_lifecycle(self):
191+
"""
192+
Test VM backup lifecycle
193+
"""
194+
195+
# Verify there are no backups for the VM
196+
backups = Backup.list(self.apiclient, self.vm.id)
197+
self.assertEqual(backups, None, "There should not exist any backup for the VM")
198+
199+
# Assign VM to offering and create ad-hoc backup
200+
self.backup_offering.assignOffering(self.apiclient, self.vm.id)
201+
Backup.create(self.apiclient, self.vm.id)
202+
203+
# Verify backup is created for the VM
204+
backups = Backup.list(self.apiclient, self.vm.id)
205+
self.assertEqual(len(backups), 1, "There should exist only one backup for the VM")
206+
backup = backups[0]
207+
208+
# Delete backup
209+
Backup.delete(self.apiclient, backup.id)
210+
211+
# Verify backup is deleted
212+
backups = Backup.list(self.apiclient, self.vm.id)
213+
self.assertEqual(backups, None, "There should not exist any backup for the VM")
214+
215+
# Remove VM from offering
216+
self.backup_offering.removeOffering(self.apiclient, self.vm.id)
217+
218+
@attr(tags=["advanced", "backup"], required_hardware="true")
219+
def test_vm_backup_create_vm_from_backup(self):
220+
"""
221+
Test creating a new VM from a backup
222+
"""
223+
self.vm_backup_create_vm_from_backup_int(self.zone.id)
224+
225+
@attr(tags=["advanced", "backup"], required_hardware="true")
226+
def test_vm_backup_create_vm_from_backup_in_another_zone(self):
227+
"""
228+
Test creating a new VM from a backup in another zone
229+
"""
230+
cmd = listZones.listZonesCmd()
231+
zones = self.apiclient.listZones(cmd)
232+
if not isinstance(zones, list):
233+
raise Exception("Failed to find zones.")
234+
if len(zones) < 2:
235+
self.skipTest("Skipping test due to there are less than two zones.")
236+
return
237+
238+
self.destZone = zones[1]
239+
240+
self.vm_backup_create_vm_from_backup_int(self.destZone)

0 commit comments

Comments
 (0)