Merge "Add tempest test for network attach/detach."
This commit is contained in:
commit
41c3eea186
@ -266,6 +266,18 @@ class ZunClient(rest_client.RestClient):
|
|||||||
return True
|
return True
|
||||||
utils.wait_for_condition(is_container_deleted)
|
utils.wait_for_condition(is_container_deleted)
|
||||||
|
|
||||||
|
def network_attach(self, container_id, params=None, **kwargs):
|
||||||
|
return self.post(
|
||||||
|
self.container_uri(container_id, action='network_attach',
|
||||||
|
params=params),
|
||||||
|
None, **kwargs)
|
||||||
|
|
||||||
|
def network_detach(self, container_id, params=None, **kwargs):
|
||||||
|
return self.post(
|
||||||
|
self.container_uri(container_id, action='network_detach',
|
||||||
|
params=params),
|
||||||
|
None, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
@contextlib.contextmanager
|
@contextlib.contextmanager
|
||||||
def docker_client(docker_auth_url):
|
def docker_client(docker_auth_url):
|
||||||
|
@ -22,7 +22,7 @@ from zun_tempest_plugin.tests.tempest import utils
|
|||||||
class TestContainer(base.BaseZunTest):
|
class TestContainer(base.BaseZunTest):
|
||||||
|
|
||||||
credentials = ['primary', 'admin']
|
credentials = ['primary', 'admin']
|
||||||
min_microversion = '1.7'
|
min_microversion = '1.12'
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_client_manager(cls, credential_type=None, roles=None,
|
def get_client_manager(cls, credential_type=None, roles=None,
|
||||||
@ -515,3 +515,36 @@ class TestContainer(base.BaseZunTest):
|
|||||||
# }
|
# }
|
||||||
base_url = '{}://{}:{}' . format(protocol, host, port)
|
base_url = '{}://{}:{}' . format(protocol, host, port)
|
||||||
return base_url
|
return base_url
|
||||||
|
|
||||||
|
@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))
|
||||||
|
|
||||||
|
network = list(model.addresses.keys())[0]
|
||||||
|
resp, body = self.container_client.network_detach(
|
||||||
|
model.uuid, params={'network': network})
|
||||||
|
self._ensure_network_detached(model, network)
|
||||||
|
resp, body = self.container_client.network_attach(
|
||||||
|
model.uuid, params={'network': network})
|
||||||
|
self._ensure_network_attached(model, network)
|
||||||
|
|
||||||
|
def _ensure_network_detached(self, container, network):
|
||||||
|
def is_network_detached():
|
||||||
|
_, model = self.container_client.get_container(container.uuid)
|
||||||
|
if network not in model.addresses:
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
|
utils.wait_for_condition(is_network_detached)
|
||||||
|
|
||||||
|
def _ensure_network_attached(self, container, network):
|
||||||
|
def is_network_attached():
|
||||||
|
_, model = self.container_client.get_container(container.uuid)
|
||||||
|
if network in model.addresses:
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
|
utils.wait_for_condition(is_network_attached)
|
||||||
|
Loading…
Reference in New Issue
Block a user