Skip to content

Commit d83d994

Browse files
authored
test: additional check to ensure hosts are left in up state (#8383)
With this change, a fix is added for failures seen with test_08_migrate_vm or other migration-related tests because the target host is in `Connecting` state, #8356 (comment) #8374 (comment) and more
1 parent 9d3a7be commit d83d994

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

test/integration/smoke/test_vm_life_cycle.py

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

10121012
@classmethod
10131013
def tearDownClass(cls):
1014+
if cls.hypervisor.lower() in ["kvm"]:
1015+
cls.ensure_all_hosts_are_up()
10141016
super(TestSecuredVmMigration, cls).tearDownClass()
10151017

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

0 commit comments

Comments
 (0)