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
This commit is contained in:
deepak_mourya 2018-03-13 09:38:46 +05:30 committed by Hongbin Lu
parent 3f3c74f400
commit 37456f57eb
2 changed files with 18 additions and 0 deletions

View File

@ -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):

View File

@ -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={