Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
reducing swift unit test failures from 348 to 285 via changing the config map
diff --git a/.functests b/.functests
index 86abce3..7b5aa2b 100755
--- a/.functests
+++ b/.functests
@@ -1,4 +1,5 @@
#!/bin/bash
+set -e
nosetests test/functional --exe
nosetests test/functionalnosetests --exe
diff --git a/.probetests b/.probetests
index 7514693..00c8812 100755
--- a/.probetests
+++ b/.probetests
@@ -1,3 +1,4 @@
#!/bin/bash
+set -e
nosetests test/probe --exe
diff --git a/.unittests b/.unittests
index c115578..091cfe5 100755
--- a/.unittests
+++ b/.unittests
@@ -1,4 +1,5 @@
#!/bin/bash
+set -e
nosetests test/unit --exe --with-coverage --cover-package swift --cover-erase
rm -f .coverage
diff --git a/swift/common/utils.py b/swift/common/utils.py
index 16d1fa4..bbdc669 100644
--- a/swift/common/utils.py
+++ b/swift/common/utils.py
@@ -408,6 +408,7 @@ def get_logger(conf, name=None, log_to_console=False, log_route=None,
log_facility = LOG_LOCAL0
log_level = INFO
log_name = swift
+ log_address = /dev/log
:param conf: Configuration dict to read settings from
:param name: Name of the logger
@@ -433,10 +434,12 @@ def get_logger(conf, name=None, log_to_console=False, log_route=None,
if logger in get_logger.handler4logger:
logger.removeHandler(get_logger.handler4logger[logger])
+ # setup syslog logging
# facility for this logger will be set by last call wins
facility = getattr(SysLogHandler, conf.get('log_facility', 'LOG_LOCAL0'),
SysLogHandler.LOG_LOCAL0)
- handler = SysLogHandler(address='/dev/log', facility=facility)
+ address = conf.get("log_address", "/dev/log")
+ handler = SysLogHandler(address=address, facility=facility)
handler.setFormatter(formatter)
logger.addHandler(handler)
get_logger.handler4logger[logger] = handler
diff --git a/test/unit/account/test_server.py b/test/unit/account/test_server.py
index 879592c..f43c149 100644
--- a/test/unit/account/test_server.py
+++ b/test/unit/account/test_server.py
@@ -33,7 +33,8 @@ class TestAccountController(unittest.TestCase):
""" Set up for testing swift.account_server.AccountController """
self.testdir = os.path.join(os.path.dirname(__file__), 'account_server')
self.controller = AccountController(
- {'devices': self.testdir, 'mount_check': 'false'})
+ {'devices': self.testdir, 'mount_check': 'false',
+ 'log_address': '/tmp/log'})
def tearDown(self):
""" Tear down for testing swift.account_server.AccountController """
diff --git a/test/unit/common/middleware/test_except.py b/test/unit/common/middleware/test_except.py
index d110723..dc6cb5c 100644
--- a/test/unit/common/middleware/test_except.py
+++ b/test/unit/common/middleware/test_except.py
@@ -37,17 +37,18 @@ def start_response(*args):
class TestCatchErrors(unittest.TestCase):
def setUp(self):
- self.logger = get_logger({})
+ # FIXME: self.conf?
+ self.logger = get_logger({'log_address': '/tmp/log'})
self.logger.txn_id = None
def test_catcherrors_passthrough(self):
- app = catch_errors.CatchErrorMiddleware(FakeApp(), {})
+ app = catch_errors.CatchErrorMiddleware(FakeApp(), {'log_address': '/tmp/log'})
req = Request.blank('/', environ={'REQUEST_METHOD': 'GET'})
resp = app(req.environ, start_response)
self.assertEquals(resp, ['FAKE APP'])
def test_catcherrors(self):
- app = catch_errors.CatchErrorMiddleware(FakeApp(True), {})
+ app = catch_errors.CatchErrorMiddleware(FakeApp(True), {'log_address': '/tmp/log'})
req = Request.blank('/', environ={'REQUEST_METHOD': 'GET'})
resp = app(req.environ, start_response)
self.assertEquals(resp, ['An error occurred'])
@@ -56,7 +57,7 @@ class TestCatchErrors(unittest.TestCase):
self.assertEquals(self.logger.txn_id, None)
def start_response(status, headers):
self.assert_('x-trans-id' in (x[0] for x in headers))
- app = catch_errors.CatchErrorMiddleware(FakeApp(), {})
+ app = catch_errors.CatchErrorMiddleware(FakeApp(), {'log_address': '/tmp/log'})
req = Request.blank('/v1/a/c/o')
app(req.environ, start_response)
self.assertEquals(len(self.logger.txn_id), 34) # 32 hex + 'tx'
@@ -65,7 +66,7 @@ class TestCatchErrors(unittest.TestCase):
self.assertEquals(self.logger.txn_id, None)
def start_response(status, headers):
self.assert_('x-trans-id' in (x[0] for x in headers))
- app = catch_errors.CatchErrorMiddleware(FakeApp(True), {})
+ app = catch_errors.CatchErrorMiddleware(FakeApp(True), {'log_address': '/tmp/log'})
req = Request.blank('/v1/a/c/o')
app(req.environ, start_response)
self.assertEquals(len(self.logger.txn_id), 34)
diff --git a/test/unit/common/middleware/test_formpost.py b/test/unit/common/middleware/test_formpost.py
index 63cfbdb..0aac308 100644
--- a/test/unit/common/middleware/test_formpost.py
+++ b/test/unit/common/middleware/test_formpost.py
@@ -284,8 +284,8 @@ class TestFormPost(unittest.TestCase):
def setUp(self):
self.app = FakeApp()
- self.auth = tempauth.filter_factory({})(self.app)
- self.formpost = formpost.filter_factory({})(self.auth)
+ self.auth = tempauth.filter_factory({'log_address': '/tmp/log'})(self.app)
+ self.formpost = formpost.filter_factory({'log_address': '/tmp/log'})(self.auth)
def _make_request(self, path, **kwargs):
req = Request.blank(path, **kwargs)
@@ -458,8 +458,8 @@ class TestFormPost(unittest.TestCase):
}
self.app = FakeApp(iter([('201 Created', {}, ''),
('201 Created', {}, '')]))
- self.auth = tempauth.filter_factory({})(self.app)
- self.formpost = formpost.filter_factory({})(self.auth)
+ self.auth = tempauth.filter_factory({'log_address': '/tmp/log'})(self.app)
+ self.formpost = formpost.filter_factory({'log_address': '/tmp/log'})(self.auth)
status = [None]
headers = [None]
exc_info = [None]
@@ -568,8 +568,8 @@ class TestFormPost(unittest.TestCase):
}
self.app = FakeApp(iter([('201 Created', {}, ''),
('201 Created', {}, '')]))
- self.auth = tempauth.filter_factory({})(self.app)
- self.formpost = formpost.filter_factory({})(self.auth)
+ self.auth = tempauth.filter_factory({'log_address': '/tmp/log'})(self.app)
+ self.formpost = formpost.filter_factory({'log_address': '/tmp/log'})(self.auth)
status = [None]
headers = [None]
exc_info = [None]
@@ -681,8 +681,8 @@ class TestFormPost(unittest.TestCase):
}
self.app = FakeApp(iter([('201 Created', {}, ''),
('201 Created', {}, '')]))
- self.auth = tempauth.filter_factory({})(self.app)
- self.formpost = formpost.filter_factory({})(self.auth)
+ self.auth = tempauth.filter_factory({'log_address': '/tmp/log'})(self.app)
+ self.formpost = formpost.filter_factory({'log_address': '/tmp/log'})(self.auth)
status = [None]
headers = [None]
exc_info = [None]
@@ -790,8 +790,8 @@ class TestFormPost(unittest.TestCase):
}
self.app = FakeApp(iter([('201 Created', {}, ''),
('201 Created', {}, '')]))
- self.auth = tempauth.filter_factory({})(self.app)
- self.formpost = formpost.filter_factory({})(self.auth)
+ self.auth = tempauth.filter_factory({'log_address': '/tmp/log'})(self.app)
+ self.formpost = formpost.filter_factory({'log_address': '/tmp/log'})(self.auth)
status = [None]
headers = [None]
exc_info = [None]
@@ -826,8 +826,8 @@ class TestFormPost(unittest.TestCase):
env['swift.cache'].set('temp-url-key/AUTH_test', key)
self.app = FakeApp(iter([('201 Created', {}, ''),
('201 Created', {}, '')]))
- self.auth = tempauth.filter_factory({})(self.app)
- self.formpost = formpost.filter_factory({})(self.auth)
+ self.auth = tempauth.filter_factory({'log_address': '/tmp/log'})(self.app)
+ self.formpost = formpost.filter_factory({'log_address': '/tmp/log'})(self.auth)
status = [None]
headers = [None]
exc_info = [None]
@@ -855,8 +855,8 @@ class TestFormPost(unittest.TestCase):
env['swift.cache'].set('temp-url-key/AUTH_test', key)
self.app = FakeApp(iter([('201 Created', {}, ''),
('201 Created', {}, '')]))
- self.auth = tempauth.filter_factory({})(self.app)
- self.formpost = formpost.filter_factory({})(self.auth)
+ self.auth = tempauth.filter_factory({'log_address': '/tmp/log'})(self.app)
+ self.formpost = formpost.filter_factory({'log_address': '/tmp/log'})(self.auth)
status = [None]
headers = [None]
exc_info = [None]
@@ -884,8 +884,8 @@ class TestFormPost(unittest.TestCase):
env['swift.cache'].set('temp-url-key/AUTH_test', key)
self.app = FakeApp(iter([('201 Created', {}, ''),
('201 Created', {}, '')]))
- self.auth = tempauth.filter_factory({})(self.app)
- self.formpost = formpost.filter_factory({})(self.auth)
+ self.auth = tempauth.filter_factory({'log_address': '/tmp/log'})(self.app)
+ self.formpost = formpost.filter_factory({'log_address': '/tmp/log'})(self.auth)
status = [None]
headers = [None]
exc_info = [None]
@@ -922,8 +922,8 @@ class TestFormPost(unittest.TestCase):
env['swift.cache'].set('temp-url-key/AUTH_test', key)
self.app = FakeApp(iter([('404 Not Found', {}, ''),
('201 Created', {}, '')]))
- self.auth = tempauth.filter_factory({})(self.app)
- self.formpost = formpost.filter_factory({})(self.auth)
+ self.auth = tempauth.filter_factory({'log_address': '/tmp/log'})(self.app)
+ self.formpost = formpost.filter_factory({'log_address': '/tmp/log'})(self.auth)
status = [None]
headers = [None]
exc_info = [None]
@@ -1003,8 +1003,8 @@ class TestFormPost(unittest.TestCase):
env['swift.cache'].set('temp-url-key/AUTH_test', key)
self.app = FakeApp(iter([('201 Created', {}, ''),
('201 Created', {}, '')]))
- self.auth = tempauth.filter_factory({})(self.app)
- self.formpost = formpost.filter_factory({})(self.auth)
+ self.auth = tempauth.filter_factory({'log_address': '/tmp/log'})(self.app)
+ self.formpost = formpost.filter_factory({'log_address': '/tmp/log'})(self.auth)
status = [None]
headers = [None]
exc_info = [None]
@@ -1068,8 +1068,8 @@ class TestFormPost(unittest.TestCase):
env['swift.cache'].set('temp-url-key/AUTH_test', key)
self.app = FakeApp(iter([('201 Created', {}, ''),
('201 Created', {}, '')]))
- self.auth = tempauth.filter_factory({})(self.app)
- self.formpost = formpost.filter_factory({})(self.auth)
+ self.auth = tempauth.filter_factory({'log_address': '/tmp/log'})(self.app)
+ self.formpost = formpost.filter_factory({'log_address': '/tmp/log'})(self.auth)
status = [None]
headers = [None]
exc_info = [None]
@@ -1105,8 +1105,8 @@ class TestFormPost(unittest.TestCase):
env['swift.cache'].set('temp-url-key/AUTH_test', key)
self.app = FakeApp(iter([('201 Created', {}, ''),
('201 Created', {}, '')]))
- self.auth = tempauth.filter_factory({})(self.app)
- self.formpost = formpost.filter_factory({})(self.auth)
+ self.auth = tempauth.filter_factory({'log_address': '/tmp/log'})(self.app)
+ self.formpost = formpost.filter_factory({'log_address': '/tmp/log'})(self.auth)
status = [None]
headers = [None]
exc_info = [None]
@@ -1141,8 +1141,8 @@ class TestFormPost(unittest.TestCase):
env['swift.cache'].set('temp-url-key/AUTH_test', key)
self.app = FakeApp(iter([('201 Created', {}, ''),
('201 Created', {}, '')]))
- self.auth = tempauth.filter_factory({})(self.app)
- self.formpost = formpost.filter_factory({})(self.auth)
+ self.auth = tempauth.filter_factory({'log_address': '/tmp/log'})(self.app)
+ self.formpost = formpost.filter_factory({'log_address': '/tmp/log'})(self.auth)
status = [None]
headers = [None]
exc_info = [None]
@@ -1176,8 +1176,8 @@ class TestFormPost(unittest.TestCase):
env['swift.cache'].set('temp-url-key/AUTH_test', key)
self.app = FakeApp(iter([('201 Created', {}, ''),
('201 Created', {}, '')]))
- self.auth = tempauth.filter_factory({})(self.app)
- self.formpost = formpost.filter_factory({})(self.auth)
+ self.auth = tempauth.filter_factory({'log_address': '/tmp/log'})(self.app)
+ self.formpost = formpost.filter_factory({'log_address': '/tmp/log'})(self.auth)
status = [None]
headers = [None]
exc_info = [None]
@@ -1209,8 +1209,8 @@ class TestFormPost(unittest.TestCase):
env['swift.cache'].set('temp-url-key/AUTH_test', key)
self.app = FakeApp(iter([('201 Created', {}, ''),
('201 Created', {}, '')]))
- self.auth = tempauth.filter_factory({})(self.app)
- self.formpost = formpost.filter_factory({})(self.auth)
+ self.auth = tempauth.filter_factory({'log_address': '/tmp/log'})(self.app)
+ self.formpost = formpost.filter_factory({'log_address': '/tmp/log'})(self.auth)
status = [None]
headers = [None]
exc_info = [None]
@@ -1242,8 +1242,8 @@ class TestFormPost(unittest.TestCase):
env['swift.cache'].set('temp-url-key/AUTH_test', key)
self.app = FakeApp(iter([('201 Created', {}, ''),
('201 Created', {}, '')]))
- self.auth = tempauth.filter_factory({})(self.app)
- self.formpost = formpost.filter_factory({})(self.auth)
+ self.auth = tempauth.filter_factory({'log_address': '/tmp/log'})(self.app)
+ self.formpost = formpost.filter_factory({'log_address': '/tmp/log'})(self.auth)
status = [None]
headers = [None]
exc_info = [None]
@@ -1275,8 +1275,8 @@ class TestFormPost(unittest.TestCase):
env['swift.cache'].set('temp-url-key/AUTH_test', key)
self.app = FakeApp(iter([('201 Created', {}, ''),
('201 Created', {}, '')]))
- self.auth = tempauth.filter_factory({})(self.app)
- self.formpost = formpost.filter_factory({})(self.auth)
+ self.auth = tempauth.filter_factory({'log_address': '/tmp/log'})(self.app)
+ self.formpost = formpost.filter_factory({'log_address': '/tmp/log'})(self.auth)
status = [None]
headers = [None]
exc_info = [None]
@@ -1308,8 +1308,8 @@ class TestFormPost(unittest.TestCase):
env['swift.cache'].set('temp-url-key/AUTH_test', key)
self.app = FakeApp(iter([('201 Created', {}, ''),
('201 Created', {}, '')]))
- self.auth = tempauth.filter_factory({})(self.app)
- self.formpost = formpost.filter_factory({})(self.auth)
+ self.auth = tempauth.filter_factory({'log_address': '/tmp/log'})(self.app)
+ self.formpost = formpost.filter_factory({'log_address': '/tmp/log'})(self.auth)
status = [None]
headers = [None]
exc_info = [None]
@@ -1343,8 +1343,8 @@ class TestFormPost(unittest.TestCase):
('200 Ok', {'x-account-meta-temp-url-key': 'def'}, ''),
('201 Created', {}, ''),
('201 Created', {}, '')]))
- self.auth = tempauth.filter_factory({})(self.app)
- self.formpost = formpost.filter_factory({})(self.auth)
+ self.auth = tempauth.filter_factory({'log_address': '/tmp/log'})(self.app)
+ self.formpost = formpost.filter_factory({'log_address': '/tmp/log'})(self.auth)
status = [None]
headers = [None]
exc_info = [None]
@@ -1376,8 +1376,8 @@ class TestFormPost(unittest.TestCase):
env['swift.cache'].set('temp-url-key/AUTH_test', key)
self.app = FakeApp(iter([('201 Created', {}, ''),
('201 Created', {}, '')]))
- self.auth = tempauth.filter_factory({})(self.app)
- self.formpost = formpost.filter_factory({})(self.auth)
+ self.auth = tempauth.filter_factory({'log_address': '/tmp/log'})(self.app)
+ self.formpost = formpost.filter_factory({'log_address': '/tmp/log'})(self.auth)
status = [None]
headers = [None]
exc_info = [None]
@@ -1414,8 +1414,8 @@ class TestFormPost(unittest.TestCase):
env['swift.cache'].set('temp-url-key/AUTH_test', key)
self.app = FakeApp(iter([('201 Created', {}, ''),
('201 Created', {}, '')]))
- self.auth = tempauth.filter_factory({})(self.app)
- self.formpost = formpost.filter_factory({})(self.auth)
+ self.auth = tempauth.filter_factory({'log_address': '/tmp/log'})(self.app)
+ self.formpost = formpost.filter_factory({'log_address': '/tmp/log'})(self.auth)
status = [None]
headers = [None]
exc_info = [None]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.