marvin: fix test failures when changing service offering of a VM (#4651)

Co-authored-by: Pearl Dsilva <pearl.dsilva@shapeblue.com>
This commit is contained in:
Pearl Dsilva 2021-02-05 18:12:12 +05:30 committed by GitHub
parent d62d5c6cd2
commit c9c1d4a6e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 41 additions and 0 deletions

View File

@ -502,6 +502,23 @@ class TestServiceOfferings(cloudstackTestCase):
self.skipTest("Skipping this test for {} due to bug CS-38153".format(self.hypervisor))
try:
self.medium_virtual_machine.stop(self.apiclient)
timeout = self.services["timeout"]
while True:
time.sleep(self.services["sleep"])
# Ensure that VM is in stopped state
list_vm_response = list_virtual_machines(
self.apiclient,
id=self.medium_virtual_machine.id
)
if isinstance(list_vm_response, list):
vm = list_vm_response[0]
if vm.state == 'Stopped':
self.debug("VM state: %s" % vm.state)
break
if timeout == 0:
raise Exception(
"Failed to stop VM (ID: %s) in change service offering" % vm.id)
timeout = timeout - 1
except Exception as e:
self.fail("Failed to stop VM: %s" % e)

View File

@ -454,6 +454,30 @@ class TestChangeServiceOfferingForVmWithSnapshots(cloudstackTestCase):
self.debug("Stopping VM - ID: %s" % virtual_machine.id)
try:
virtual_machine.stop(self.apiclient)
timeout = self.services["timeout"]
while True:
time.sleep(self.services["sleep"])
# Ensure that VM is in stopped state
list_vm_response = list_virtual_machines(
self.apiclient,
id=virtual_machine.id
)
if isinstance(list_vm_response, list):
vm = list_vm_response[0]
if vm.state == 'Stopped':
self.debug("VM state: %s" % vm.state)
break
if timeout == 0:
raise Exception(
"Failed to stop VM (ID: %s) in change service offering" % vm.id)
timeout = timeout - 1
except Exception as e:
self.fail("Failed to stop VM: %s" % e)