Add test to check the http probes has no path

Change-Id: I0e3214326e6006d5b60ba3ffe6f762c92aea2d5c
This commit is contained in:
okozachenko 2020-04-20 13:51:18 -07:00
parent 0e7bc74b79
commit 67427f5b39
2 changed files with 17 additions and 2 deletions

View File

@ -63,11 +63,11 @@ spec:
containerPort: 9150 containerPort: 9150
livenessProbe: livenessProbe:
httpGet: httpGet:
path: /metrics path: /
port: metrics port: metrics
readinessProbe: readinessProbe:
httpGet: httpGet:
path: /metrics path: /
port: metrics port: metrics
resources: resources:
limits: limits:

View File

@ -63,6 +63,21 @@ class KubernetesAppTestCaseMixin:
for container in self.object['spec']['template']['spec']['containers']: for container in self.object['spec']['template']['spec']['containers']:
self.assertIn('resources', container) 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, class DeploymentTestCase(KubernetesObjectTestCase,
KubernetesAppTestCaseMixin): KubernetesAppTestCaseMixin):