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
This commit is contained in:
Duc Truong 2019-02-07 21:16:40 +00:00
parent fc3b473eaa
commit 118193a2d7
3 changed files with 15 additions and 1 deletions

View File

@ -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."""

View File

@ -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)

View File

@ -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)