Merge "Make all config parsing case-sensitive"
This commit is contained in:
commit
6f62758413
@ -2542,6 +2542,7 @@ def readconf(conf_path, section_name=None, log_name=None, defaults=None,
|
||||
# values like "1%" (which we want to support for
|
||||
# fallocate_reserve).
|
||||
c = ConfigParser(defaults, interpolation=NicerInterpolation())
|
||||
c.optionxform = str # Don't lower-case keys
|
||||
|
||||
if hasattr(conf_path, 'readline'):
|
||||
if hasattr(conf_path, 'seek'):
|
||||
|
@ -226,7 +226,8 @@ class TestRunDaemon(unittest.TestCase, ConfigAssertMixin):
|
||||
d = daemon.run_daemon(MyDaemon, conf_path)
|
||||
# my-daemon section takes priority (!?)
|
||||
self.assertEqual('2', d.conf['client_timeout'])
|
||||
self.assertEqual('10', d.conf['conn_timeout'])
|
||||
self.assertEqual('10', d.conf['CONN_timeout'])
|
||||
self.assertEqual('5', d.conf['conn_timeout'])
|
||||
|
||||
@with_tempdir
|
||||
def test_run_daemon_from_conf_file_with_duplicate_var(self, tempdir):
|
||||
@ -237,13 +238,16 @@ class TestRunDaemon(unittest.TestCase, ConfigAssertMixin):
|
||||
[my-daemon]
|
||||
CLIENT_TIMEOUT = 2
|
||||
client_timeout = 1
|
||||
conn_timeout = 1.1
|
||||
conn_timeout = 1.2
|
||||
"""
|
||||
contents = dedent(conf_body)
|
||||
with open(conf_path, 'w') as f:
|
||||
f.write(contents)
|
||||
with mock.patch('swift.common.daemon.use_hub'):
|
||||
app_config = lambda: daemon.run_daemon(MyDaemon, tempdir)
|
||||
self.assertDuplicateOption(app_config, 'client_timeout', '1')
|
||||
# N.B. CLIENT_TIMEOUT/client_timeout are unique options
|
||||
self.assertDuplicateOption(app_config, 'conn_timeout', '1.2')
|
||||
|
||||
@with_tempdir
|
||||
def test_run_deamon_from_conf_dir(self, tempdir):
|
||||
@ -270,7 +274,8 @@ class TestRunDaemon(unittest.TestCase, ConfigAssertMixin):
|
||||
d = daemon.run_daemon(MyDaemon, tempdir)
|
||||
# my-daemon section takes priority (!?)
|
||||
self.assertEqual('2', d.conf['client_timeout'])
|
||||
self.assertEqual('10', d.conf['conn_timeout'])
|
||||
self.assertEqual('10', d.conf['CONN_timeout'])
|
||||
self.assertEqual('5', d.conf['conn_timeout'])
|
||||
|
||||
@with_tempdir
|
||||
def test_run_daemon_from_conf_dir_with_duplicate_var(self, tempdir):
|
||||
@ -283,6 +288,8 @@ class TestRunDaemon(unittest.TestCase, ConfigAssertMixin):
|
||||
[my-daemon]
|
||||
client_timeout = 2
|
||||
CLIENT_TIMEOUT = 4
|
||||
conn_timeout = 1.1
|
||||
conn_timeout = 1.2
|
||||
""",
|
||||
}
|
||||
for filename, conf_body in conf_files.items():
|
||||
@ -291,7 +298,8 @@ class TestRunDaemon(unittest.TestCase, ConfigAssertMixin):
|
||||
fd.write(dedent(conf_body))
|
||||
with mock.patch('swift.common.daemon.use_hub'):
|
||||
app_config = lambda: daemon.run_daemon(MyDaemon, tempdir)
|
||||
self.assertDuplicateOption(app_config, 'client_timeout', '4')
|
||||
# N.B. CLIENT_TIMEOUT/client_timeout are unique options
|
||||
self.assertDuplicateOption(app_config, 'conn_timeout', '1.2')
|
||||
|
||||
@contextmanager
|
||||
def mock_os(self, child_worker_cycles=3):
|
||||
|
@ -148,6 +148,8 @@ class TestWSGI(unittest.TestCase, ConfigAssertMixin):
|
||||
app = wsgi.loadapp(conf_path)
|
||||
self.assertIsInstance(app, obj_server.ObjectController)
|
||||
self.assertTrue(isinstance(app, obj_server.ObjectController))
|
||||
# N.B. paste config loading from *file* is already case-sensitive,
|
||||
# so, CLIENT_TIMEOUT/client_timeout are unique options
|
||||
self.assertEqual(1, app.client_timeout)
|
||||
self.assertEqual(5, app.conn_timeout)
|
||||
|
||||
@ -298,6 +300,8 @@ class TestWSGI(unittest.TestCase, ConfigAssertMixin):
|
||||
use = egg:swift#proxy
|
||||
client_timeout = 2
|
||||
CLIENT_TIMEOUT = 1
|
||||
conn_timeout = 3
|
||||
conn_timeout = 4
|
||||
""",
|
||||
}
|
||||
_fake_rings(tempdir)
|
||||
@ -306,7 +310,9 @@ class TestWSGI(unittest.TestCase, ConfigAssertMixin):
|
||||
with open(path, 'wt') as fd:
|
||||
fd.write(dedent(conf_body))
|
||||
app_config = lambda: wsgi.loadapp(tempdir)
|
||||
self.assertDuplicateOption(app_config, 'client_timeout', 2.0)
|
||||
# N.B. our paste conf.d parsing re-uses readconf,
|
||||
# so, CLIENT_TIMEOUT/client_timeout are unique options
|
||||
self.assertDuplicateOption(app_config, 'conn_timeout', 4.0)
|
||||
|
||||
@with_tempdir
|
||||
def test_load_app_config(self, tempdir):
|
||||
|
Loading…
x
Reference in New Issue
Block a user