From 6afa927455ce4364fee53583c81e00304ef0a0d2 Mon Sep 17 00:00:00 2001 From: Cédric Ollivier Date: Sun, 6 Oct 2019 20:43:02 +0200 Subject: Count all hypervisors by default MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 (cherry picked from commit 7332716dc835cd72b0beefc38afda2697bd99e02) --- functest/core/singlevm.py | 9 +++++++++ functest/opnfv_tests/openstack/rally/rally.py | 2 +- functest/opnfv_tests/openstack/shaker/shaker.py | 2 +- functest/opnfv_tests/openstack/tempest/tempest.py | 2 +- functest/opnfv_tests/openstack/vmtp/vmtp.py | 2 +- functest/tests/unit/openstack/rally/test_rally.py | 2 +- 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 b5c5204c9..112d8870d 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 892d1749d..7bdca8929 100644 --- a/functest/utils/env.py +++ b/functest/utils/env.py @@ -39,7 +39,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' } -- cgit 1.2.3-korg