-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d808ab3
commit ea27722
Showing
1 changed file
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |