Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix: re-enable prometheus tests #192

Merged
merged 1 commit into from
Jul 19, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions tests/zenko_e2e/prometheus/test_basic.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import pytest
from zenko_e2e.conftest import zenko_helm_release


# @pytest.mark.skip('Waiting for PIPDEP-538')
@pytest.mark.nondestructive
@pytest.mark.conformance
def test_prometheus_healthy(prometheus_client):
resp = prometheus_client.get_admin('healthy')
assert resp.status_code == 200


SERVICE = 'kubernetes-service-endpoints'
POD = 'kubernetes-pods'


# @pytest.mark.skip('Waiting for PIPDEP-538')
@pytest.mark.nondestructive
@pytest.mark.conformance
@pytest.mark.parametrize('job,name', [
(SERVICE, '{}-redis'.format(zenko_helm_release())),
(POD, '{}-zenko-queue-0'.format(zenko_helm_release())),
])
def test_prometheus_targets(prometheus_client, k8s_namespace,
zenko_helm_release, job, name):
targets = prometheus_client.get_targets()

active_targets = targets['activeTargets']
in_namespace = (
target for target in active_targets
if target['labels'].get('kubernetes_namespace') == k8s_namespace)
this_release = (
target for target in in_namespace
if target['labels'].get('release') == zenko_helm_release)
expected_job = (
target for target in this_release
if target['labels'].get('job') == job)

if job == SERVICE:
results = (
target for target in expected_job
if target['labels'].get('kubernetes_name') == name)
elif job == POD:
results = (
target for target in expected_job
if target['labels'].get('kubernetes_pod_name') == name)
else:
raise ValueError('Unknown value for `job`: {}'.format(job))

results = list(results)

assert results != []
assert all(result['health'] == 'up' for result in results)