Do not rely on ps to check the daemon

Our container images do not install 'ps'. It is something
that, if present, comes from the base image. Since base
images come and go, it is much better to rely on 'cat' which
is always there.

Depends-on: Ic57fbe20b7bf396ea92e0c2cbcca42814ae2a119
Change-Id: I794290c61e7ce7bc61dd8d52d6a6b57ffeebdf23
Signed-off-by: Antoni Segura Puimedon <celebdor@gmail.com>
This commit is contained in:
Antoni Segura Puimedon 2018-09-17 15:08:47 +02:00
parent 32944d50e9
commit 5b6df793c1
2 changed files with 13 additions and 9 deletions

View File

@ -207,20 +207,22 @@ class BaseKuryrScenarioTest(manager.NetworkScenarioTest):
return kuryr_if['versioned_object.data']['id']
def exec_command_in_pod(self, pod_name, command, namespace="default",
stderr=False):
stderr=False, container=None):
api = self.k8s_client.CoreV1Api()
kwargs = dict(command=command, stdin=False, stdout=True, tty=False,
stderr=stderr)
if container is not None:
kwargs['container'] = container
if stderr:
kwargs['_preload_content'] = False
resp = stream(api.connect_get_namespaced_pod_exec, pod_name,
namespace, command=command, stderr=True,
stdin=False, stdout=True, tty=False,
_preload_content=False)
namespace, **kwargs)
# Run until completion
resp.run_forever()
return resp.read_stdout(), resp.read_stderr()
else:
return stream(api.connect_get_namespaced_pod_exec, pod_name,
namespace, command=command, stderr=False,
stdin=False, stdout=True, tty=False)
namespace, **kwargs)
def assign_fip_to_pod(self, pod_name, namespace="default"):
ext_net_id = CONF.network.public_network_id

View File

@ -36,9 +36,11 @@ class TestKuryrDaemon(base.BaseKuryrScenarioTest):
namespace = CONF.kuryr_kubernetes.kube_system_namespace
kube_system_pods = self.get_pod_name_list(
namespace=namespace)
cmd = ["ps", "aux"]
cmd = ['cat', '/proc/1/cmdline']
for kuryr_pod_name in kube_system_pods:
if kuryr_pod_name.startswith('kuryr-cni'):
self.assertIn('kuryr-daemon', self.exec_command_in_pod(
kuryr_pod_name, cmd, namespace))
self.assertIn(
'kuryr-daemon --config-file',
self.exec_command_in_pod(kuryr_pod_name, cmd, namespace,
container='kuryr-cni'))