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:28:01 +0200
commit22b37f0482f84fc935ae9ece3c9722098c0573bc (patch)
treefa7bb9799cc0a6548ea20fc035275965b51d2713
parent07f4468978fdc43d7a9885f6e4efa87b5e83d2a9 (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>
-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 0473a21da..734eb22d5 100644
--- a/functest/core/singlevm.py
+++ b/functest/core/singlevm.py
@@ -256,6 +256,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 d9fb1fb5c..95447c08d 100644
--- a/functest/opnfv_tests/openstack/rally/rally.py
+++ b/functest/opnfv_tests/openstack/rally/rally.py
@@ -517,7 +517,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 d102f6440..fa83c4522 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 c5cd5019e..c430e9794 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: