Add doctor check for debug mode enabled

This patch adds a symptom test to verify that debug mode is not
enabled. Doing so will eliminate the need to add an additional
check for debug enabled in other symptom checks like caching and
database. This also corrects the unit tests that have already been
added as well as adds a unit test for the new debug symptom.

Related-Bug: 1641621

Change-Id: I76750ab3553026583b9fb330bd39f2a134d9c230
This commit is contained in:
“Richard 2016-12-07 16:47:05 +00:00 committed by Steve Martinelli
parent fc93521ed1
commit 359b10c7e3
5 changed files with 48 additions and 18 deletions

View File

@ -13,6 +13,7 @@
from keystone.cmd.doctor import caching
from keystone.cmd.doctor import credential
from keystone.cmd.doctor import database
from keystone.cmd.doctor import debug
from keystone.cmd.doctor import federation
from keystone.cmd.doctor import ldap
from keystone.cmd.doctor import security_compliance
@ -29,6 +30,7 @@ SYMPTOM_MODULES = [
caching,
credential,
database,
debug,
federation,
ldap,
security_compliance,

View File

@ -22,7 +22,7 @@ def symptom_caching_disabled():
Caching greatly improves the performance of keystone, and it is highly
recommended that you enable it.
"""
return not CONF.cache.enabled and not CONF.debug
return not CONF.cache.enabled
def symptom_caching_enabled_without_a_backend():

View File

@ -26,5 +26,4 @@ def symptom_database_connection_is_not_SQLite():
"""
return (
CONF.database.connection is not None
and 'sqlite' in CONF.database.connection
and not CONF.debug)
and 'sqlite' in CONF.database.connection)

View File

@ -0,0 +1,28 @@
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import keystone.conf
CONF = keystone.conf.CONF
def symptom_debug_mode_is_enabled():
"""Debug mode should be set to False.
Debug mode can be used to get more information back when trying to isolate
a problem, but it is not recommended to be enabled when running a
production environment.
Ensure `keystone.conf debug` is set to False
"""
return CONF.debug

View File

@ -26,6 +26,7 @@ from testtools import matchers
from keystone.cmd import cli
from keystone.cmd.doctor import caching
from keystone.cmd.doctor import debug
from keystone.cmd.doctor import federation
from keystone.common import dependency
from keystone.common.sql import upgrades
@ -714,27 +715,15 @@ class CliDomainConfigUploadNothing(unit.BaseTestCase):
matchers.Contains(expected_msg))
class DoctorTestCase(unit.TestCase):
class CachingDoctorTests(unit.TestCase):
def test_symptom_caching_disabled(self):
# Success Case: Caching enabled and debug disabled
# Symptom Detected: Caching disabled
self.config_fixture.config(group='cache', enabled=False)
self.config_fixture.config(debug=False)
self.assertTrue(caching.symptom_caching_disabled())
# Failure Case 1: Caching disabled and debug enabled
self.config_fixture.config(group='cache', enabled=False)
self.config_fixture.config(debug=True)
self.assertFalse(caching.symptom_caching_disabled())
# Failure Case 2: Caching enabled and debug enabled
# No Symptom Detected: Caching is enabled
self.config_fixture.config(group='cache', enabled=True)
self.config_fixture.config(debug=True)
self.assertFalse(caching.symptom_caching_disabled())
# Failure Case 3: Caching enabled and debug disabled
self.config_fixture.config(group='cache', enabled=True)
self.config_fixture.config(debug=False)
self.assertFalse(caching.symptom_caching_disabled())
def test_caching_symptom_caching_enabled_without_a_backend(self):
@ -761,6 +750,18 @@ class DoctorTestCase(unit.TestCase):
self.assertFalse(caching.symptom_caching_enabled_without_a_backend())
class DebugDoctorTests(unit.TestCase):
def test_symptom_debug_mode_is_enabled(self):
# Symptom Detected: Debug mode is enabled
self.config_fixture.config(debug=True)
self.assertTrue(debug.symptom_debug_mode_is_enabled())
# No Symptom Detected: Debug mode is disabled
self.config_fixture.config(debug=False)
self.assertFalse(debug.symptom_debug_mode_is_enabled())
class FederationDoctorTests(unit.TestCase):
def test_symptom_comma_in_SAML_public_certificate_path(self):