From 5b6df793c13733ecbbd2fed8510deaaa64470fff Mon Sep 17 00:00:00 2001 From: Antoni Segura Puimedon Date: Mon, 17 Sep 2018 15:08:47 +0200 Subject: [PATCH] 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 --- kuryr_tempest_plugin/tests/scenario/base.py | 14 ++++++++------ kuryr_tempest_plugin/tests/scenario/test_daemon.py | 8 +++++--- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/kuryr_tempest_plugin/tests/scenario/base.py b/kuryr_tempest_plugin/tests/scenario/base.py index 527a9497..6765341f 100644 --- a/kuryr_tempest_plugin/tests/scenario/base.py +++ b/kuryr_tempest_plugin/tests/scenario/base.py @@ -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 diff --git a/kuryr_tempest_plugin/tests/scenario/test_daemon.py b/kuryr_tempest_plugin/tests/scenario/test_daemon.py index a63afb60..a332388f 100644 --- a/kuryr_tempest_plugin/tests/scenario/test_daemon.py +++ b/kuryr_tempest_plugin/tests/scenario/test_daemon.py @@ -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'))