Use standard HTTP ports for UI

All StackLight plugins will switch to use standard HTTP ports for their
UI (Kibana, Grafana and Nagios UI). This change checks whether Grafana
and Nagios use the old (non-standard) ports, if not the tests will use
the standard port numbers.
This avoids breaking the CI after the patches have landed in the
respective plugin repositories.


Co-Authored-By: Simon Pasquier <spasquier@mirantis.com>

Change-Id: Id94cae82b2bea92e049975ccc9e91e4383f52931
This commit is contained in:
Swann Croiset 2016-07-05 16:16:19 +02:00
parent bc0b47da85
commit 1bac5769e9
3 changed files with 47 additions and 7 deletions

View File

@ -12,6 +12,9 @@
# License for the specific language governing permissions and limitations
# under the License.
from contextlib import closing
import socket
from proboscis import asserts
import requests
@ -56,3 +59,15 @@ def check_process_count(remote, process, count):
len(pids), count,
msg.format(process=process, count=count, got=len(pids)))
return pids
def check_port(address, port):
"""Check whether or not a TCP port is open.
:param address: server address
:type address: str
:param port: server port
:type port: str
"""
with closing(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) as sock:
return sock.connect_ex((address, port)) == 0

View File

@ -23,6 +23,18 @@ from stacklight_tests.influxdb_grafana import plugin_settings
class InfluxdbPluginApi(base_test.PluginApi):
def __init__(self):
super(InfluxdbPluginApi, self).__init__()
self._grafana_port = None
@property
def grafana_port(self):
if self._grafana_port is None:
self._grafana_port = 80
if self.checkers.check_port(self.get_plugin_vip(), 8000):
self._grafana_port = 8000
return self._grafana_port
def get_plugin_settings(self):
return plugin_settings
@ -39,7 +51,8 @@ class InfluxdbPluginApi(base_test.PluginApi):
return self.helpers.get_plugin_vip(self.settings.vip_name)
def get_grafana_url(self, path=''):
return "http://{0}:8000/{1}".format(self.get_plugin_vip(), path)
return "http://{0}:{1}/{2}".format(self.get_plugin_vip(),
self.grafana_port, path)
def get_influxdb_url(self, path=''):
return "http://{0}:8086/{1}".format(self.get_plugin_vip(), path)
@ -118,8 +131,7 @@ class InfluxdbPluginApi(base_test.PluginApi):
self.settings.name, self.settings.version)
def check_grafana_dashboards(self):
grafana_url = self.get_grafana_url()
ui_api.check_grafana_dashboards(grafana_url)
ui_api.check_grafana_dashboards(self.get_grafana_url())
def get_nova_instance_creation_time_metrics(self, time_point=None):
"""Gets instance creation metrics for provided interval

View File

@ -25,6 +25,18 @@ from stacklight_tests.lma_infrastructure_alerting import(
class InfraAlertingPluginApi(base_test.PluginApi):
def __init__(self):
super(InfraAlertingPluginApi, self).__init__()
self._nagios_port = None
@property
def nagios_port(self):
if self._nagios_port is None:
self._nagios_port = 80
if self.checkers.check_port(self.get_plugin_vip(), 8001):
self._nagios_port = 8001
return self._nagios_port
def get_plugin_settings(self):
return infra_alerting_plugin_settings
@ -60,12 +72,13 @@ class InfraAlertingPluginApi(base_test.PluginApi):
)
def get_authenticated_nagios_url(self):
return "http://{0}:{1}@{2}:8001".format(self.settings.nagios_user,
self.settings.nagios_password,
self.get_plugin_vip())
return "http://{0}:{1}@{2}:{3}".format(self.settings.nagios_user,
self.settings.nagios_password,
self.get_plugin_vip(),
self.nagios_port)
def get_nagios_url(self):
return "http://{}:8001/".format(self.get_plugin_vip())
return "http://{0}:{1}".format(self.get_plugin_vip(), self.nagios_port)
def open_nagios_page(self, link_text, anchor):
driver = self.ui_tester.get_driver(self.get_authenticated_nagios_url(),