From 118193a2d7105f004a00c4c11d1f3764eeeab246 Mon Sep 17 00:00:00 2001 From: Duc Truong Date: Thu, 7 Feb 2019 21:16:40 +0000 Subject: [PATCH] Generate profile spec baed on tempest config Get flavor and image id for profile specs used in integtration tests from tempest config. Change-Id: I60738cde45e2c92a406590eb77d8424fdd9a8877 --- senlin_tempest_plugin/common/utils.py | 13 +++++++++++++ .../tests/integration/test_health_policy.py | 2 +- .../tests/integration/test_nova_server_cluster.py | 1 + 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/senlin_tempest_plugin/common/utils.py b/senlin_tempest_plugin/common/utils.py index 8f4a4fe..e3791dd 100644 --- a/senlin_tempest_plugin/common/utils.py +++ b/senlin_tempest_plugin/common/utils.py @@ -19,11 +19,14 @@ from six.moves import http_client as http import tempfile import tenacity +from tempest import config from tempest.lib.common.utils import data_utils from tempest.lib import exceptions from senlin_tempest_plugin.common import constants +CONF = config.CONF + def api_microversion(api_microversion): """Decorator used to specify api_microversion for test.""" @@ -57,6 +60,16 @@ def prepare_and_cleanup_for_nova_server(base, cidr, spec=None): base.addCleanup(delete_a_subnet, base, subnet_id) +def create_spec_from_config(): + """Utility function that creates a spec object from tempest config""" + spec = constants.spec_nova_server + + spec['properties']['flavor'] = CONF.compute.flavor_ref + spec['properties']['image'] = CONF.compute.image_ref + + return spec + + def create_a_profile(base, spec=None, name=None, metadata=None): """Utility function that generates a Senlin profile.""" diff --git a/senlin_tempest_plugin/tests/integration/test_health_policy.py b/senlin_tempest_plugin/tests/integration/test_health_policy.py index 0954f63..817d094 100644 --- a/senlin_tempest_plugin/tests/integration/test_health_policy.py +++ b/senlin_tempest_plugin/tests/integration/test_health_policy.py @@ -23,7 +23,7 @@ class TestHealthPolicy(base.BaseSenlinIntegrationTest): def setUp(self): super(TestHealthPolicy, self).setUp() - spec = constants.spec_nova_server + spec = utils.create_spec_from_config() spec['properties']['networks'][0]['network'] = 'private-hp' utils.prepare_and_cleanup_for_nova_server(self, "192.168.199.0/24", spec) diff --git a/senlin_tempest_plugin/tests/integration/test_nova_server_cluster.py b/senlin_tempest_plugin/tests/integration/test_nova_server_cluster.py index f1d902f..ce6e01e 100644 --- a/senlin_tempest_plugin/tests/integration/test_nova_server_cluster.py +++ b/senlin_tempest_plugin/tests/integration/test_nova_server_cluster.py @@ -23,6 +23,7 @@ class TestNovaServerCluster(base.BaseSenlinIntegrationNonAdminTest): def setUp(self): super(TestNovaServerCluster, self).setUp() + self.spec = utils.create_spec_from_config() utils.prepare_and_cleanup_for_nova_server(self, "192.168.199.0/24") self.profile_id = utils.create_a_profile(self, self.spec) self.addCleanup(utils.delete_a_profile, self, self.profile_id)