Skip to content

Commit b84b654

Browse files
committed
test: additional check to ensure hosts are left in up state
Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
1 parent 64ecd00 commit b84b654

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

test/integration/smoke/test_vm_life_cycle.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,8 +1011,36 @@ def setUpClass(cls):
10111011

10121012
@classmethod
10131013
def tearDownClass(cls):
1014+
cls.ensure_all_hosts_are_up()
10141015
super(TestSecuredVmMigration, cls).tearDownClass()
10151016

1017+
@classmethod
1018+
def ensure_all_hosts_are_up(cls):
1019+
hosts = Host.list(
1020+
cls.apiclient,
1021+
zoneid=cls.zone.id,
1022+
type='Routing',
1023+
hypervisor='KVM'
1024+
)
1025+
for host in hosts:
1026+
if host.state != "Up":
1027+
SshClient(host.ipaddress, port=22, user=cls.hostConfig["username"], passwd=cls.hostConfig["password"]) \
1028+
.execute("service cloudstack-agent stop ; \
1029+
sleep 10 ; \
1030+
service cloudstack-agent start")
1031+
interval = 5
1032+
retries = 10
1033+
while retries > -1:
1034+
time.sleep(interval)
1035+
restarted_host = Host.list(
1036+
cls.apiclient,
1037+
hostid=host.id,
1038+
type='Routing'
1039+
)[0]
1040+
if restarted_host.state == state:
1041+
break
1042+
retries = retries - 1
1043+
10161044
def setUp(self):
10171045
self.apiclient = self.testClient.getApiClient()
10181046
self.dbclient = self.testClient.getDbConnection()

0 commit comments

Comments
 (0)