Fixed the LP bug 993754.
Ensure that the server created in the test is destroyed in finally: block of the test.
Change-Id: I78b731f79f2b7b6f2673203b8d47bff858c368dc
diff --git a/tempest/tests/test_server_personality.py b/tempest/tests/test_server_personality.py
index 0d90857..c790a6c 100644
--- a/tempest/tests/test_server_personality.py
+++ b/tempest/tests/test_server_personality.py
@@ -41,22 +41,25 @@
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'])