Merge "Small fix: test nodes in ElasticSearch will get > than 500 nodes"
diff --git a/test_set/cvp-sanity/fixtures/base.py b/test_set/cvp-sanity/fixtures/base.py
index dccee56..60b8f28 100644
--- a/test_set/cvp-sanity/fixtures/base.py
+++ b/test_set/cvp-sanity/fixtures/base.py
@@ -27,6 +27,17 @@
 
 
 @pytest.fixture(scope='session')
+def check_alerta(local_salt_client):
+    salt_output = local_salt_client.cmd(
+        'prometheus:alerta',
+        'test.ping',
+        expr_form='pillar')
+    if not salt_output:
+        pytest.skip("Alerta service or prometheus:alerta pillar \
+              are not found on this environment.")
+
+
+@pytest.fixture(scope='session')
 def check_kibana(local_salt_client):
     salt_output = local_salt_client.cmd(
         'kibana:server',
diff --git a/test_set/cvp-sanity/tests/test_nodes.py b/test_set/cvp-sanity/tests/test_nodes.py
new file mode 100644
index 0000000..5f8b2dc
--- /dev/null
+++ b/test_set/cvp-sanity/tests/test_nodes.py
@@ -0,0 +1,19 @@
+import json
+import pytest
+
+
+def test_minions_status(local_salt_client):
+    result = local_salt_client.cmd(
+        'salt:master',
+        'cmd.run',
+        ['salt-run manage.status timeout=10 --out=json'],
+        expr_form='pillar')
+    statuses = {}
+    try:
+        statuses = json.loads(result.values()[0])
+    except Exception as e:
+        pytest.fail(
+            "Could not check the result: {}\n"
+            "Nodes status result: {}".format(e, result))
+    assert not statuses["down"], "Some minions are down:\n {}".format(
+        statuses["down"])
diff --git a/test_set/cvp-sanity/tests/test_ui_addresses.py b/test_set/cvp-sanity/tests/test_ui_addresses.py
index 3f6f3a3..1bb67ec 100644
--- a/test_set/cvp-sanity/tests/test_ui_addresses.py
+++ b/test_set/cvp-sanity/tests/test_ui_addresses.py
@@ -24,50 +24,163 @@
 
 
 @pytest.mark.usefixtures('check_kibana')
-def test_ui_kibana(local_salt_client):
+def test_internal_ui_kibana(local_salt_client):
     IP = utils.get_monitoring_ip('stacklight_log_address')
+    protocol = 'http'
+    port = '5601'
+    url = "{}://{}:{}".format(protocol, IP, port)
     result = local_salt_client.cmd(
         'keystone:server',
         'cmd.run',
-        ['curl http://{}:5601/app/kibana 2>&1 | \
-         grep loading'.format(IP)],
+        ['curl {}/app/kibana 2>&1 | \
+         grep loading'.format(url)],
         expr_form='pillar')
     assert len(result[result.keys()[0]]) != 0, \
-        'Kibana login page is not reachable on {} from ctl nodes'.format(IP)
+        'Internal Kibana login page is not reachable on {} ' \
+        'from ctl nodes'.format(url)
+
+
+@pytest.mark.usefixtures('check_kibana')
+def test_public_ui_kibana(local_salt_client):
+    IP = utils.get_monitoring_ip('openstack_proxy_address')
+    protocol = 'https'
+    port = '5601'
+    url = "{}://{}:{}".format(protocol, IP, port)
+    result = local_salt_client.cmd(
+        'keystone:server',
+        'cmd.run',
+        ['curl {}/app/kibana 2>&1 | \
+         grep loading'.format(url)],
+        expr_form='pillar')
+    assert len(result[result.keys()[0]]) != 0, \
+        'Public Kibana login page is not reachable on {} ' \
+        'from ctl nodes'.format(url)
 
 
 @pytest.mark.usefixtures('check_prometheus')
-def test_ui_prometheus(local_salt_client):
+def test_internal_ui_prometheus(local_salt_client):
     IP = utils.get_monitoring_ip('stacklight_monitor_address')
+    protocol = 'http'
+    port = '15010'
+    url = "{}://{}:{}".format(protocol, IP, port)
     result = local_salt_client.cmd(
         'keystone:server',
         'cmd.run',
-        ['curl http://{}:15010/graph 2>&1 | \
-         grep Prometheus'.format(IP)],
+        ['curl {}/graph 2>&1 | \
+         grep Prometheus'.format(url)],
         expr_form='pillar')
     assert len(result[result.keys()[0]]) != 0, \
-        'Prometheus page is not reachable on {} from ctl nodes'.format(IP)
+        'Internal Prometheus page is not reachable on {} ' \
+        'from ctl nodes'.format(url)
 
 
 @pytest.mark.usefixtures('check_prometheus')
-def test_ui_alert_manager(local_salt_client):
-    IP = utils.get_monitoring_ip('stacklight_monitor_address')
+def test_public_ui_prometheus(local_salt_client):
+    IP = utils.get_monitoring_ip('openstack_proxy_address')
+    protocol = 'https'
+    port = '15010'
+    url = "{}://{}:{}".format(protocol, IP, port)
     result = local_salt_client.cmd(
         'keystone:server',
         'cmd.run',
-        ['curl -s http://{}:15011/ | grep Alertmanager'.format(IP)],
+        ['curl {}/graph 2>&1 | \
+         grep Prometheus'.format(url)],
         expr_form='pillar')
     assert len(result[result.keys()[0]]) != 0, \
-        'AlertManager page is not reachable on {} from ctl nodes'.format(IP)
+        'Public Prometheus page is not reachable on {} ' \
+        'from ctl nodes'.format(url)
+
+
+@pytest.mark.usefixtures('check_prometheus')
+def test_internal_ui_alert_manager(local_salt_client):
+    IP = utils.get_monitoring_ip('stacklight_monitor_address')
+    protocol = 'http'
+    port = '15011'
+    url = "{}://{}:{}".format(protocol, IP, port)
+    result = local_salt_client.cmd(
+        'keystone:server',
+        'cmd.run',
+        ['curl -s {}/ | grep Alertmanager'.format(url)],
+        expr_form='pillar')
+    assert len(result[result.keys()[0]]) != 0, \
+        'Internal AlertManager page is not reachable on {} ' \
+        'from ctl nodes'.format(url)
+
+
+@pytest.mark.usefixtures('check_prometheus')
+def test_public_ui_alert_manager(local_salt_client):
+    IP = utils.get_monitoring_ip('openstack_proxy_address')
+    protocol = 'https'
+    port = '15011'
+    url = "{}://{}:{}".format(protocol, IP, port)
+    result = local_salt_client.cmd(
+        'keystone:server',
+        'cmd.run',
+        ['curl -s {}/ | grep Alertmanager'.format(url)],
+        expr_form='pillar')
+    assert len(result[result.keys()[0]]) != 0, \
+        'Public AlertManager page is not reachable on {} ' \
+        'from ctl nodes'.format(url)
 
 
 @pytest.mark.usefixtures('check_grafana')
-def test_ui_grafana(local_salt_client):
+def test_internal_ui_grafana(local_salt_client):
     IP = utils.get_monitoring_ip('stacklight_monitor_address')
+    protocol = 'http'
+    port = '15013'
+    url = "{}://{}:{}".format(protocol, IP, port)
     result = local_salt_client.cmd(
         'keystone:server',
         'cmd.run',
-        ['curl http://{}:15013/login 2>&1 | grep Grafana'.format(IP)],
+        ['curl {}/login 2>&1 | grep Grafana'.format(url)],
         expr_form='pillar')
     assert len(result[result.keys()[0]]) != 0, \
-        'Grafana page is not reachable on {} from ctl nodes'.format(IP)
+        'Internal Grafana page is not reachable on {} ' \
+        'from ctl nodes'.format(url)
+
+
+@pytest.mark.usefixtures('check_grafana')
+def test_public_ui_grafana(local_salt_client):
+    IP = utils.get_monitoring_ip('openstack_proxy_address')
+    protocol = 'https'
+    port = '8084'
+    url = "{}://{}:{}".format(protocol, IP, port)
+    result = local_salt_client.cmd(
+        'keystone:server',
+        'cmd.run',
+        ['curl {}/login 2>&1 | grep Grafana'.format(url)],
+        expr_form='pillar')
+    assert len(result[result.keys()[0]]) != 0, \
+        'Public Grafana page is not reachable on {} from ctl nodes'.format(url)
+
+
+@pytest.mark.usefixtures('check_alerta')
+def test_internal_ui_alerta(local_salt_client):
+    IP = utils.get_monitoring_ip('stacklight_monitor_address')
+    protocol = 'http'
+    port = '15017'
+    url = "{}://{}:{}".format(protocol, IP, port)
+    result = local_salt_client.cmd(
+        'keystone:server',
+        'cmd.run',
+        ['curl {}/ 2>&1 | \
+         grep Alerta'.format(url)],
+        expr_form='pillar')
+    assert len(result[result.keys()[0]]) != 0, \
+        'Internal Alerta page is not reachable on {} from ctl nodes'.format(url)
+
+
+@pytest.mark.usefixtures('check_alerta')
+def test_public_ui_alerta(local_salt_client):
+    IP = utils.get_monitoring_ip('openstack_proxy_address')
+    protocol = 'https'
+    port = '15017'
+    url = "{}://{}:{}".format(protocol, IP, port)
+    result = local_salt_client.cmd(
+        'keystone:server',
+        'cmd.run',
+        ['curl {}/ 2>&1 | \
+         grep Alerta'.format(url)],
+        expr_form='pillar')
+    assert len(result[result.keys()[0]]) != 0, \
+        'Public Alerta page is not reachable on {} from ctl nodes'.format(url)