diff options
author | Cédric Ollivier <cedric.ollivier@orange.com> | 2019-10-06 20:43:02 +0200 |
---|---|---|
committer | Cédric Ollivier <cedric.ollivier@orange.com> | 2019-10-08 07:23:44 +0200 |
commit | 5d9efdccd75f608c7a7a1aaf1a9c1b9b811023d3 (patch) | |
tree | ac5533ba3476020b0ef22834aa57d86e590f4882 | |
parent | 476f454c79a120320080473865b1872d7ca3f1e4 (diff) |
Count all hypervisors by default
If one hypervisor is down, few tempest test fails.
User is free to set SKIP_DOWN_HYPERVISORS if it's down on purpose.
Change-Id: I7b6a4d0d8f67755d8c1550fd1bc6fd707634f68b
Signed-off-by: Cédric Ollivier <cedric.ollivier@orange.com>
(cherry picked from commit 7332716dc835cd72b0beefc38afda2697bd99e02)
-rw-r--r-- | functest/core/singlevm.py | 9 | ||||
-rw-r--r-- | functest/opnfv_tests/openstack/rally/rally.py | 2 | ||||
-rw-r--r-- | functest/opnfv_tests/openstack/shaker/shaker.py | 2 | ||||
-rw-r--r-- | functest/opnfv_tests/openstack/tempest/tempest.py | 2 | ||||
-rw-r--r-- | functest/opnfv_tests/openstack/vmtp/vmtp.py | 2 | ||||
-rw-r--r-- | functest/tests/unit/openstack/rally/test_rally.py | 2 | ||||
-rw-r--r-- | functest/utils/env.py | 3 |
7 files changed, 16 insertions, 6 deletions
diff --git a/functest/core/singlevm.py b/functest/core/singlevm.py index 734eb22d5..5ecd482ac 100644 --- a/functest/core/singlevm.py +++ b/functest/core/singlevm.py @@ -256,12 +256,21 @@ class VmReady1(tenantnetwork.TenantNetwork1): self.__logger.debug( "Orphan security group %s in use", sec_group.id) + def count_hypervisors(self): + """Count hypervisors.""" + if env.get('SKIP_DOWN_HYPERVISORS').lower() == 'false': + return len(self.orig_cloud.list_hypervisors()) + return self.count_active_hypervisors() + def count_active_hypervisors(self): """Count all hypervisors which are up.""" compute_cnt = 0 for hypervisor in self.orig_cloud.list_hypervisors(): if hypervisor['state'] == 'up': compute_cnt += 1 + else: + self.__logger.warning( + "%s is down", hypervisor['hypervisor_hostname']) return compute_cnt def run(self, **kwargs): diff --git a/functest/opnfv_tests/openstack/rally/rally.py b/functest/opnfv_tests/openstack/rally/rally.py index 5487e21aa..d3b82b789 100644 --- a/functest/opnfv_tests/openstack/rally/rally.py +++ b/functest/opnfv_tests/openstack/rally/rally.py @@ -518,7 +518,7 @@ class RallyBase(singlevm.VmReady2): shutil.copytree(task_macro, macro_dir) self.update_keystone_default_role() - self.compute_cnt = self.count_active_hypervisors() + self.compute_cnt = self.count_hypervisors() self.network_extensions = self.cloud.get_network_extensions() self.flavor_alt = self.create_flavor_alt() self.services = [service.name for service in diff --git a/functest/opnfv_tests/openstack/shaker/shaker.py b/functest/opnfv_tests/openstack/shaker/shaker.py index 36706704f..9d8a13274 100644 --- a/functest/opnfv_tests/openstack/shaker/shaker.py +++ b/functest/opnfv_tests/openstack/shaker/shaker.py @@ -48,7 +48,7 @@ class Shaker(singlevm.SingleVm2): self.role = None def check_requirements(self): - if self.count_active_hypervisors() < 2: + if self.count_hypervisors() < 2: self.__logger.warning("Shaker requires at least 2 hypervisors") self.is_skipped = True self.project.clean() diff --git a/functest/opnfv_tests/openstack/tempest/tempest.py b/functest/opnfv_tests/openstack/tempest/tempest.py index 6d13bd206..908d3bc16 100644 --- a/functest/opnfv_tests/openstack/tempest/tempest.py +++ b/functest/opnfv_tests/openstack/tempest/tempest.py @@ -567,7 +567,7 @@ class TempestCommon(singlevm.VmReady2): self.deployment_dir = self.get_verifier_deployment_dir( self.verifier_id, self.deployment_id) - compute_cnt = self.count_active_hypervisors() + compute_cnt = self.count_hypervisors() self.image_alt = self.publish_image_alt() self.flavor_alt = self.create_flavor_alt() LOGGER.debug("flavor: %s", self.flavor_alt) diff --git a/functest/opnfv_tests/openstack/vmtp/vmtp.py b/functest/opnfv_tests/openstack/vmtp/vmtp.py index fa83c4522..dc480c4f3 100644 --- a/functest/opnfv_tests/openstack/vmtp/vmtp.py +++ b/functest/opnfv_tests/openstack/vmtp/vmtp.py @@ -60,7 +60,7 @@ class Vmtp(singlevm.VmReady2): (_, self.pubkey_filename) = tempfile.mkstemp() def check_requirements(self): - if self.count_active_hypervisors() < 2: + if self.count_hypervisors() < 2: self.__logger.warning("Vmtp requires at least 2 hypervisors") self.is_skipped = True self.project.clean() diff --git a/functest/tests/unit/openstack/rally/test_rally.py b/functest/tests/unit/openstack/rally/test_rally.py index c430e9794..ae3c3976b 100644 --- a/functest/tests/unit/openstack/rally/test_rally.py +++ b/functest/tests/unit/openstack/rally/test_rally.py @@ -291,7 +291,7 @@ class OSRallyTesting(unittest.TestCase): def test_prepare_run_flavor_alt_creation_failed(self, *args): # pylint: disable=unused-argument self.rally_base.stests = ['test1', 'test2'] - with mock.patch.object(self.rally_base, 'count_active_hypervisors') \ + with mock.patch.object(self.rally_base, 'count_hypervisors') \ as mock_list_hyperv, \ mock.patch.object(self.rally_base, 'create_flavor_alt', side_effect=Exception) \ diff --git a/functest/utils/env.py b/functest/utils/env.py index 8c003092d..dec9b0e71 100644 --- a/functest/utils/env.py +++ b/functest/utils/env.py @@ -36,7 +36,8 @@ INPUTS = { 'NEW_USER_ROLE': 'Member', 'USE_DYNAMIC_CREDENTIALS': 'True', 'BLOCK_MIGRATION': 'True', - 'CLEAN_ORPHAN_SECURITY_GROUPS': 'True' + 'CLEAN_ORPHAN_SECURITY_GROUPS': 'True', + 'SKIP_DOWN_HYPERVISORS': 'False' } |