Count all hypervisors by default 84/68584/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:53:28 +0000 (06:53 +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>
(cherry picked from commit 7332716dc835cd72b0beefc38afda2697bd99e02)

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 cebb7cc..4c33920 100644 (file)
@@ -257,12 +257,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 abeb3e0..5d94eaf 100644 (file)
@@ -525,7 +525,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 256b46b..c4d6e81 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 66ba1c3..c867990 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 892d174..7bdca89 100644 (file)
@@ -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'
 }