Count all hypervisors by default 82/68582/2
authorCédric Ollivier <cedric.ollivier@orange.com>
Sun, 6 Oct 2019 18:43:02 +0000 (20:43 +0200)
committerCédric Ollivier <cedric.ollivier@orange.com>
Tue, 8 Oct 2019 04:51:20 +0000 (06:51 +0200)
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>
functest/core/singlevm.py
functest/opnfv_tests/openstack/rally/rally.py
functest/opnfv_tests/openstack/shaker/shaker.py
functest/opnfv_tests/openstack/tempest/tempest.py
functest/opnfv_tests/openstack/vmtp/vmtp.py
functest/tests/unit/openstack/rally/test_rally.py
functest/utils/env.py

index 734eb22..5ecd482 100644 (file)
@@ -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):
index 5487e21..d3b82b7 100644 (file)
@@ -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
index 3670670..9d8a132 100644 (file)
@@ -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()
index 6d13bd2..908d3bc 100644 (file)
@@ -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)
index fa83c45..dc480c4 100644 (file)
@@ -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()
index c430e97..ae3c397 100644 (file)
@@ -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) \
index 8c00309..dec9b0e 100644 (file)
@@ -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'
 }