Merge "Stop trying to use identity URI if dashboard URL exists"

This commit is contained in:
Zuul 2021-04-20 20:48:38 +00:00 committed by Gerrit Code Review
commit 894835caca
2 changed files with 20 additions and 5 deletions

View File

@ -22,11 +22,14 @@ from config_tempest import constants as C
def configure_horizon(conf, **kwargs): def configure_horizon(conf, **kwargs):
"""Derive the horizon URIs from the identity's URI.""" """Verify horizon is working (fallback to introspect from identity URI)"""
uri = conf.get('identity', 'uri') if conf.has_option("dashboard", "dashboard_url"):
u = urllib.parse.urlparse(uri) base = conf.get("dashboard", "dashboard_url")
base = '%s://%s%s' % (u.scheme, u.netloc.replace( else:
':' + str(u.port), ''), '/dashboard') uri = conf.get('identity', 'uri')
u = urllib.parse.urlparse(uri)
base = '%s://%s%s' % (u.scheme, u.netloc.replace(
':' + str(u.port), ''), '/dashboard')
assert base.startswith('http:') or base.startswith('https:') assert base.startswith('http:') or base.startswith('https:')
has_horizon = True has_horizon = True
try: try:

View File

@ -28,6 +28,18 @@ class TestConfigTempest(BaseConfigTempestTest):
super(TestConfigTempest, self).setUp() super(TestConfigTempest, self).setUp()
self.conf = self._get_conf("v2.0", "v3") self.conf = self._get_conf("v2.0", "v3")
def test_configure_horizon_overridden(self):
mock_function = mock.Mock(return_value=True)
self.useFixture(MonkeyPatch('six.moves.urllib.request.urlopen',
mock_function))
self.conf.set("dashboard", "dashboard_url", "http://172.16.52.151")
horizon.configure_horizon(self.conf)
self.assertEqual(self.conf.get('service_available', 'horizon'), "True")
self.assertEqual(self.conf.get('dashboard', 'dashboard_url'),
"http://172.16.52.151/")
self.assertEqual(self.conf.get('dashboard', 'login_url'),
"http://172.16.52.151/auth/login/")
def test_configure_horizon_ipv4(self): def test_configure_horizon_ipv4(self):
mock_function = mock.Mock(return_value=True) mock_function = mock.Mock(return_value=True)
self.useFixture(MonkeyPatch('six.moves.urllib.request.urlopen', self.useFixture(MonkeyPatch('six.moves.urllib.request.urlopen',