aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCédric Ollivier <cedric.ollivier@orange.com>2019-09-30 17:26:05 +0200
committerCédric Ollivier <cedric.ollivier@orange.com>2019-09-30 17:29:32 +0200
commit7babc714b760a5953abd9098a669307aa44a1966 (patch)
treeebf6fb170bad63740d0d61ab195315acecb8df06
parentee92bf3e349a15326028df343e89a114eac859da (diff)
Count all active hypervisors
Else tempest_slow fails if one hypervisor is down (detected in ONAP Openlab). It also improves Shaker, Rally and Vmtp which count them. Change-Id: Iee7c20e0357d9237501c5c451580d8f6409ac86b Signed-off-by: Cédric Ollivier <cedric.ollivier@orange.com> (cherry picked from commit 22b37f0482f84fc935ae9ece3c9722098c0573bc)
-rw-r--r--functest/core/singlevm.py8
-rw-r--r--functest/opnfv_tests/openstack/rally/rally.py2
-rw-r--r--functest/opnfv_tests/openstack/shaker/shaker.py2
-rw-r--r--functest/opnfv_tests/openstack/tempest/tempest.py3
-rw-r--r--functest/opnfv_tests/openstack/vmtp/vmtp.py2
-rw-r--r--functest/tests/unit/openstack/rally/test_rally.py4
6 files changed, 14 insertions, 7 deletions
diff --git a/functest/core/singlevm.py b/functest/core/singlevm.py
index 1da30de34..cebb7cc84 100644
--- a/functest/core/singlevm.py
+++ b/functest/core/singlevm.py
@@ -257,6 +257,14 @@ class VmReady1(tenantnetwork.TenantNetwork1):
self.__logger.debug(
"Orphan security group %s in use", sec_group.id)
+ 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
+ return compute_cnt
+
def run(self, **kwargs):
"""Boot the new VM
diff --git a/functest/opnfv_tests/openstack/rally/rally.py b/functest/opnfv_tests/openstack/rally/rally.py
index b450580c7..4b7c5499c 100644
--- a/functest/opnfv_tests/openstack/rally/rally.py
+++ b/functest/opnfv_tests/openstack/rally/rally.py
@@ -524,7 +524,7 @@ class RallyBase(singlevm.VmReady2):
shutil.copytree(task_macro, macro_dir)
self.update_keystone_default_role()
- self.compute_cnt = len(self.cloud.list_hypervisors())
+ self.compute_cnt = self.count_active_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 46a44c775..9a31a8b19 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 len(self.orig_cloud.list_hypervisors()) < 2:
+ if self.count_active_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 a6ec568a0..6d13bd206 100644
--- a/functest/opnfv_tests/openstack/tempest/tempest.py
+++ b/functest/opnfv_tests/openstack/tempest/tempest.py
@@ -567,8 +567,7 @@ class TempestCommon(singlevm.VmReady2):
self.deployment_dir = self.get_verifier_deployment_dir(
self.verifier_id, self.deployment_id)
- compute_cnt = len(self.orig_cloud.list_hypervisors())
-
+ compute_cnt = self.count_active_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 294201996..256b46b84 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 len(self.orig_cloud.list_hypervisors()) < 2:
+ if self.count_active_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 226d4e69a..66ba1c3b0 100644
--- a/functest/tests/unit/openstack/rally/test_rally.py
+++ b/functest/tests/unit/openstack/rally/test_rally.py
@@ -291,8 +291,8 @@ 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.cloud,
- 'list_hypervisors') as mock_list_hyperv, \
+ with mock.patch.object(self.rally_base, 'count_active_hypervisors') \
+ as mock_list_hyperv, \
mock.patch.object(self.rally_base, 'create_flavor_alt',
side_effect=Exception) \
as mock_create_flavor: