Fixes for stacklight tests
1. Move test_prometheus_alert_count from curl to requests
2. Add authorization for prometheus and alermanager
Change-Id: Ic29c957c0b93fc8762d22624d1314af441eeea0e
Related-prod: PROD-31822 PROD-34064
diff --git a/test_set/cvp-sanity/tests/test_ui_addresses.py b/test_set/cvp-sanity/tests/test_ui_addresses.py
index 5e6ccdb..12ff05c 100644
--- a/test_set/cvp-sanity/tests/test_ui_addresses.py
+++ b/test_set/cvp-sanity/tests/test_ui_addresses.py
@@ -1,3 +1,4 @@
+import requests
import pytest
@@ -101,15 +102,24 @@
@pytest.mark.usefixtures('check_prometheus')
def test_public_ui_prometheus(local_salt_client, ctl_nodes_pillar):
IP = local_salt_client.pillar_get(param='_param:cluster_public_host')
+ prometheus_password_old = local_salt_client.pillar_get(
+ param='_param:keepalived_prometheus_vip_password_generated')
+ prometheus_password = local_salt_client.pillar_get(
+ param='_param:prometheus_server_proxy_password_generated')
proto = local_salt_client.pillar_get(
param='_param:cluster_public_protocol')
- port = '15010'
- url = "{}://{}:{}".format(proto, IP, port)
- result = local_salt_client.cmd(
- tgt=ctl_nodes_pillar,
- param='curl -k {}/graph 2>&1 | grep Prometheus'.format(url),
- expr_form='pillar')
- assert len(result[result.keys()[0]]) != 0, (
+ proxies = {"http": None, "https": None}
+ if prometheus_password == '':
+ prometheus_password = prometheus_password_old
+ response = requests.get(
+ '{0}://{1}:15010/graph'.format(proto, IP),
+ proxies=proxies,
+ auth=('prometheus', prometheus_password))
+ assert response.status_code == 200, (
+ 'Issues with accessing public prometheus ui on {}:\n{}'.format(
+ IP, response.text)
+ )
+ assert response.content.find('Prometheus Time Series Collection') > -1, (
'Public Prometheus page is not reachable on {} from ctl '
'nodes'.format(url)
)
@@ -138,15 +148,24 @@
@pytest.mark.usefixtures('check_prometheus')
def test_public_ui_alert_manager(local_salt_client, ctl_nodes_pillar):
IP = local_salt_client.pillar_get(param='_param:cluster_public_host')
+ alermanager_password_old = local_salt_client.pillar_get(
+ param='_param:keepalived_prometheus_vip_password_generated')
+ alermanager_password = local_salt_client.pillar_get(
+ param='_param:prometheus_alermanager_proxy_password_generated')
proto = local_salt_client.pillar_get(
param='_param:cluster_public_protocol')
- port = '15011'
- url = "{}://{}:{}".format(proto, IP, port)
- result = local_salt_client.cmd(
- tgt=ctl_nodes_pillar,
- param='curl -k -s {}/ | grep Alertmanager'.format(url),
- expr_form='pillar')
- assert len(result[result.keys()[0]]) != 0, (
+ proxies = {"http": None, "https": None}
+ if alermanager_password == '':
+ alermanager_password = alermanager_password_old
+ response = requests.get(
+ '{0}://{1}:15011/'.format(proto, IP),
+ proxies=proxies,
+ auth=('alertmanager', alermanager_password))
+ assert response.status_code == 200, (
+ 'Issues with accessing public alert manager ui on {}:\n{}'.format(
+ IP, response.text)
+ )
+ assert response.content.find('<title>Alertmanager</title>') > -1, (
'Public AlertManager page is not reachable on {} '
'from ctl nodes'.format(url)
)