diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2ba2d99057b9783f60cb96416c03155f67f1a684..8c2b44e86798368eb0f0629ecb12f6770227def3 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -827,6 +827,7 @@ kube-prometheus-stack-alerts: allow_failure: true script: - *debug_information + - export BASIC_AUTH_PW=$(python3 -m openappstack varac-test secrets | grep oas-prometheus-basic-auth | cut -d'=' -f2) - cd test/ - pytest -s -m 'prometheus' --connection=ansible --ansible-inventory=${CLUSTER_DIR}/inventory.yml --hosts='ansible://*' extends: diff --git a/openappstack/cluster.py b/openappstack/cluster.py index 3902ffeba725be9a571f610f0d43112130b98b26..f0eb71572999a2ec12c3fabffe0ce518c200dfc3 100644 --- a/openappstack/cluster.py +++ b/openappstack/cluster.py @@ -75,7 +75,7 @@ class Cluster: if not self.data_loaded: with open(self.inventory_file, 'r') as stream: inventory = yaml.safe_load(stream) - print(inventory) + # print(inventory) # Work with the master node from the inventory self.hostname = inventory['all']['children']['master']['hosts'] self.domain = \ diff --git a/test/pytest/test_prometheus.py b/test/pytest/test_prometheus.py index 14e64a61c58495cadb8febfedada4634b5377f71..d46f6bea05cc82c7063c9a3d446035328c140e43 100755 --- a/test/pytest/test_prometheus.py +++ b/test/pytest/test_prometheus.py @@ -1,5 +1,6 @@ import re import json +import os import pytest @@ -64,7 +65,18 @@ def test_prometheus_alerts(host): print("Starting prometheus test...") - url = 'http://kube-prometheus-stack-kube-prom-prometheus.oas.svc.cluster.local:9090/api/v1/alerts' + basic_auth_pw = os.environ.get("BASIC_AUTH_PW") + assert basic_auth_pw, "Please export the BASIC_AUTH_PW env var!" + + domain = os.environ.get("FQDN") + if domain: + print(f"Using domain {domain} from FQDN environment variable.") + else: + ansible_vars = host.ansible.get_variables() + domain = ansible_vars["domain"] + print(f"Using domain {domain} from ansible inventory.") + + url = f'https://admin:{basic_auth_pw}@prometheus.{domain}/api/v1/alerts' alert_json = json.loads(host.check_output('curl ' + url)) status = alert_json["status"]