Add keystone host unreachable checks

Raise HostUnreachableException if the property auth_url is wrong

Implements blueprint keystone-auth-url-wrong

Change-Id: Idf2a07b1535a4a3c53814a1a55959afc59caefe2
This commit is contained in:
Pierre Padrixe 2014-01-22 15:30:05 +01:00
parent de35f19279
commit e64a98df61
3 changed files with 21 additions and 3 deletions

View File

@ -16,7 +16,7 @@
import json
import jsonschema
from keystoneclient.v2_0 import client as keystone
from keystoneclient import exceptions as keystone_exceptions
from rally.benchmark import base
from rally.benchmark import runner
@ -156,8 +156,11 @@ class TestEngine(object):
if not any("admin" == role['name'] for role in roles):
raise exceptions.InvalidAdminException(
username=self.endpoint["username"])
except keystone.exceptions.Unauthorized:
except keystone_exceptions.Unauthorized:
raise exceptions.InvalidEndpointsException()
except keystone_exceptions.AuthorizationFailure:
raise exceptions.HostUnreachableException(
url=self.endpoint['auth_url'])
return self
def __enter__(self):

View File

@ -160,3 +160,7 @@ class InvalidAdminException(InvalidArgumentsException):
class InvalidEndpointsException(InvalidArgumentsException):
msg_fmt = _("wrong keystone credentials specified in your endpoint"
" properties. (HTTP 401)")
class HostUnreachableException(InvalidArgumentsException):
msg_fmt = _("unable to establish connection to the remote host: %(url)s")

View File

@ -17,6 +17,8 @@
import mock
from keystoneclient import exceptions as keystone_exceptions
from rally.benchmark import engine
from rally import consts
from rally import exceptions
@ -133,12 +135,21 @@ class TestEngineTestCase(test.TestCase):
@mock.patch("rally.cmd.main.api.engine.osclients.Clients"
".get_keystone_client")
def test_bind_unauthorized_keystone(self, mock_osclients):
mock_osclients.side_effect = exceptions.InvalidEndpointsException
mock_osclients.side_effect = keystone_exceptions.Unauthorized
tester = engine.TestEngine(self.valid_test_config_continuous_times,
mock.MagicMock())
self.assertRaises(exceptions.InvalidEndpointsException,
tester.bind, self.valid_endpoint)
@mock.patch("rally.cmd.main.api.engine.osclients.Clients"
".get_keystone_client")
def test_bind_keystone_host_unreachable(self, mock_osclients):
mock_osclients.side_effect = keystone_exceptions.AuthorizationFailure
tester = engine.TestEngine(self.valid_test_config_continuous_times,
mock.MagicMock())
self.assertRaises(exceptions.HostUnreachableException,
tester.bind, self.valid_endpoint)
@mock.patch("rally.benchmark.runner.ScenarioRunner.run")
@mock.patch("rally.benchmark.utils.osclients")
@mock.patch("rally.benchmark.engine.osclients")