|
17 | 17 | """ BVT tests for Hosts Maintenance |
18 | 18 | """ |
19 | 19 |
|
| 20 | +# Import Local Modules |
| 21 | +from marvin.codes import FAILED |
20 | 22 | from marvin.cloudstackTestCase import * |
| 23 | +from marvin.cloudstackAPI import * |
21 | 24 | from marvin.lib.utils import * |
22 | 25 | from marvin.lib.base import * |
23 | 26 | from marvin.lib.common import * |
24 | 27 | from nose.plugins.attrib import attr |
25 | 28 |
|
| 29 | +from time import sleep |
| 30 | + |
26 | 31 | _multiprocess_shared_ = False |
27 | 32 |
|
28 | 33 |
|
29 | 34 | class TestHostHA(cloudstackTestCase): |
30 | 35 |
|
31 | | - hostCountMsg = "Host HA can be tested with at least two hosts, only %s found" |
32 | | - |
33 | 36 | def setUp(self): |
34 | 37 | self.logger = logging.getLogger('TestHM') |
35 | 38 | self.stream_handler = logging.StreamHandler() |
@@ -83,8 +86,17 @@ def setUp(self): |
83 | 86 | "timeout": 10, |
84 | 87 | } |
85 | 88 |
|
| 89 | + |
86 | 90 | def tearDown(self): |
87 | | - super(TestHostHA, self).tearDown() |
| 91 | + try: |
| 92 | + # Clean up, terminate the created templates |
| 93 | + cleanup_resources(self.apiclient, self.cleanup) |
| 94 | + |
| 95 | + except Exception as e: |
| 96 | + raise Exception("Warning: Exception during cleanup : %s" % e) |
| 97 | + |
| 98 | + return |
| 99 | + |
88 | 100 |
|
89 | 101 | def createVMs(self, hostId, number, local): |
90 | 102 |
|
@@ -307,16 +319,19 @@ def test_01_host_ha_with_nfs_storagepool_with_vm(self): |
307 | 319 | for host in listHost: |
308 | 320 | self.logger.debug('Hypervisor = {}'.format(host.id)) |
309 | 321 |
|
310 | | - if len(listHost) < 2: |
311 | | - self.logger.debug(self.hostCountMsg % len(listHost)) |
312 | | - raise unittest.SkipTest(self.hostCountMsg % len(listHost)) |
| 322 | + |
| 323 | + if len(listHost) != 2: |
| 324 | + self.logger.debug("Host HA can be tested with two host only %s, found" % len(listHost)) |
| 325 | + raise unittest.SkipTest("Host HA can be tested with two host only %s, found" % len(listHost)) |
| 326 | + |
313 | 327 |
|
314 | 328 | no_of_vms = self.noOfVMsOnHost(listHost[0].id) |
315 | 329 |
|
316 | 330 | no_of_vms = no_of_vms + self.noOfVMsOnHost(listHost[1].id) |
317 | 331 |
|
318 | 332 | self.logger.debug("Number of VMS on hosts = %s" % no_of_vms) |
319 | 333 |
|
| 334 | + |
320 | 335 | if no_of_vms < 5: |
321 | 336 | self.logger.debug("test_01: Create VMs as there are not enough vms to check host ha") |
322 | 337 | no_vm_req = 5 - no_of_vms |
@@ -381,9 +396,10 @@ def test_02_host_ha_with_local_storage_and_nfs(self): |
381 | 396 | for host in listHost: |
382 | 397 | self.logger.debug('Hypervisor = {}'.format(host.id)) |
383 | 398 |
|
384 | | - if len(listHost) < 2: |
385 | | - self.logger.debug(self.hostCountMsg % len(listHost)) |
386 | | - raise unittest.SkipTest(self.hostCountMsg % len(listHost)) |
| 399 | + |
| 400 | + if len(listHost) != 2: |
| 401 | + self.logger.debug("Host HA can be tested with two host only %s, found" % len(listHost)) |
| 402 | + raise unittest.SkipTest("Host HA can be tested with two host only %s, found" % len(listHost)) |
387 | 403 |
|
388 | 404 | no_of_vms = self.noOfVMsOnHost(listHost[0].id) |
389 | 405 |
|
@@ -457,9 +473,10 @@ def test_03_host_ha_with_only_local_storage(self): |
457 | 473 | for host in listHost: |
458 | 474 | self.logger.debug('Hypervisor = {}'.format(host.id)) |
459 | 475 |
|
460 | | - if len(listHost) < 2: |
461 | | - self.logger.debug(self.hostCountMsg % len(listHost)) |
462 | | - raise unittest.SkipTest(self.hostCountMsg % len(listHost)) |
| 476 | + |
| 477 | + if len(listHost) != 2: |
| 478 | + self.logger.debug("Host HA can be tested with two host only %s, found" % len(listHost)) |
| 479 | + raise unittest.SkipTest("Host HA can be tested with two host only %s, found" % len(listHost)) |
463 | 480 |
|
464 | 481 | no_of_vms = self.noOfVMsOnHost(listHost[0].id) |
465 | 482 |
|
@@ -531,16 +548,18 @@ def test_04_host_ha_vmactivity_check(self): |
531 | 548 | for host in listHost: |
532 | 549 | self.logger.debug('Hypervisor = {}'.format(host.id)) |
533 | 550 |
|
534 | | - if len(listHost) < 2: |
535 | | - self.logger.debug(self.hostCountMsg % len(listHost)) |
536 | | - raise unittest.SkipTest(self.hostCountMsg % len(listHost)) |
| 551 | + |
| 552 | + if len(listHost) != 2: |
| 553 | + self.logger.debug("Host HA can be tested with two host only %s, found" % len(listHost)) |
| 554 | + raise unittest.SkipTest("Host HA can be tested with two host only %s, found" % len(listHost)) |
537 | 555 |
|
538 | 556 | no_of_vms = self.noOfVMsOnHost(listHost[0].id) |
539 | 557 |
|
540 | 558 | no_of_vms = no_of_vms + self.noOfVMsOnHost(listHost[1].id) |
541 | 559 |
|
542 | 560 | self.logger.debug("Number of VMS on hosts = %s" % no_of_vms) |
543 | 561 |
|
| 562 | + |
544 | 563 | if no_of_vms < 5: |
545 | 564 | self.logger.debug("test_01: Create VMs as there are not enough vms to check host ha") |
546 | 565 | no_vm_req = 5 - no_of_vms |
|
0 commit comments