Skip to content

Commit

Permalink
Fixed the LP bug 993754.
Browse files Browse the repository at this point in the history
Ensure that the server created in the test is destroyed in finally: block of the test.

Change-Id: I78b731f79f2b7b6f2673203b8d47bff858c368dc
  • Loading branch information
patelsa committed May 3, 2012
1 parent 89a6857 commit 26bf032
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions tempest/tests/test_server_personality.py
Expand Up @@ -41,22 +41,25 @@ def test_can_create_server_with_max_number_personality_files(self):
Server should be created successfully if maximum allowed number of
files is injected into the server during creation.
"""
name = rand_name('server')
file_contents = 'This is a test file.'
try:
name = rand_name('server')
file_contents = 'This is a test file.'

resp, max_file_limit = self.user_client.get_personality_file_limit()
self.assertEqual(200, resp.status)
resp, max_file_limit = self.user_client.\
get_personality_file_limit()
self.assertEqual(200, resp.status)

personality = []
for i in range(0, max_file_limit):
path = 'etc/test' + str(i) + '.txt'
personality.append({'path': path,
personality = []
for i in range(0, max_file_limit):
path = 'etc/test' + str(i) + '.txt'
personality.append({'path': path,
'contents': base64.b64encode(file_contents)})

resp, server = self.client.create_server(name, self.image_ref,
resp, server = self.client.create_server(name, self.image_ref,
self.flavor_ref,
personality=personality)
self.assertEqual('202', resp['status'])
self.assertEqual('202', resp['status'])

#Teardown
self.client.delete_server(server['id'])
finally:
self.client.delete_server(server['id'])

0 comments on commit 26bf032

Please sign in to comment.