Testing pod to pod connectivity

Co-Authored-By: Michal Dulko <mdulko@redhat.com>

Change-Id: I10cc90e9fbeb334b00ce4c14c285199375862c21
This commit is contained in:
Genadi Chereshnya 2017-12-05 16:24:30 +02:00 committed by Michał Dulko
parent ffbd59d792
commit f8d436c7ab
2 changed files with 24 additions and 0 deletions

View File

@ -16,6 +16,7 @@ import time
from kubernetes import client as k8s_client
from kubernetes import config as k8s_config
from kubernetes.stream import stream
from tempest import config
from tempest.lib.common.utils import data_utils
@ -104,6 +105,12 @@ class BaseKuryrScenarioTest(manager.NetworkScenarioTest):
if pod_name == port['name']:
return port
def exec_command_in_pod(self, pod_name, command, namespace="default"):
api = self.k8s_client.CoreV1Api()
return stream(api.connect_get_namespaced_pod_exec, pod_name, namespace,
command=command, stderr=False, stdin=False, stdout=True,
tty=False)
def assign_fip_to_pod(self, pod_name, namespace="default"):
ext_net_id = CONF.network.public_network_id
pod_fip = self.os_admin.floating_ips_client.create_floatingip(

View File

@ -12,6 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import time
from oslo_log import log as logging
from tempest import config
from tempest.lib.common.utils import data_utils
@ -63,3 +65,18 @@ class TestCrossPingScenario(base.BaseKuryrScenarioTest):
self.assertEqual('0', result.rstrip('\n'))
except exceptions.SSHExecCommandFailed:
LOG.error("Couldn't ping server")
@decorators.idempotent_id('bddf5441-1244-449d-a125-b5fddfb1a2a9')
def test_pod_pod_ping(self):
pod_name_list, pod_fip_list = [], []
for i in range(2):
pod_name, pod = self.create_pod()
self.addCleanup(self.delete_pod, pod_name, pod)
pod_name_list.append(pod_name)
pod_fip_list.append(self.assign_fip_to_pod(pod_name))
cmd = [
"/bin/sh", "-c", "ping -c 1 {dst_ip}>/dev/null ; echo $?".format(
dst_ip=pod_fip_list[1]['floatingip']['floating_ip_address'])]
time.sleep(20)
self.assertEqual(self.exec_command_in_pod(pod_name_list[0], cmd), '0')