summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--kuryr_tempest_plugin/tests/scenario/base.py7
-rw-r--r--kuryr_tempest_plugin/tests/scenario/test_cross_ping.py17
2 files changed, 24 insertions, 0 deletions
diff --git a/kuryr_tempest_plugin/tests/scenario/base.py b/kuryr_tempest_plugin/tests/scenario/base.py
index 290e0bd..8825a78 100644
--- a/kuryr_tempest_plugin/tests/scenario/base.py
+++ b/kuryr_tempest_plugin/tests/scenario/base.py
@@ -16,6 +16,7 @@ import time
16 16
17from kubernetes import client as k8s_client 17from kubernetes import client as k8s_client
18from kubernetes import config as k8s_config 18from kubernetes import config as k8s_config
19from kubernetes.stream import stream
19 20
20from tempest import config 21from tempest import config
21from tempest.lib.common.utils import data_utils 22from tempest.lib.common.utils import data_utils
@@ -104,6 +105,12 @@ class BaseKuryrScenarioTest(manager.NetworkScenarioTest):
104 if pod_name == port['name']: 105 if pod_name == port['name']:
105 return port 106 return port
106 107
108 def exec_command_in_pod(self, pod_name, command, namespace="default"):
109 api = self.k8s_client.CoreV1Api()
110 return stream(api.connect_get_namespaced_pod_exec, pod_name, namespace,
111 command=command, stderr=False, stdin=False, stdout=True,
112 tty=False)
113
107 def assign_fip_to_pod(self, pod_name, namespace="default"): 114 def assign_fip_to_pod(self, pod_name, namespace="default"):
108 ext_net_id = CONF.network.public_network_id 115 ext_net_id = CONF.network.public_network_id
109 pod_fip = self.os_admin.floating_ips_client.create_floatingip( 116 pod_fip = self.os_admin.floating_ips_client.create_floatingip(
diff --git a/kuryr_tempest_plugin/tests/scenario/test_cross_ping.py b/kuryr_tempest_plugin/tests/scenario/test_cross_ping.py
index 6d11fea..825c140 100644
--- a/kuryr_tempest_plugin/tests/scenario/test_cross_ping.py
+++ b/kuryr_tempest_plugin/tests/scenario/test_cross_ping.py
@@ -12,6 +12,8 @@
12# See the License for the specific language governing permissions and 12# See the License for the specific language governing permissions and
13# limitations under the License. 13# limitations under the License.
14 14
15import time
16
15from oslo_log import log as logging 17from oslo_log import log as logging
16from tempest import config 18from tempest import config
17from tempest.lib.common.utils import data_utils 19from tempest.lib.common.utils import data_utils
@@ -63,3 +65,18 @@ class TestCrossPingScenario(base.BaseKuryrScenarioTest):
63 self.assertEqual('0', result.rstrip('\n')) 65 self.assertEqual('0', result.rstrip('\n'))
64 except exceptions.SSHExecCommandFailed: 66 except exceptions.SSHExecCommandFailed:
65 LOG.error("Couldn't ping server") 67 LOG.error("Couldn't ping server")
68
69 @decorators.idempotent_id('bddf5441-1244-449d-a125-b5fddfb1a2a9')
70 def test_pod_pod_ping(self):
71 pod_name_list, pod_fip_list = [], []
72 for i in range(2):
73 pod_name, pod = self.create_pod()
74 self.addCleanup(self.delete_pod, pod_name, pod)
75 pod_name_list.append(pod_name)
76 pod_fip_list.append(self.assign_fip_to_pod(pod_name))
77
78 cmd = [
79 "/bin/sh", "-c", "ping -c 1 {dst_ip}>/dev/null ; echo $?".format(
80 dst_ip=pod_fip_list[1]['floatingip']['floating_ip_address'])]
81 time.sleep(20)
82 self.assertEqual(self.exec_command_in_pod(pod_name_list[0], cmd), '0')