From 84cbe6555a685591d8e311611d7d5436f19f50df Mon Sep 17 00:00:00 2001 From: Luis Tomas Bolivar Date: Wed, 28 Feb 2018 09:52:34 +0100 Subject: [PATCH] Ensure port name includes namespace name Change-Id: Idab7e0fe9ecc6e23a2d27d89b81ac9bd4ad8ca68 --- kuryr_tempest_plugin/tests/scenario/base.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/kuryr_tempest_plugin/tests/scenario/base.py b/kuryr_tempest_plugin/tests/scenario/base.py index 8825a78c..26ec1e22 100644 --- a/kuryr_tempest_plugin/tests/scenario/base.py +++ b/kuryr_tempest_plugin/tests/scenario/base.py @@ -100,10 +100,22 @@ class BaseKuryrScenarioTest(manager.NetworkScenarioTest): def get_pod_port(self, pod_name, namespace="default"): # TODO(gcheresh) get pod port using container id, as kuryr this would # depend on port_debug kuryr feature + full_port_name = str(namespace) + "/" + str(pod_name) port_list = self.os_admin.ports_client.list_ports() + found_ports = [] for port in port_list['ports']: - if pod_name == port['name']: + if full_port_name == port['name']: return port + if pod_name == port['name']: + found_ports.append(port) + # To maintain backwards compatibility with the old naming we also check + # for matchings without namespace at the port name. + # Note, if there is more than one port with the same name, we have no + # way to differentiate them unless the namespace is used at the port + # name, since kubernetes will avoid having pods with the same name + # under the same namespace + if len(found_ports) == 1: + return found_ports[0] def exec_command_in_pod(self, pod_name, command, namespace="default"): api = self.k8s_client.CoreV1Api()