Skip to content

Commit 0fd5475

Browse files
author
SrikanteswaraRao Talluri
committed
Merge branch '4.5'
* 4.5: CLOUDSTACK-7885 : Fixed the script '/maint/test_vpc_host_maintenance.py' CLOUDSTACK-7860: test_eip_elb.py - Move Netscler info out of the test case. Read it from config. Fix attribute error. Fix pep8 issues. Fix imports.
2 parents a60b729 + f92fa42 commit 0fd5475

2 files changed

Lines changed: 867 additions & 757 deletions

File tree

‎test/integration/component/maint/test_vpc_host_maintenance.py‎

Lines changed: 96 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
get_zone,
3737
get_template,
3838
wait_for_cleanup)
39+
import time
3940

4041

4142
class Services:
@@ -190,7 +191,7 @@ def __init__(self):
190191
"ostype": 'CentOS 5.3 (64-bit)',
191192
# Cent OS 5.3 (64 bit)
192193
"sleep": 60,
193-
"timeout": 10,
194+
"timeout": 30,
194195
"mode": 'advanced'
195196
}
196197

@@ -376,7 +377,7 @@ def setUp(self):
376377

377378
self.router = routers[0]
378379
if self.router.state == "Running":
379-
Router.stop(self.apiclient, id=self.router.id)
380+
self.debug("Verified that the Router is in Running State")
380381

381382
self.cleanup = []
382383
return
@@ -448,6 +449,9 @@ def test_01_enable_maintenance_with_vpc_nw(self):
448449
# 2. VMs present on the above host should successfully migrate to the
449450
# other host present in the cluster
450451

452+
Host.update(self.apiclient, id=self.hosts[0].id, hosttags="hosttag1,hosttag2")
453+
Host.update(self.apiclient, id=self.hosts[1].id, hosttags="hosttag1,hosttag2")
454+
451455
self.validate_vm_deployment()
452456
self.debug("Stop the host on which the VPC virtual router is running")
453457
try:
@@ -468,12 +472,34 @@ def test_01_enable_maintenance_with_vpc_nw(self):
468472
True,
469473
"List routers shall return a valid VPCVR for account"
470474
)
471-
for router in routers:
472-
self.assertEqual(
473-
router.state,
474-
"Running",
475-
"Router state should be running after migration"
476-
)
475+
476+
router = routers[0]
477+
478+
try:
479+
480+
timeout = self.services["timeout"]
481+
self.debug("Timeout Value %d : " % timeout)
482+
while True:
483+
list_router_response = Router.list(
484+
self.apiclient,
485+
id = router.id,
486+
state = "Running"
487+
)
488+
489+
if list_router_response is not None:
490+
break
491+
elif timeout == 0:
492+
raise Exception("Router state should be running after migration")
493+
494+
time.sleep(self.services["sleep"])
495+
timeout = timeout - 1
496+
self.debug("Waiting for %d seconds - %d tries left" % (self.services["sleep"],timeout))
497+
498+
self.debug("Verified that the Router is in Running State")
499+
500+
except Exception as e:
501+
self.fail("Failed to find the Router in Running state %s " % e)
502+
477503
vms = VirtualMachine.list(
478504
self.apiclient,
479505
account=self.account.name,
@@ -488,7 +514,7 @@ def test_01_enable_maintenance_with_vpc_nw(self):
488514
for vm in vms:
489515
self.assertEqual(
490516
vm.state,
491-
"Ruuning",
517+
"Running",
492518
"Vm state should be running after migration"
493519
)
494520
return
@@ -506,12 +532,51 @@ def test_02_cancel_maintenance(self):
506532
# 1. Successfully cancel the Maintenance mode on the host.
507533
# 2. Migrate the VMs back successfully onto the host.
508534
# 3. Check that the network connectivity exists with the migrated VMs.
535+
536+
try:
537+
timeout = self.services["timeout"]
538+
while True:
539+
list_host_response = Host.list(
540+
self.apiclient,
541+
id=self.vpcvr.hostid,
542+
resourcestate="Maintenance")
543+
544+
if list_host_response is not None:
545+
break
546+
elif timeout == 0:
547+
raise Exception("Failed to list the Host in Maintenance State")
548+
549+
time.sleep(self.services["sleep"])
550+
timeout = timeout - 1
551+
552+
self.debug("Verified that the Host is in Maintenance State")
553+
554+
except:
555+
self.fail("Failed to find the Host in maintenance state")
509556

510557
self.debug("Cancel host maintenence on which the VPCVR is running")
511558
try:
512559
Host.cancelMaintenance(self.apiclient, id=self.vpcvr.hostid)
560+
561+
timeout = self.services["timeout"]
562+
while True:
563+
list_host_response = Host.list(
564+
self.apiclient,
565+
id=self.vpcvr.hostid,
566+
state="Up")
567+
568+
if list_host_response is not None:
569+
break
570+
elif timeout == 0:
571+
raise Exception("Failed to list the Host in Up State after Canceling Maintenance Mode")
572+
573+
time.sleep(self.services["sleep"])
574+
timeout = timeout - 1
575+
576+
self.debug("Verified that the Host is in Up State after Canceling Maintenance Mode")
577+
513578
except Exception as e:
514-
self.fail("Failed to enable maintenance mode on host: %s" % e)
579+
self.fail("Failed to cancel maintenance mode on host: %s" % e)
515580

516581
self.debug(
517582
"Migrating the instances back to the host: %s" %
@@ -555,6 +620,27 @@ def test_03_reconnect_host(self):
555620
# 2. Network connectivity to all the VMs on the host should not be
556621
# effected due to reconnection.
557622

623+
try:
624+
timeout = self.services["timeout"]
625+
while True:
626+
list_host_response = Host.list(
627+
self.apiclient,
628+
id=self.vpcvr.hostid,
629+
resourcestate="Enabled")
630+
631+
if list_host_response is not None:
632+
break
633+
elif timeout == 0:
634+
raise Exception("Failed to list the Host in Up State")
635+
636+
time.sleep(self.services["sleep"])
637+
timeout = timeout - 1
638+
639+
self.debug("Verified that the Host is in Up State")
640+
641+
except:
642+
self.fail("Failed to find the Host in Up State")
643+
558644
self.debug("Reconnecting the host where VPC VR is running")
559645
try:
560646
Host.reconnect(self.apiclient, id=self.vpcvr.hostid)

0 commit comments

Comments
 (0)