Use one pod to check connectivity in kuryr_restart
In test_kuryr_restart use one pod to check connectivity to the created pods from this pod instead of assigning a fip for each created pod. This can solve problems when there is shortage of floating ips. Also, Don't fail on deletion of a pod in cleanup if it's not found Change-Id: I55a33f88356ff3d1ef6ed0ce83bb102172e46023
This commit is contained in:
parent
0e68dcf892
commit
f6f77354b1
@ -213,10 +213,16 @@ class BaseKuryrScenarioTest(manager.NetworkScenarioTest):
|
|||||||
def delete_pod(cls, pod_name, body=None, namespace="default"):
|
def delete_pod(cls, pod_name, body=None, namespace="default"):
|
||||||
if body is None:
|
if body is None:
|
||||||
body = {}
|
body = {}
|
||||||
|
try:
|
||||||
cls.k8s_client.CoreV1Api().delete_namespaced_pod(
|
cls.k8s_client.CoreV1Api().delete_namespaced_pod(
|
||||||
name=pod_name,
|
name=pod_name,
|
||||||
body=body,
|
body=body,
|
||||||
namespace=namespace)
|
namespace=namespace)
|
||||||
|
except kubernetes.client.exceptions.ApiException as e:
|
||||||
|
if e.status == 404:
|
||||||
|
LOG.debug(f"Pod {pod_name} was not found.")
|
||||||
|
else:
|
||||||
|
raise
|
||||||
# TODO(apuimedo) This sleep to be replaced with a polling with
|
# TODO(apuimedo) This sleep to be replaced with a polling with
|
||||||
# timeout for the pod object to be gone from k8s api.
|
# timeout for the pod object to be gone from k8s api.
|
||||||
time.sleep(30)
|
time.sleep(30)
|
||||||
|
@ -18,8 +18,8 @@ from tempest import config
|
|||||||
from tempest.lib import decorators
|
from tempest.lib import decorators
|
||||||
from tempest.lib import exceptions as lib_exc
|
from tempest.lib import exceptions as lib_exc
|
||||||
|
|
||||||
|
|
||||||
from kuryr_tempest_plugin.tests.scenario import base
|
from kuryr_tempest_plugin.tests.scenario import base
|
||||||
|
from kuryr_tempest_plugin.tests.scenario import consts
|
||||||
|
|
||||||
CONF = config.CONF
|
CONF = config.CONF
|
||||||
|
|
||||||
@ -39,6 +39,9 @@ class TestKuryrRestartScenario(base.BaseKuryrScenarioTest):
|
|||||||
def test_kuryr_pod_delete(self):
|
def test_kuryr_pod_delete(self):
|
||||||
# find kuryr CNI and controller pods, delete them one by one and create
|
# find kuryr CNI and controller pods, delete them one by one and create
|
||||||
# a regular pod just after removal
|
# a regular pod just after removal
|
||||||
|
client_pod_name, pod = self.create_pod()
|
||||||
|
self.addCleanup(self.delete_pod, client_pod_name)
|
||||||
|
|
||||||
kube_system_pods = self.get_pod_name_list(
|
kube_system_pods = self.get_pod_name_list(
|
||||||
namespace=CONF.kuryr_kubernetes.kube_system_namespace)
|
namespace=CONF.kuryr_kubernetes.kube_system_namespace)
|
||||||
for kuryr_pod_name in kube_system_pods:
|
for kuryr_pod_name in kube_system_pods:
|
||||||
@ -65,11 +68,15 @@ class TestKuryrRestartScenario(base.BaseKuryrScenarioTest):
|
|||||||
# Check once for controller kuryr pod and once for CNI pod
|
# Check once for controller kuryr pod and once for CNI pod
|
||||||
pod_name, pod = self.create_pod()
|
pod_name, pod = self.create_pod()
|
||||||
self.addCleanup(self.delete_pod, pod_name)
|
self.addCleanup(self.delete_pod, pod_name)
|
||||||
pod_fip = self.assign_fip_to_pod(pod_name)
|
dst_pod_ip = self.get_pod_ip(pod_name)
|
||||||
self.assertIsNotNone(pod_fip['floatingip'][
|
curl_tmpl = self.get_curl_template(dst_pod_ip,
|
||||||
'floating_ip_address'])
|
extra_args='-m 10',
|
||||||
self.assertTrue(self.ping_ip_address(pod_fip[
|
port=8080)
|
||||||
'floatingip']['floating_ip_address']))
|
cmd = ["/bin/sh", "-c", curl_tmpl.format(dst_pod_ip, ':8080')]
|
||||||
|
self.assertIn(consts.POD_OUTPUT, self.exec_command_in_pod(
|
||||||
|
client_pod_name, cmd),
|
||||||
|
"Connectivity from %s to pod with ip %s failed." % (
|
||||||
|
client_pod_name, dst_pod_ip))
|
||||||
|
|
||||||
# Check that both kuryr-pods are up and running
|
# Check that both kuryr-pods are up and running
|
||||||
# The newly created pods are running because create_pod is written
|
# The newly created pods are running because create_pod is written
|
||||||
|
Loading…
Reference in New Issue
Block a user