Merge "Remove accidentally added file"
diff --git a/test_set/cvp-sanity/fixtures/base.py b/test_set/cvp-sanity/fixtures/base.py
index 60b8f28..0b83260 100644
--- a/test_set/cvp-sanity/fixtures/base.py
+++ b/test_set/cvp-sanity/fixtures/base.py
@@ -16,6 +16,50 @@
 
 
 @pytest.fixture(scope='session')
+def ctl_nodes_pillar(local_salt_client):
+    '''Return controller node pillars (OS or k8s ctls).
+       This will help to identify nodes to use for UI curl tests.
+       If no platform is installed (no OS or k8s) we need to skip
+       the test (product team use case).
+    '''
+    salt_output = local_salt_client.cmd(
+        'keystone:server',
+        'test.ping',
+        expr_form='pillar')
+    if salt_output:
+        return "keystone:server"
+    else:
+        salt_output = local_salt_client.cmd(
+            'etcd:server',
+            'test.ping',
+            expr_form='pillar')
+        return "etcd:server" if salt_output else pytest.skip("Neither \
+            Openstack nor k8s is found. Skipping test")
+
+
+@pytest.fixture(scope='session')
+def check_openstack(local_salt_client):
+    salt_output = local_salt_client.cmd(
+        'keystone:server',
+        'test.ping',
+        expr_form='pillar')
+    if not salt_output:
+        pytest.skip("Openstack not found or keystone:server pillar \
+          are not found on this environment.")
+
+
+@pytest.fixture(scope='session')
+def check_drivetrain(local_salt_client):
+    salt_output = local_salt_client.cmd(
+        'I@jenkins:client and not I@salt:master',
+        'test.ping',
+        expr_form='compound')
+    if not salt_output:
+        pytest.skip("Drivetrain service or jenkins:client pillar \
+          are not found on this environment.")
+
+
+@pytest.fixture(scope='session')
 def check_prometheus(local_salt_client):
     salt_output = local_salt_client.cmd(
         'prometheus:server',
diff --git a/test_set/cvp-sanity/global_config.yaml b/test_set/cvp-sanity/global_config.yaml
index 4146147..ab593d7 100644
--- a/test_set/cvp-sanity/global_config.yaml
+++ b/test_set/cvp-sanity/global_config.yaml
@@ -90,6 +90,4 @@
 
 # ntp test setting
 # this test may skip specific node (use fqdn)
-test_ntp_sync:
-  { #"skipped_nodes": [""],
-    "time_deviation": 1}
+ntp_skipped_nodes: [""]
diff --git a/test_set/cvp-sanity/tests/test_contrail.py b/test_set/cvp-sanity/tests/test_contrail.py
index 5e7e108..e5722bd 100644
--- a/test_set/cvp-sanity/tests/test_contrail.py
+++ b/test_set/cvp-sanity/tests/test_contrail.py
@@ -1,5 +1,6 @@
 import pytest
 import json
+import utils
 
 pytestmark = pytest.mark.usefixtures("contrail")
 
@@ -85,3 +86,18 @@
         'The length of vRouters {} differs' \
         ' from the length of compute nodes {}'.format(actual_vrouter_count,
                                                       len(cs.keys()))
+
+
+def test_public_ui_contrail(local_salt_client, ctl_nodes_pillar):
+    IP = utils.get_monitoring_ip('cluster_public_host')
+    protocol = 'https'
+    port = '8143'
+    url = "{}://{}:{}".format(protocol, IP, port)
+    result = local_salt_client.cmd(
+        ctl_nodes_pillar,
+        'cmd.run',
+        ['curl -k {}/ 2>&1 | \
+         grep Contrail'.format(url)],
+        expr_form='pillar')
+    assert len(result[result.keys()[0]]) != 0, \
+        'Public Contrail UI is not reachable on {} from ctl nodes'.format(url)
diff --git a/test_set/cvp-sanity/tests/test_mtu.py b/test_set/cvp-sanity/tests/test_mtu.py
index 9930fea..417bc1a 100644
--- a/test_set/cvp-sanity/tests/test_mtu.py
+++ b/test_set/cvp-sanity/tests/test_mtu.py
@@ -56,7 +56,9 @@
                 diff.append(total[node][interf])
                 row.append("{}: {}".format(node, total[node][interf]))
             else:
-                row.append("{}: No interface".format(node))
+                # skip node with no virbr0 or virbr0-nic interfaces
+                if interf not in ['virbr0', 'virbr0-nic']:
+                    row.append("{}: No interface".format(node))
         if diff.count(diff[0]) < len(nodes):
             row.sort()
             row.insert(0, interf)
diff --git a/test_set/cvp-sanity/tests/test_ntp_sync.py b/test_set/cvp-sanity/tests/test_ntp_sync.py
index 23a98a3..3636f14 100644
--- a/test_set/cvp-sanity/tests/test_ntp_sync.py
+++ b/test_set/cvp-sanity/tests/test_ntp_sync.py
@@ -1,39 +1,34 @@
 import json
-import os
-
 import utils
 
 
 def test_ntp_sync(local_salt_client):
-    testname = os.path.basename(__file__).split('.')[0]
-    active_nodes = utils.get_active_nodes(os.path.basename(__file__))
+    """Test checks that system time is the same across all nodes"""
+
+    active_nodes = utils.get_active_nodes()
     config = utils.get_configuration()
-    fail = {}
-    saltmaster_time = int(local_salt_client.cmd(
-        'salt:master',
-        'cmd.run',
-        ['date +%s'],
-        expr_form='pillar').values()[0])
     nodes_time = local_salt_client.cmd(
         utils.list_to_target_string(active_nodes, 'or'),
         'cmd.run',
         ['date +%s'],
         expr_form='compound')
-    diff = config.get(testname)["time_deviation"] or 30
+    result = {}
     for node, time in nodes_time.iteritems():
-        if (int(time) - saltmaster_time) > diff or \
-                (int(time) - saltmaster_time) < -diff:
-            fail[node] = time
-
-    assert not fail, 'SaltMaster time: {}\n' \
-                     'Nodes with time mismatch:\n {}'.format(saltmaster_time,
-                                                             fail)
+        if node in config.get("ntp_skipped_nodes"):
+            continue
+        if time in result:
+            result[time].append(node)
+            result[time].sort()
+        else:
+            result[time] = [node]
+    assert len(result) <= 1, 'Not all nodes have the same time:\n {}'.format(
+                             json.dumps(result, indent=4))
 
 
 def test_ntp_peers_state(local_salt_client):
-    """Test gets ntpq peers state and check the system peer is declared"""
+    """Test gets ntpq peers state and checks the system peer is declared"""
 
-    active_nodes = utils.get_active_nodes(os.path.basename(__file__))
+    active_nodes = utils.get_active_nodes()
     state = local_salt_client.cmd(
         utils.list_to_target_string(active_nodes, 'or'),
         'cmd.run',
diff --git a/test_set/cvp-sanity/tests/test_stacklight.py b/test_set/cvp-sanity/tests/test_stacklight.py
index bd6401d..c91a5f6 100644
--- a/test_set/cvp-sanity/tests/test_stacklight.py
+++ b/test_set/cvp-sanity/tests/test_stacklight.py
@@ -121,13 +121,13 @@
 
 
 @pytest.mark.usefixtures('check_prometheus')
-def test_prometheus_alert_count(local_salt_client):
+def test_prometheus_alert_count(local_salt_client, ctl_nodes_pillar):
     IP = utils.get_monitoring_ip('cluster_public_host')
     # keystone:server can return 3 nodes instead of 1
     # this will be fixed later
     # TODO
     nodes_info = local_salt_client.cmd(
-        'keystone:server',
+        ctl_nodes_pillar,
         'cmd.run',
         ['curl -s http://{}:15010/alerts | grep icon-chevron-down | '
          'grep -v "0 active"'.format(IP)],
diff --git a/test_set/cvp-sanity/tests/test_ui_addresses.py b/test_set/cvp-sanity/tests/test_ui_addresses.py
index 1bb67ec..a2f0f2d 100644
--- a/test_set/cvp-sanity/tests/test_ui_addresses.py
+++ b/test_set/cvp-sanity/tests/test_ui_addresses.py
@@ -2,7 +2,8 @@
 import pytest
 
 
-def test_ui_horizon(local_salt_client):
+@pytest.mark.usefixtures('check_openstack')
+def test_ui_horizon(local_salt_client, ctl_nodes_pillar):
     salt_output = local_salt_client.cmd(
         'horizon:server',
         'pillar.get',
@@ -13,7 +14,7 @@
     IP = [salt_output[node] for node in salt_output
           if salt_output[node]]
     result = local_salt_client.cmd(
-        'keystone:server',
+        ctl_nodes_pillar,
         'cmd.run',
         ['curl --insecure https://{}/auth/login/ 2>&1 | \
          grep Login'.format(IP[0])],
@@ -23,14 +24,30 @@
         IP[0])
 
 
+@pytest.mark.usefixtures('check_openstack')
+def test_public_openstack(local_salt_client, ctl_nodes_pillar):
+    IP = utils.get_monitoring_ip('cluster_public_host')
+    protocol = 'https'
+    port = '5000'
+    url = "{}://{}:{}/v3".format(protocol, IP, port)
+    result = local_salt_client.cmd(
+        ctl_nodes_pillar,
+        'cmd.run',
+        ['curl -k {}/ 2>&1 | \
+         grep stable'.format(url)],
+        expr_form='pillar')
+    assert len(result[result.keys()[0]]) != 0, \
+        'Public Openstack url is not reachable on {} from ctl nodes'.format(url)
+
+
 @pytest.mark.usefixtures('check_kibana')
-def test_internal_ui_kibana(local_salt_client):
+def test_internal_ui_kibana(local_salt_client, ctl_nodes_pillar):
     IP = utils.get_monitoring_ip('stacklight_log_address')
     protocol = 'http'
     port = '5601'
     url = "{}://{}:{}".format(protocol, IP, port)
     result = local_salt_client.cmd(
-        'keystone:server',
+        ctl_nodes_pillar,
         'cmd.run',
         ['curl {}/app/kibana 2>&1 | \
          grep loading'.format(url)],
@@ -41,13 +58,13 @@
 
 
 @pytest.mark.usefixtures('check_kibana')
-def test_public_ui_kibana(local_salt_client):
-    IP = utils.get_monitoring_ip('openstack_proxy_address')
+def test_public_ui_kibana(local_salt_client, ctl_nodes_pillar):
+    IP = utils.get_monitoring_ip('cluster_public_host')
     protocol = 'https'
     port = '5601'
     url = "{}://{}:{}".format(protocol, IP, port)
     result = local_salt_client.cmd(
-        'keystone:server',
+        ctl_nodes_pillar,
         'cmd.run',
         ['curl {}/app/kibana 2>&1 | \
          grep loading'.format(url)],
@@ -58,13 +75,13 @@
 
 
 @pytest.mark.usefixtures('check_prometheus')
-def test_internal_ui_prometheus(local_salt_client):
+def test_internal_ui_prometheus(local_salt_client, ctl_nodes_pillar):
     IP = utils.get_monitoring_ip('stacklight_monitor_address')
     protocol = 'http'
     port = '15010'
     url = "{}://{}:{}".format(protocol, IP, port)
     result = local_salt_client.cmd(
-        'keystone:server',
+        ctl_nodes_pillar,
         'cmd.run',
         ['curl {}/graph 2>&1 | \
          grep Prometheus'.format(url)],
@@ -75,13 +92,13 @@
 
 
 @pytest.mark.usefixtures('check_prometheus')
-def test_public_ui_prometheus(local_salt_client):
-    IP = utils.get_monitoring_ip('openstack_proxy_address')
+def test_public_ui_prometheus(local_salt_client, ctl_nodes_pillar):
+    IP = utils.get_monitoring_ip('cluster_public_host')
     protocol = 'https'
     port = '15010'
     url = "{}://{}:{}".format(protocol, IP, port)
     result = local_salt_client.cmd(
-        'keystone:server',
+        ctl_nodes_pillar,
         'cmd.run',
         ['curl {}/graph 2>&1 | \
          grep Prometheus'.format(url)],
@@ -92,13 +109,13 @@
 
 
 @pytest.mark.usefixtures('check_prometheus')
-def test_internal_ui_alert_manager(local_salt_client):
+def test_internal_ui_alert_manager(local_salt_client, ctl_nodes_pillar):
     IP = utils.get_monitoring_ip('stacklight_monitor_address')
     protocol = 'http'
     port = '15011'
     url = "{}://{}:{}".format(protocol, IP, port)
     result = local_salt_client.cmd(
-        'keystone:server',
+        ctl_nodes_pillar,
         'cmd.run',
         ['curl -s {}/ | grep Alertmanager'.format(url)],
         expr_form='pillar')
@@ -108,13 +125,13 @@
 
 
 @pytest.mark.usefixtures('check_prometheus')
-def test_public_ui_alert_manager(local_salt_client):
-    IP = utils.get_monitoring_ip('openstack_proxy_address')
+def test_public_ui_alert_manager(local_salt_client, ctl_nodes_pillar):
+    IP = utils.get_monitoring_ip('cluster_public_host')
     protocol = 'https'
     port = '15011'
     url = "{}://{}:{}".format(protocol, IP, port)
     result = local_salt_client.cmd(
-        'keystone:server',
+        ctl_nodes_pillar,
         'cmd.run',
         ['curl -s {}/ | grep Alertmanager'.format(url)],
         expr_form='pillar')
@@ -124,13 +141,13 @@
 
 
 @pytest.mark.usefixtures('check_grafana')
-def test_internal_ui_grafana(local_salt_client):
+def test_internal_ui_grafana(local_salt_client, ctl_nodes_pillar):
     IP = utils.get_monitoring_ip('stacklight_monitor_address')
     protocol = 'http'
     port = '15013'
     url = "{}://{}:{}".format(protocol, IP, port)
     result = local_salt_client.cmd(
-        'keystone:server',
+        ctl_nodes_pillar,
         'cmd.run',
         ['curl {}/login 2>&1 | grep Grafana'.format(url)],
         expr_form='pillar')
@@ -140,13 +157,13 @@
 
 
 @pytest.mark.usefixtures('check_grafana')
-def test_public_ui_grafana(local_salt_client):
-    IP = utils.get_monitoring_ip('openstack_proxy_address')
+def test_public_ui_grafana(local_salt_client, ctl_nodes_pillar):
+    IP = utils.get_monitoring_ip('cluster_public_host')
     protocol = 'https'
     port = '8084'
     url = "{}://{}:{}".format(protocol, IP, port)
     result = local_salt_client.cmd(
-        'keystone:server',
+        ctl_nodes_pillar,
         'cmd.run',
         ['curl {}/login 2>&1 | grep Grafana'.format(url)],
         expr_form='pillar')
@@ -155,13 +172,13 @@
 
 
 @pytest.mark.usefixtures('check_alerta')
-def test_internal_ui_alerta(local_salt_client):
+def test_internal_ui_alerta(local_salt_client, ctl_nodes_pillar):
     IP = utils.get_monitoring_ip('stacklight_monitor_address')
     protocol = 'http'
     port = '15017'
     url = "{}://{}:{}".format(protocol, IP, port)
     result = local_salt_client.cmd(
-        'keystone:server',
+        ctl_nodes_pillar,
         'cmd.run',
         ['curl {}/ 2>&1 | \
          grep Alerta'.format(url)],
@@ -171,16 +188,48 @@
 
 
 @pytest.mark.usefixtures('check_alerta')
-def test_public_ui_alerta(local_salt_client):
-    IP = utils.get_monitoring_ip('openstack_proxy_address')
+def test_public_ui_alerta(local_salt_client, ctl_nodes_pillar):
+    IP = utils.get_monitoring_ip('cluster_public_host')
     protocol = 'https'
     port = '15017'
     url = "{}://{}:{}".format(protocol, IP, port)
     result = local_salt_client.cmd(
-        'keystone:server',
+        ctl_nodes_pillar,
         '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)
+
+
+@pytest.mark.usefixtures('check_drivetrain')
+def test_public_ui_jenkins(local_salt_client, ctl_nodes_pillar):
+    IP = utils.get_monitoring_ip('cluster_public_host')
+    protocol = 'https'
+    port = '8081'
+    url = "{}://{}:{}".format(protocol, IP, port)
+    result = local_salt_client.cmd(
+        ctl_nodes_pillar,
+        'cmd.run',
+        ['curl -k {}/ 2>&1 | \
+         grep Authentication'.format(url)],
+        expr_form='pillar')
+    assert len(result[result.keys()[0]]) != 0, \
+        'Public Jenkins page is not reachable on {} from ctl nodes'.format(url)
+
+
+@pytest.mark.usefixtures('check_drivetrain')
+def test_public_ui_gerrit(local_salt_client, ctl_nodes_pillar):
+    IP = utils.get_monitoring_ip('cluster_public_host')
+    protocol = 'https'
+    port = '8070'
+    url = "{}://{}:{}".format(protocol, IP, port)
+    result = local_salt_client.cmd(
+        ctl_nodes_pillar,
+        'cmd.run',
+        ['curl -k {}/ 2>&1 | \
+         grep "Gerrit Code Review"'.format(url)],
+        expr_form='pillar')
+    assert len(result[result.keys()[0]]) != 0, \
+        'Public Gerrit page is not reachable on {} from ctl nodes'.format(url)