Read template's expected value orchest test Part-2

In tests under /tempest/api/orchestration/, resources gets
created based on parameters defined in template (yaml, json).
But while verification of output, expected values are hard coded
in tests.
Expected values should be read from template only.
This patch covers the following files -
    test_environment.py
    test_nova_keypair_resources.py
    test_swift_resources.py

Closes-Bug: #1327919

Change-Id: Ie241b7f299487cd0db384778225823e96fecf440
This commit is contained in:
Ghanshyam 2014-07-10 10:24:29 +09:00
parent 961ea1adb8
commit f36b0d462c
3 changed files with 29 additions and 10 deletions

View File

@ -65,7 +65,10 @@ outputs:
# random_string.yaml specifies a length of 10
random_value = self.get_stack_output(stack_identifier, 'random_value')
self.assertEqual(10, len(random_value))
random_string_template = self.load_template('random_string')
expected_length = random_string_template['parameters'][
'random_length']['default']
self.assertEqual(expected_length, len(random_value))
@test.attr(type='gate')
def test_files_provider_resource(self):
@ -90,4 +93,7 @@ outputs:
# random_string.yaml specifies a length of 10
random_value = self.get_stack_output(stack_identifier, 'random_value')
self.assertEqual(10, len(random_value))
random_string_template = self.load_template('random_string')
expected_length = random_string_template['parameters'][
'random_length']['default']
self.assertEqual(expected_length, len(random_value))

View File

@ -23,6 +23,8 @@ LOG = logging.getLogger(__name__)
class NovaKeyPairResourcesYAMLTest(base.BaseOrchestrationTest):
_tpl_type = 'yaml'
_resource = 'resources'
_type = 'type'
@classmethod
def setUpClass(cls):
@ -49,8 +51,15 @@ class NovaKeyPairResourcesYAMLTest(base.BaseOrchestrationTest):
@test.attr(type='slow')
def test_created_resources(self):
"""Verifies created keypair resource."""
resources = [('KeyPairSavePrivate', 'OS::Nova::KeyPair'),
('KeyPairDontSavePrivate', 'OS::Nova::KeyPair')]
nova_keypair_template = self.load_template('nova_keypair',
ext=self._tpl_type)
resources = [('KeyPairSavePrivate',
nova_keypair_template[self._resource][
'KeyPairSavePrivate'][self._type]),
('KeyPairDontSavePrivate',
nova_keypair_template[self._resource][
'KeyPairDontSavePrivate'][self._type])]
for resource_name, resource_type in resources:
resource = self.test_resources.get(resource_name, None)
@ -85,3 +94,5 @@ class NovaKeyPairResourcesYAMLTest(base.BaseOrchestrationTest):
class NovaKeyPairResourcesAWSTest(NovaKeyPairResourcesYAMLTest):
_tpl_type = 'json'
_resource = 'Resources'
_type = 'Type'

View File

@ -49,8 +49,11 @@ class SwiftResourcesTestJSON(base.BaseOrchestrationTest):
def test_created_resources(self):
"""Created stack should be in the list of existing stacks."""
resources = [('SwiftContainer', 'OS::Swift::Container'),
('SwiftContainerWebsite', 'OS::Swift::Container')]
swift_basic_template = self.load_template('swift_basic')
resources = [('SwiftContainer', swift_basic_template['resources'][
'SwiftContainer']['type']),
('SwiftContainerWebsite', swift_basic_template[
'resources']['SwiftContainerWebsite']['type'])]
for resource_name, resource_type in resources:
resource = self.test_resources.get(resource_name)
self.assertIsInstance(resource, dict)
@ -84,10 +87,9 @@ class SwiftResourcesTestJSON(base.BaseOrchestrationTest):
self.assertIn(h, headers)
def test_metadata(self):
metadatas = {
"web-index": "index.html",
"web-error": "error.html"
}
swift_basic_template = self.load_template('swift_basic')
metadatas = swift_basic_template['resources']['SwiftContainerWebsite'][
'properties']['X-Container-Meta']
swcont_website = self.test_resources.get(
'SwiftContainerWebsite')['physical_resource_id']
headers, _ = self.container_client.list_container_metadata(