Skip to content

Commit

Permalink
Read template's expected value orchest test Part-2
Browse files Browse the repository at this point in the history
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
  • Loading branch information
gmannos committed Jul 10, 2014
1 parent 961ea1a commit f36b0d4
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 10 deletions.
10 changes: 8 additions & 2 deletions tempest/api/orchestration/stacks/test_environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@ def test_environment_provider_resource(self):

# 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):
Expand All @@ -90,4 +93,7 @@ def test_files_provider_resource(self):

# 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))
15 changes: 13 additions & 2 deletions tempest/api/orchestration/stacks/test_nova_keypair_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

class NovaKeyPairResourcesYAMLTest(base.BaseOrchestrationTest):
_tpl_type = 'yaml'
_resource = 'resources'
_type = 'type'

@classmethod
def setUpClass(cls):
Expand All @@ -49,8 +51,15 @@ def setUpClass(cls):
@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)
Expand Down Expand Up @@ -85,3 +94,5 @@ def test_stack_keypairs_output(self):

class NovaKeyPairResourcesAWSTest(NovaKeyPairResourcesYAMLTest):
_tpl_type = 'json'
_resource = 'Resources'
_type = 'Type'
14 changes: 8 additions & 6 deletions tempest/api/orchestration/stacks/test_swift_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,11 @@ def setUpClass(cls):

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)
Expand Down Expand Up @@ -84,10 +87,9 @@ def test_acl(self):
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(
Expand Down

0 comments on commit f36b0d4

Please sign in to comment.