summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.openstack.org>2018-07-17 16:52:45 +0000
committerGerrit Code Review <review@openstack.org>2018-07-17 16:52:45 +0000
commit8221aaef31099adb376859142229c91164c08920 (patch)
tree49f06322ab7753607934b1b112e54848fb555bd0
parent9e1e2660c191c278c2f4cd3bc44c032c7382a92c (diff)
parent39d5bf3765a76f995ff7c67d1f53a39532e7de5f (diff)
Merge "Using port id instead of port name in get_pod_port"HEADmaster
-rw-r--r--kuryr_tempest_plugin/tests/scenario/base.py25
1 files changed, 6 insertions, 19 deletions
diff --git a/kuryr_tempest_plugin/tests/scenario/base.py b/kuryr_tempest_plugin/tests/scenario/base.py
index 9d0b26e..6cf89da 100644
--- a/kuryr_tempest_plugin/tests/scenario/base.py
+++ b/kuryr_tempest_plugin/tests/scenario/base.py
@@ -115,24 +115,11 @@ class BaseKuryrScenarioTest(manager.NetworkScenarioTest):
115 return pod.status.phase 115 return pod.status.phase
116 116
117 def get_pod_port(self, pod_name, namespace="default"): 117 def get_pod_port(self, pod_name, namespace="default"):
118 # TODO(gcheresh) get pod port using container id, as kuryr this would 118 pod = self.k8s_client.CoreV1Api().read_namespaced_pod_status(
119 # depend on port_debug kuryr feature 119 namespace=namespace, name=pod_name)
120 full_port_name = str(namespace) + "/" + str(pod_name) 120 kuryr_if = json.loads(pod.metadata.annotations[
121 port_list = self.os_admin.ports_client.list_ports() 121 'openstack.org/kuryr-vif'])
122 found_ports = [] 122 return kuryr_if['eth0']['versioned_object.data']['id']
123 for port in port_list['ports']:
124 if full_port_name == port['name']:
125 return port
126 if pod_name == port['name']:
127 found_ports.append(port)
128 # To maintain backwards compatibility with the old naming we also check
129 # for matchings without namespace at the port name.
130 # Note, if there is more than one port with the same name, we have no
131 # way to differentiate them unless the namespace is used at the port
132 # name, since kubernetes will avoid having pods with the same name
133 # under the same namespace
134 if len(found_ports) == 1:
135 return found_ports[0]
136 123
137 def exec_command_in_pod(self, pod_name, command, namespace="default"): 124 def exec_command_in_pod(self, pod_name, command, namespace="default"):
138 api = self.k8s_client.CoreV1Api() 125 api = self.k8s_client.CoreV1Api()
@@ -145,7 +132,7 @@ class BaseKuryrScenarioTest(manager.NetworkScenarioTest):
145 pod_fip = self.os_admin.floating_ips_client.create_floatingip( 132 pod_fip = self.os_admin.floating_ips_client.create_floatingip(
146 floating_network_id=ext_net_id, 133 floating_network_id=ext_net_id,
147 tenant_id=self.get_project_id(), 134 tenant_id=self.get_project_id(),
148 port_id=self.get_pod_port(pod_name, namespace)['id']) 135 port_id=self.get_pod_port(pod_name, namespace))
149 self.pod_fips.append(pod_fip) 136 self.pod_fips.append(pod_fip)
150 return pod_fip 137 return pod_fip
151 138