deb-heat/heat_integrationtests/functional/test_remote_stack.py
Rabi Mishra 25becbcbf4 Add config entries to skip integration tests
This adds options to skip scenario and functional tests.
You can either skip the complete set of tests or list of specific
tests.

Following new config options are added:

`skip_scenario_tests` -  Skip all scenario tests
`skip_functional_tests` - Skip all functional tests
`skip_functional_test_list` - List of functional tests to skip
`skip_scenario_test_list` - List of scenario tests to skip
`skip_test_stack_action_list` - List of actions in tests to skip

Change-Id: I7a5233f5db1f065ccee5a97408c72203c108a656
Depends-On: I25c5e853f0499b88f2803b077d19e132140908f1
2015-08-07 07:29:20 +00:00

144 lines
5.6 KiB
Python

# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from heatclient import exc
import six
from heat_integrationtests.functional import functional_base
class RemoteStackTest(functional_base.FunctionalTestsBase):
template = '''
heat_template_version: 2013-05-23
resources:
my_stack:
type: OS::Heat::Stack
properties:
context:
region_name: RegionOne
template:
get_file: remote_stack.yaml
outputs:
key:
value: {get_attr: [my_stack, outputs]}
'''
remote_template = '''
heat_template_version: 2013-05-23
resources:
random1:
type: OS::Heat::RandomString
outputs:
remote_key:
value: {get_attr: [random1, value]}
'''
def setUp(self):
super(RemoteStackTest, self).setUp()
def test_remote_stack_alone(self):
stack_id = self.stack_create(template=self.remote_template)
expected_resources = {'random1': 'OS::Heat::RandomString'}
self.assertEqual(expected_resources, self.list_resources(stack_id))
stack = self.client.stacks.get(stack_id)
output_value = self._stack_output(stack, 'remote_key')
self.assertEqual(32, len(output_value))
def test_stack_create(self):
files = {'remote_stack.yaml': self.remote_template}
stack_id = self.stack_create(files=files)
expected_resources = {'my_stack': 'OS::Heat::Stack'}
self.assertEqual(expected_resources, self.list_resources(stack_id))
stack = self.client.stacks.get(stack_id)
output = self._stack_output(stack, 'key')
parent_output_value = output['remote_key']
self.assertEqual(32, len(parent_output_value))
rsrc = self.client.resources.get(stack_id, 'my_stack')
remote_id = rsrc.physical_resource_id
rstack = self.client.stacks.get(remote_id)
self.assertEqual(remote_id, rstack.id)
remote_output_value = self._stack_output(rstack, 'remote_key')
self.assertEqual(32, len(remote_output_value))
self.assertEqual(parent_output_value, remote_output_value)
remote_resources = {'random1': 'OS::Heat::RandomString'}
self.assertEqual(remote_resources, self.list_resources(remote_id))
def test_stack_create_bad_region(self):
stack_name = self._stack_rand_name()
tmpl_bad_region = self.template.replace('RegionOne', 'DARKHOLE')
files = {'remote_stack.yaml': self.remote_template}
kwargs = {
'stack_name': stack_name,
'template': tmpl_bad_region,
'files': files
}
ex = self.assertRaises(exc.HTTPBadRequest, self.stack_create, **kwargs)
error_msg = ('ERROR: Cannot establish connection to Heat endpoint '
'at region "DARKHOLE" due to "publicURL endpoint for '
'orchestration service in DARKHOLE region not found"')
self.assertEqual(error_msg, six.text_type(ex))
def test_stack_resource_validation_fail(self):
stack_name = self._stack_rand_name()
tmpl_bad_format = self.remote_template.replace('resources', 'resource')
files = {'remote_stack.yaml': tmpl_bad_format}
kwargs = {'stack_name': stack_name, 'files': files}
ex = self.assertRaises(exc.HTTPBadRequest, self.stack_create, **kwargs)
error_msg = ('ERROR: Failed validating stack template using Heat '
'endpoint at region "RegionOne" due to '
'"ERROR: The template section is invalid: resource"')
self.assertEqual(error_msg, six.text_type(ex))
def test_stack_update(self):
files = {'remote_stack.yaml': self.remote_template}
stack_id = self.stack_create(files=files)
expected_resources = {'my_stack': 'OS::Heat::Stack'}
self.assertEqual(expected_resources, self.list_resources(stack_id))
rsrc = self.client.resources.get(stack_id, 'my_stack')
physical_resource_id = rsrc.physical_resource_id
rstack = self.client.stacks.get(physical_resource_id)
self.assertEqual(physical_resource_id, rstack.id)
remote_resources = {'random1': 'OS::Heat::RandomString'}
self.assertEqual(remote_resources,
self.list_resources(rstack.id))
# do an update
update_template = self.remote_template.replace('random1', 'random2')
files = {'remote_stack.yaml': update_template}
self.update_stack(stack_id, self.template, files=files)
# check if the remote stack is still there with the same ID
self.assertEqual(expected_resources, self.list_resources(stack_id))
rsrc = self.client.resources.get(stack_id, 'my_stack')
physical_resource_id = rsrc.physical_resource_id
rstack = self.client.stacks.get(physical_resource_id)
self.assertEqual(physical_resource_id, rstack.id)
remote_resources = {'random2': 'OS::Heat::RandomString'}
self.assertEqual(remote_resources,
self.list_resources(rstack.id))
def test_stack_suspend_resume(self):
files = {'remote_stack.yaml': self.remote_template}
stack_id = self.stack_create(files=files)
self.stack_suspend(stack_id)
self.stack_resume(stack_id)