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