From 37456f57eb646a290656416789d07eb9d77a1173 Mon Sep 17 00:00:00 2001 From: deepak_mourya Date: Tue, 13 Mar 2018 09:38:46 +0530 Subject: [PATCH] Add tempest test for the 'nets' parameter This patch will add the tempest test for the 'nets' parameter. The test pre-creates a neutron port and run a container with the pre-created neutron port. This test verifies the Zun container will work with an existing neutron port. Closes-bug: #1753270 Change-Id: Ie00deb46b879e7625ec83141715d9383ce961469 --- zun_tempest_plugin/tests/tempest/api/clients.py | 3 +++ .../tests/tempest/api/test_containers.py | 15 +++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/zun_tempest_plugin/tests/tempest/api/clients.py b/zun_tempest_plugin/tests/tempest/api/clients.py index ecd77aa..7600bc8 100644 --- a/zun_tempest_plugin/tests/tempest/api/clients.py +++ b/zun_tempest_plugin/tests/tempest/api/clients.py @@ -18,6 +18,7 @@ from tempest import config from tempest.lib.common import api_version_utils from tempest.lib.common import rest_client from tempest.lib.services.image.v2 import images_client +from tempest.lib.services.network import networks_client from tempest.lib.services.network import ports_client from tempest.lib.services.network import security_groups_client from tempest import manager @@ -72,6 +73,8 @@ class Manager(manager.Manager): self.sgs_client = security_groups_client.SecurityGroupsClient( self.auth_provider, 'network', CONF.identity.region) self.container_client = ZunClient(self.auth_provider) + self.neutron_client = networks_client.NetworksClient( + self.auth_provider, 'network', CONF.identity.region) class ZunClient(rest_client.RestClient): diff --git a/zun_tempest_plugin/tests/tempest/api/test_containers.py b/zun_tempest_plugin/tests/tempest/api/test_containers.py index 95c87c2..b68589c 100644 --- a/zun_tempest_plugin/tests/tempest/api/test_containers.py +++ b/zun_tempest_plugin/tests/tempest/api/test_containers.py @@ -50,6 +50,7 @@ class TestContainer(base.BaseZunTest): cls.images_client = cls.os_primary.images_client cls.ports_client = cls.os_primary.ports_client cls.sgs_client = cls.os_primary.sgs_client + cls.networks_client = cls.os_primary.neutron_client @classmethod def resource_setup(cls): @@ -186,6 +187,20 @@ class TestContainer(base.BaseZunTest): self.assertTrue('key1=label1', labels) self.assertTrue('key2=label2', labels) + @decorators.idempotent_id('8fc7fec1-e1a2-3f65-a5a6-dba425c1607c') + def test_run_container_with_port(self): + project_id = self.container_client.tenant_id + networks = self.networks_client.list_networks()['networks'] + for network in networks: + if network['project_id'] == project_id: + network_id = network['id'] + + port = self.ports_client.create_port(network_id=network_id, + name='testport') + _, model = self._run_container(nets=[{'port': 'testport'}]) + self.assertTrue('testport', model) + self.addCleanup(self.ports_client.delete_port, port['port']['id']) + @decorators.idempotent_id('9fc7fec0-e1a9-4f65-a5a6-dba425c1607c') def test_run_container_with_restart_policy(self): _, model = self._run_container(restart_policy={