Include file content in scenario tests
Use the heatclient utilities for loading referenced files and passing them in the files dict when running scenario tests. This allows testing nested stack scenarios in a way that is representative of how users would encounter them. Change-Id: I6693a0a9e0e1af42b69ade12c8da6f12d370eb49 Story: #1739447 Task: 22218
This commit is contained in:
parent
b57d248b39
commit
4ca172ae78
|
@ -10,7 +10,6 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import os
|
||||
import random
|
||||
import re
|
||||
import subprocess
|
||||
|
@ -206,13 +205,6 @@ class HeatIntegrationTest(testtools.testcase.WithAttributes,
|
|||
LOG.info('Console output for %s', server.id)
|
||||
LOG.info(server.get_console_output())
|
||||
|
||||
def _load_template(self, base_file, file_name, sub_dir=None):
|
||||
sub_dir = sub_dir or ''
|
||||
filepath = os.path.join(os.path.dirname(os.path.realpath(base_file)),
|
||||
sub_dir, file_name)
|
||||
with open(filepath) as f:
|
||||
return f.read()
|
||||
|
||||
def create_keypair(self, client=None, name=None):
|
||||
if client is None:
|
||||
client = self.compute_client
|
||||
|
|
|
@ -10,6 +10,10 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import os
|
||||
import yaml
|
||||
|
||||
from heatclient.common import template_utils
|
||||
from oslo_utils import reflection
|
||||
|
||||
from heat_tempest_plugin.common import test
|
||||
|
@ -33,9 +37,19 @@ class ScenarioTestsBase(test.HeatIntegrationTest):
|
|||
if not self.conf.minimal_instance_type:
|
||||
raise self.skipException("No minimal flavor configured to test")
|
||||
|
||||
def _load_template(self, base_file, file_name, sub_dir=None, files=None):
|
||||
sub_dir = sub_dir or ''
|
||||
filepath = os.path.join(os.path.dirname(os.path.realpath(base_file)),
|
||||
sub_dir, file_name)
|
||||
_files, template = template_utils.get_template_contents(filepath,
|
||||
files=files)
|
||||
return yaml.safe_dump(template)
|
||||
|
||||
def launch_stack(self, template_name, expected_status='CREATE_COMPLETE',
|
||||
parameters=None, **kwargs):
|
||||
template = self._load_template(__file__, template_name, self.sub_dir)
|
||||
files = kwargs.get('files', {})
|
||||
template = self._load_template(__file__, template_name, self.sub_dir,
|
||||
files)
|
||||
|
||||
parameters = parameters or {}
|
||||
|
||||
|
@ -45,7 +59,7 @@ class ScenarioTestsBase(test.HeatIntegrationTest):
|
|||
stack_id = self.stack_create(
|
||||
stack_name=kwargs.get('stack_name'),
|
||||
template=template,
|
||||
files=kwargs.get('files'),
|
||||
files=files,
|
||||
parameters=parameters,
|
||||
environment=kwargs.get('environment'),
|
||||
expected_status=expected_status
|
||||
|
|
Loading…
Reference in New Issue