Merge "Test remove security group in tempest tests"
This commit is contained in:
commit
3f3c74f400
@ -242,6 +242,11 @@ class ZunClient(rest_client.RestClient):
|
||||
self.container_uri(container_id, action='add_security_group'),
|
||||
body=model.to_json(), **kwargs)
|
||||
|
||||
def remove_security_group(self, container_id, model, **kwargs):
|
||||
return self.post(
|
||||
self.container_uri(container_id, action='remove_security_group'),
|
||||
body=model.to_json(), **kwargs)
|
||||
|
||||
def list_services(self, **kwargs):
|
||||
resp, body = self.get(self.services_uri(), **kwargs)
|
||||
return self.deserialize(resp, body,
|
||||
|
@ -103,3 +103,14 @@ def container_add_sg_data(**kwargs):
|
||||
model = container_model.ContainerPatchEntity.from_dict(data)
|
||||
|
||||
return model
|
||||
|
||||
|
||||
def container_remove_sg_data(**kwargs):
|
||||
data = {
|
||||
'name': 'sg_name',
|
||||
}
|
||||
|
||||
data.update(kwargs)
|
||||
model = container_model.ContainerPatchEntity.from_dict(data)
|
||||
|
||||
return model
|
||||
|
@ -415,7 +415,7 @@ class TestContainer(base.BaseZunTest):
|
||||
self.assertTrue('BLOCK I/O(B)' in encodeutils.safe_decode(body))
|
||||
|
||||
@decorators.idempotent_id('b3b9cf17-82ad-4c1b-a4af-8210a778a33e')
|
||||
def test_add_sg_to_container(self):
|
||||
def test_add_and_remove_sg_to_container(self):
|
||||
_, model = self._run_container()
|
||||
sgs = self._get_all_security_groups(model)
|
||||
self.assertEqual(1, len(sgs))
|
||||
@ -438,6 +438,19 @@ class TestContainer(base.BaseZunTest):
|
||||
|
||||
utils.wait_for_condition(assert_security_group_is_added)
|
||||
|
||||
gen_model = datagen.container_remove_sg_data(name=sg_name)
|
||||
resp1, body = self.container_client.remove_security_group(
|
||||
model.uuid, gen_model)
|
||||
self.assertEqual(202, resp1.status)
|
||||
|
||||
def assert_security_group_is_removed():
|
||||
sgs = self._get_all_security_groups(model)
|
||||
if sg_name not in sgs:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
utils.wait_for_condition(assert_security_group_is_removed)
|
||||
|
||||
def _assert_resource_constraints(self, container, cpu=None, memory=None):
|
||||
if cpu is not None:
|
||||
cpu_quota = container.get('HostConfig').get('CpuQuota')
|
||||
@ -536,8 +549,8 @@ class TestContainer(base.BaseZunTest):
|
||||
@decorators.idempotent_id('dcb0dddb-7f0f-43f6-b82a-0cae13938bd6')
|
||||
def test_detach_and_attach_network_to_container(self):
|
||||
_, model = self._run_container()
|
||||
self.assertEqual(1, len(model.addresses))
|
||||
|
||||
self.assertEqual(1, len(model.addresses))
|
||||
network = list(model.addresses.keys())[0]
|
||||
resp, body = self.container_client.network_detach(
|
||||
model.uuid, params={'network': network})
|
||||
|
Loading…
Reference in New Issue
Block a user