From 09c6030ae9fd759b59634a10e98eb2698a848539 Mon Sep 17 00:00:00 2001 From: Prasanna Santhanam Date: Fri, 24 May 2013 14:23:14 +0530 Subject: [PATCH] Correct the resize volume tests Resize would fail on XenServer if the VM isn't stopped before resizing. Ensuring VM stop based on the hypervisor host detected that the VM is resident on. Signed-off-by: Prasanna Santhanam --- test/integration/smoke/test_volumes.py | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/test/integration/smoke/test_volumes.py b/test/integration/smoke/test_volumes.py index 7987136f88e..d9c808a01d9 100644 --- a/test/integration/smoke/test_volumes.py +++ b/test/integration/smoke/test_volumes.py @@ -536,7 +536,7 @@ class TestVolumes(cloudstackTestCase): @attr(tags = ["advanced", "advancedns", "smoke", "basic"]) def test_07_resize_fail(self): - """Verify invalid options fail to Resize a volume""" + """Test resize (negative) non-existent volume""" # Verify the size is the new size is what we wanted it to be. self.debug("Fail Resize Volume ID: %s" % self.volume.id) @@ -584,7 +584,12 @@ class TestVolumes(cloudstackTestCase): self.virtual_machine.attach_volume(self.apiClient, self.volume) self.attached = True #stop the vm if it is on xenserver - if self.services['hypervisor'].lower() == "xenserver": + hosts = Host.list(self.apiClient, id=self.virtual_machine.hostid) + self.assertTrue(isinstance(hosts, list)) + self.assertTrue(len(hosts) > 0) + self.debug("Found %s host" % hosts[0].hypervisor) + + if hosts[0].hypervisor == "XenServer": self.virtual_machine.stop(self.apiClient) self.apiClient.resizeVolume(cmd) @@ -610,23 +615,28 @@ class TestVolumes(cloudstackTestCase): True, "Verify the volume did not resize" ) - if self.services['hypervisor'].lower() == "xenserver": + if hosts[0].hypervisor == "XenServer": self.virtual_machine.start(self.apiClient) @attr(tags = ["advanced", "advancedns", "smoke", "basic"]) def test_08_resize_volume(self): - """Resize a volume""" + """Test resize a volume""" # Verify the size is the new size is what we wanted it to be. self.debug( "Attaching volume (ID: %s) to VM (ID: %s)" % ( self.volume.id, self.virtual_machine.id )) + self.virtual_machine.attach_volume(self.apiClient, self.volume) self.attached = True + hosts = Host.list(self.apiClient, id=self.virtual_machine.hostid) + self.assertTrue(isinstance(hosts, list)) + self.assertTrue(len(hosts) > 0) + self.debug("Found %s host" % hosts[0].hypervisor) - if self.services['hypervisor'].lower() == "xenserver": + if hosts[0].hypervisor == "XenServer": self.virtual_machine.stop(self.apiClient) self.debug("Resize Volume ID: %s" % self.volume.id) @@ -659,7 +669,9 @@ class TestVolumes(cloudstackTestCase): "Check if the volume resized appropriately" ) - if self.services['hypervisor'].lower() == "xenserver": + #start the vm if it is on xenserver + + if hosts[0].hypervisor == "XenServer": self.virtual_machine.start(self.apiClient) @attr(tags = ["advanced", "advancedns", "smoke","basic"])