CLOUDSTACK-7223: Wait for system VM agent state to be up before verification

Signed-off-by: Santhosh Edukulla <santhosh.edukulla@gmail.com>
This commit is contained in:
John Dilley 2014-08-04 14:48:43 +00:00 committed by Santhosh Edukulla
parent b73fe32519
commit 0c77b2007e

View File

@ -50,6 +50,25 @@ class TestSSVMs(cloudstackTestCase):
raise Exception("Warning: Exception during cleanup : %s" % e)
return
def waitForSystemVMAgent(self, vmname):
timeout = self.services["timeout"]
while True:
list_host_response = list_hosts(
self.apiclient,
name=vmname
)
if list_host_response and list_host_response[0].state == 'Up':
break
if timeout == 0:
raise Exception("Timed out waiting for SSVM agent to be Up")
time.sleep(self.services["sleep"])
timeout = timeout - 1
@attr(tags = ["advanced", "advancedns", "smoke", "basic", "sg"], required_hardware="false")
def test_01_list_sec_storage_vm(self):
"""Test List secondary storage VMs
@ -517,9 +536,6 @@ class TestSSVMs(cloudstackTestCase):
cmd.id = ssvm.id
self.apiclient.stopSystemVm(cmd)
# Sleep to ensure that VM is in proper state
time.sleep(self.services["sleep"])
timeout = self.services["timeout"]
while True:
list_ssvm_response = list_ssvms(
@ -529,7 +545,7 @@ class TestSSVMs(cloudstackTestCase):
if isinstance(list_ssvm_response, list):
if list_ssvm_response[0].state == 'Running':
break
elif timeout == 0:
if timeout == 0:
raise Exception("List SSVM call failed!")
time.sleep(self.services["sleep"])
@ -547,6 +563,9 @@ class TestSSVMs(cloudstackTestCase):
'Running',
"Check whether SSVM is running or not"
)
# Wait for the agent to be up
self.waitForSystemVMAgent(ssvm_response.name)
# Call above tests to ensure SSVM is properly running
self.test_01_list_sec_storage_vm()
self.test_03_ssvm_internals()
@ -593,9 +612,6 @@ class TestSSVMs(cloudstackTestCase):
cmd.id = cpvm.id
self.apiclient.stopSystemVm(cmd)
# Sleep to ensure that VM is in proper state
time.sleep(self.services["sleep"])
timeout = self.services["timeout"]
while True:
list_cpvm_response = list_ssvms(
@ -605,7 +621,7 @@ class TestSSVMs(cloudstackTestCase):
if isinstance(list_cpvm_response, list):
if list_cpvm_response[0].state == 'Running':
break
elif timeout == 0:
if timeout == 0:
raise Exception("List CPVM call failed!")
time.sleep(self.services["sleep"])
@ -620,6 +636,10 @@ class TestSSVMs(cloudstackTestCase):
'Running',
"Check whether CPVM is running or not"
)
# Wait for the agent to be up
self.waitForSystemVMAgent(cpvm_response.name)
# Call above tests to ensure CPVM is properly running
self.test_02_list_cpvm_vm()
self.test_04_cpvm_internals()
@ -670,9 +690,6 @@ class TestSSVMs(cloudstackTestCase):
cmd.id = ssvm_response.id
self.apiclient.rebootSystemVm(cmd)
# Sleep to ensure that VM is in proper state
time.sleep(self.services["sleep"])
timeout = self.services["timeout"]
while True:
list_ssvm_response = list_ssvms(
@ -682,7 +699,7 @@ class TestSSVMs(cloudstackTestCase):
if isinstance(list_ssvm_response, list):
if list_ssvm_response[0].state == 'Running':
break
elif timeout == 0:
if timeout == 0:
raise Exception("List SSVM call failed!")
time.sleep(self.services["sleep"])
@ -707,6 +724,10 @@ class TestSSVMs(cloudstackTestCase):
old_private_ip,
"Check Private IP after reboot with that of before reboot"
)
# Wait for the agent to be up
self.waitForSystemVMAgent(ssvm_response.name)
#Call to verify cloud process is running
self.test_03_ssvm_internals()
return
@ -756,9 +777,6 @@ class TestSSVMs(cloudstackTestCase):
cmd.id = cpvm_response.id
self.apiclient.rebootSystemVm(cmd)
# Sleep to ensure that VM is in proper state
time.sleep(self.services["sleep"])
timeout = self.services["timeout"]
while True:
list_cpvm_response = list_ssvms(
@ -768,7 +786,7 @@ class TestSSVMs(cloudstackTestCase):
if isinstance(list_cpvm_response, list):
if list_cpvm_response[0].state == 'Running':
break
elif timeout == 0:
if timeout == 0:
raise Exception("List CPVM call failed!")
time.sleep(self.services["sleep"])
@ -794,6 +812,9 @@ class TestSSVMs(cloudstackTestCase):
old_private_ip,
"Check Private IP after reboot with that of before reboot"
)
# Wait for the agent to be up
self.waitForSystemVMAgent(cpvm_response.name)
#Call to verify cloud process is running
self.test_04_cpvm_internals()
return
@ -830,9 +851,6 @@ class TestSSVMs(cloudstackTestCase):
cmd.id = ssvm_response.id
self.apiclient.destroySystemVm(cmd)
# Sleep to ensure that VM is in proper state
time.sleep(self.services["sleep"])
timeout = self.services["timeout"]
while True:
list_ssvm_response = list_ssvms(
@ -843,7 +861,7 @@ class TestSSVMs(cloudstackTestCase):
if isinstance(list_ssvm_response, list):
if list_ssvm_response[0].state == 'Running':
break
elif timeout == 0:
if timeout == 0:
raise Exception("List SSVM call failed!")
time.sleep(self.services["sleep"])
@ -876,6 +894,9 @@ class TestSSVMs(cloudstackTestCase):
"Check whether SSVM has public IP field"
)
# Wait for the agent to be up
self.waitForSystemVMAgent(ssvm_response.name)
#Call to verify cloud process is running
self.test_03_ssvm_internals()
return
@ -911,9 +932,6 @@ class TestSSVMs(cloudstackTestCase):
cmd.id = cpvm_response.id
self.apiclient.destroySystemVm(cmd)
# Sleep to ensure that VM is in proper state
time.sleep(self.services["sleep"])
timeout = self.services["timeout"]
while True:
list_cpvm_response = list_ssvms(
@ -924,7 +942,7 @@ class TestSSVMs(cloudstackTestCase):
if isinstance(list_cpvm_response, list):
if list_cpvm_response[0].state == 'Running':
break
elif timeout == 0:
if timeout == 0:
raise Exception("List CPVM call failed!")
time.sleep(self.services["sleep"])
@ -957,6 +975,9 @@ class TestSSVMs(cloudstackTestCase):
"Check whether CPVM has public IP field"
)
# Wait for the agent to be up
self.waitForSystemVMAgent(cpvm_response.name)
#Call to verify cloud process is running
self.test_04_cpvm_internals()
return