Merge "Cleanup the created security groups"

This commit is contained in:
Zuul 2018-03-20 16:39:09 +00:00 committed by Gerrit Code Review
commit 3f9055cdca

View File

@ -133,8 +133,6 @@ class TestContainer(base.BaseZunTest):
@decorators.idempotent_id('c32f93e3-da88-4c13-be38-25d2e662a28e')
def test_run_container_with_image_driver_glance(self):
image = None
try:
docker_base_url = self._get_docker_url()
self.docker_client.pull_image(
'cirros', docker_auth_url=docker_base_url)
@ -150,18 +148,13 @@ class TestContainer(base.BaseZunTest):
image = self.images_client.create_image(
name='cirros', disk_format='raw', container_format='docker')
self.addCleanup(self.images_client.delete_image, image['id'])
self.images_client.store_image_file(image['id'], image_data)
# delete the local image that was previously pulled down
self.docker_client.delete_image('cirros', docker_base_url)
_, model = self._run_container(
image='cirros', image_driver='glance')
finally:
if image:
try:
self.images_client.delete_image(image['id'])
except Exception:
pass
@decorators.idempotent_id('b70bedbc-5ba2-400c-8f5f-0cf05ca17151')
def test_run_container_with_environment(self):
@ -237,7 +230,9 @@ class TestContainer(base.BaseZunTest):
@decorators.idempotent_id('f181eeda-a9d1-4b2e-9746-d6634ca81e2f')
def test_run_container_with_security_groups(self):
sg_name = data_utils.rand_name('test_sg')
self.sgs_client.create_security_group(name=sg_name)
sg = self.sgs_client.create_security_group(name=sg_name)
self.addCleanup(self.sgs_client.delete_security_group,
sg['security_group']['id'])
_, model = self._run_container(security_groups=[sg_name])
sgs = self._get_all_security_groups(model)
self.assertEqual(1, len(sgs))
@ -436,7 +431,9 @@ class TestContainer(base.BaseZunTest):
self.assertEqual(1, len(sgs))
self.assertEqual('default', sgs[0])
sg_name = data_utils.rand_name('test_add_sg')
self.sgs_client.create_security_group(name=sg_name)
sg = self.sgs_client.create_security_group(name=sg_name)
self.addCleanup(self.sgs_client.delete_security_group,
sg['security_group']['id'])
gen_model = datagen.container_add_sg_data(name=sg_name)
resp, body = self.container_client.add_security_group(
model.uuid, gen_model)