From 67427f5b39288414e9426f8321479eb2a8193054 Mon Sep 17 00:00:00 2001 From: okozachenko Date: Mon, 20 Apr 2020 13:51:18 -0700 Subject: [PATCH] Add test to check the http probes has no path Change-Id: I0e3214326e6006d5b60ba3ffe6f762c92aea2d5c --- .../templates/memcached/statefulset.yml.j2 | 4 ++-- openstack_operator/tests/unit/base.py | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/openstack_operator/templates/memcached/statefulset.yml.j2 b/openstack_operator/templates/memcached/statefulset.yml.j2 index a1f4a15c..5ed70d64 100644 --- a/openstack_operator/templates/memcached/statefulset.yml.j2 +++ b/openstack_operator/templates/memcached/statefulset.yml.j2 @@ -63,11 +63,11 @@ spec: containerPort: 9150 livenessProbe: httpGet: - path: /metrics + path: / port: metrics readinessProbe: httpGet: - path: /metrics + path: / port: metrics resources: limits: diff --git a/openstack_operator/tests/unit/base.py b/openstack_operator/tests/unit/base.py index 6f554e26..4fd55021 100644 --- a/openstack_operator/tests/unit/base.py +++ b/openstack_operator/tests/unit/base.py @@ -63,6 +63,21 @@ class KubernetesAppTestCaseMixin: for container in self.object['spec']['template']['spec']['containers']: self.assertIn('resources', container) + def test_container_http_probes_have_no_metrics_path(self): + """Ensure that http probes (liveness/rediness) of all containers + don't have metrics path""" + for container in self.object['spec']['template']['spec']['containers']: + if 'httpGet' in container['readinessProbe']: + self.assertNotEqual( + container['readinessProbe']['httpGet']['path'], + '/metrics' + ) + if 'httpGet' in container['livenessProbe']: + self.assertNotEqual( + container['livenessProbe']['httpGet']['path'], + '/metrics' + ) + class DeploymentTestCase(KubernetesObjectTestCase, KubernetesAppTestCaseMixin):