Merge "Optimize the way to serach file 'glance-api-paste.ini'"

This commit is contained in:
Zuul 2017-11-15 08:23:31 +00:00 committed by Gerrit Code Review
commit dfee2ce67e
2 changed files with 8 additions and 1 deletions

View File

@ -782,7 +782,7 @@ def _get_deployment_config_file():
path = CONF.paste_deploy.config_file
if not path:
path = _get_paste_config_path()
if not path:
if not path or not (os.path.isfile(os.path.abspath(path))):
msg = _("Unable to locate paste config file for %s.") % CONF.prog
raise RuntimeError(msg)
return os.path.abspath(path)

View File

@ -95,6 +95,13 @@ class TestPasteApp(test_utils.BaseTestCase):
self._do_test_load_paste_app(expected_middleware,
paste_config_file=paste_config_file)
def test_load_paste_app_with_paste_config_file_but_not_exist(self):
paste_config_file = os.path.abspath("glance-registry-paste.ini")
expected_middleware = oslo_middleware.Healthcheck
self.assertRaises(RuntimeError, self._do_test_load_paste_app,
expected_middleware,
paste_config_file=paste_config_file)
def test_get_path_non_exist(self):
self.assertRaises(RuntimeError, config._get_deployment_config_file)