diff options
author | Cedric Ollivier <cedric.ollivier@orange.com> | 2019-10-01 08:40:30 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@opnfv.org> | 2019-10-01 08:40:30 +0000 |
commit | 8e006458285fbfde4e4c6c421b05e308eb5d4583 (patch) | |
tree | fe43c12b3a16e5ebcb060f3946135e3518e85c4e | |
parent | 1eb836f24b082754c3a00899dbafb0330b68db6a (diff) | |
parent | 7babc714b760a5953abd9098a669307aa44a1966 (diff) |
Merge "Count all active hypervisors" into stable/hunter
-rw-r--r-- | functest/core/singlevm.py | 8 | ||||
-rw-r--r-- | functest/opnfv_tests/openstack/rally/rally.py | 2 | ||||
-rw-r--r-- | functest/opnfv_tests/openstack/shaker/shaker.py | 2 | ||||
-rw-r--r-- | functest/opnfv_tests/openstack/tempest/tempest.py | 3 | ||||
-rw-r--r-- | functest/opnfv_tests/openstack/vmtp/vmtp.py | 2 | ||||
-rw-r--r-- | functest/tests/unit/openstack/rally/test_rally.py | 4 |
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 fbba1a75f..abeb3e073 100644 --- a/functest/opnfv_tests/openstack/rally/rally.py +++ b/functest/opnfv_tests/openstack/rally/rally.py @@ -525,7 +525,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: |