test.patch revision 2810
2810N/AVarious testing fixes:
2810N/A
2810N/A - Tests involving large (5GB+) bodies are mocked, but on 32-bit python,
2810N/A len() is limited to returning a ssize_t, which can represent 2GB.
2810N/A
2810N/A - Solaris doesn't yet support syslog logging to /dev/log.
2810N/A
2810N/A - Solaris doesn't have TCP_KEEPIDLE.
2810N/A
2810N/A - Three tests make connections to 127.0.0.[234], which take minutes to
2810N/A timeout (and one test fails). Mock the connections to make the return
2810N/A success immediately.
2810N/A
2810N/AThe last has already been fixed upstream, as of 1.9.1. The middle two are
2810N/ASolaris-only, and not suitable for upstream. The first, while potentially
2810N/Auseful elsewhere, is really only an issue on Solaris because Linux runs
2810N/Aalmost exclusively 64-bit, which makes this a non-issue.
2810N/A
2810N/Adiff --git a/test/unit/__init__.py b/test/unit/__init__.py
2810N/A--- a/test/unit/__init__.py
2810N/A+++ b/test/unit/__init__.py
2810N/A@@ -315,7 +315,7 @@ def fake_http_connect(*code_iter, **kwar
2810N/A else:
2810N/A etag = '"68b329da9893e34099c7d8ad5cb9c940"'
2810N/A
2810N/A- headers = {'content-length': len(self.body),
2810N/A+ headers = {'content-length': self.body.__len__(),
2810N/A 'content-type': 'x-application/test',
2810N/A 'x-timestamp': self.timestamp,
2810N/A 'last-modified': self.timestamp,
2810N/Adiff --git a/test/unit/proxy/test_server.py b/test/unit/proxy/test_server.py
2810N/A--- a/test/unit/proxy/test_server.py
2810N/A+++ b/test/unit/proxy/test_server.py
2810N/A@@ -2310,6 +2310,9 @@ class TestObjectController(unittest.Test
2810N/A
2810N/A class LargeResponseBody(object):
2810N/A
2810N/A+ def __nonzero__(self):
2810N/A+ return True
2810N/A+
2810N/A def __len__(self):
2810N/A return MAX_FILE_SIZE + 1
2810N/A
2810N/A@@ -2439,6 +2442,9 @@ class TestObjectController(unittest.Test
2810N/A
2810N/A class LargeResponseBody(object):
2810N/A
2810N/A+ def __nonzero__(self):
2810N/A+ return True
2810N/A+
2810N/A def __len__(self):
2810N/A return MAX_FILE_SIZE + 1
2810N/A
2810N/Adiff --git a/test/unit/common/test_utils.py b/test/unit/common/test_utils.py
2810N/A--- a/test/unit/common/test_utils.py
2810N/A+++ b/test/unit/common/test_utils.py
2810N/A@@ -425,9 +425,15 @@ class TestUtils(unittest.TestCase):
2810N/A logger = utils.get_logger({
2810N/A 'log_facility': 'LOG_LOCAL3',
2810N/A }, 'server', log_route='server')
2810N/A+ if sys.platform == 'sunos5':
2810N/A+ extra = [
2810N/A+ ((), {'facility': orig_sysloghandler.LOG_LOCAL3})
2810N/A+ ]
2810N/A+ else:
2810N/A+ extra = []
2810N/A self.assertEquals([
2810N/A ((), {'address': '/dev/log',
2810N/A- 'facility': orig_sysloghandler.LOG_LOCAL3})],
2810N/A+ 'facility': orig_sysloghandler.LOG_LOCAL3})] + extra,
2810N/A syslog_handler_args)
2810N/A
2810N/A syslog_handler_args = []
2810N/Adiff --git a/test/unit/common/test_wsgi.py b/test/unit/common/test_wsgi.py
2810N/A--- a/test/unit/common/test_wsgi.py
2810N/A+++ b/test/unit/common/test_wsgi.py
2810N/A@@ -116,11 +116,12 @@ class TestWSGI(unittest.TestCase):
2810N/A socket.SOL_SOCKET: {
2810N/A socket.SO_REUSEADDR: 1,
2810N/A socket.SO_KEEPALIVE: 1,
2810N/A- },
2810N/A- socket.IPPROTO_TCP: {
2810N/A+ }
2810N/A+ }
2810N/A+ if hasattr(socket, 'TCP_KEEPIDLE'):
2810N/A+ expected_socket_opts[socket.IPPROTO_TCP] = {
2810N/A socket.TCP_KEEPIDLE: 600,
2810N/A- },
2810N/A- }
2810N/A+ }
2810N/A self.assertEquals(sock.opts, expected_socket_opts)
2810N/A # test ssl
2810N/A sock = wsgi.get_socket(ssl_conf)
2810N/Adiff --git a/test/unit/obj/test_replicator.py b/test/unit/obj/test_replicator.py
2810N/A--- a/test/unit/obj/test_replicator.py
2810N/A+++ b/test/unit/obj/test_replicator.py
2810N/A@@ -17,6 +17,7 @@ from __future__ import with_statement
2810N/A
2810N/A import unittest
2810N/A import os
2810N/A+from mock import patch as mockpatch
2810N/A from gzip import GzipFile
2810N/A from shutil import rmtree
2810N/A import cPickle as pickle
2810N/A@@ -482,14 +483,16 @@ class TestObjectReplicator(unittest.Test
2810N/A self.replicator.logger.log_dict['warning'])
2810N/A
2810N/A def test_delete_partition(self):
2810N/A- df = DiskFile(self.devices, 'sda', '0', 'a', 'c', 'o', FakeLogger())
2810N/A- mkdirs(df.datadir)
2810N/A- ohash = hash_path('a', 'c', 'o')
2810N/A- data_dir = ohash[-3:]
2810N/A- part_path = os.path.join(self.objects, '1')
2810N/A- self.assertTrue(os.access(part_path, os.F_OK))
2810N/A- self.replicator.replicate()
2810N/A- self.assertFalse(os.access(part_path, os.F_OK))
2810N/A+ with mockpatch('swift.obj.replicator.http_connect',
2810N/A+ mock_http_connect(200)):
2810N/A+ df = DiskFile(self.devices, 'sda', '0', 'a', 'c', 'o', FakeLogger())
2810N/A+ mkdirs(df.datadir)
2810N/A+ ohash = hash_path('a', 'c', 'o')
2810N/A+ data_dir = ohash[-3:]
2810N/A+ part_path = os.path.join(self.objects, '1')
2810N/A+ self.assertTrue(os.access(part_path, os.F_OK))
2810N/A+ self.replicator.replicate()
2810N/A+ self.assertFalse(os.access(part_path, os.F_OK))
2810N/A
2810N/A def test_delete_partition_override_params(self):
2810N/A df = DiskFile(self.devices, 'sda', '0', 'a', 'c', 'o', FakeLogger())
2810N/A@@ -613,12 +616,16 @@ class TestObjectReplicator(unittest.Test
2810N/A tpool.execute = was_execute
2810N/A
2810N/A def test_run(self):
2810N/A- with _mock_process([(0, '')] * 100):
2810N/A- self.replicator.replicate()
2810N/A+ with mockpatch('swift.obj.replicator.http_connect',
2810N/A+ mock_http_connect(200)):
2810N/A+ with _mock_process([(0, '')] * 100):
2810N/A+ self.replicator.replicate()
2810N/A
2810N/A def test_run_withlog(self):
2810N/A- with _mock_process([(0, "stuff in log")] * 100):
2810N/A- self.replicator.replicate()
2810N/A+ with mockpatch('swift.obj.replicator.http_connect',
2810N/A+ mock_http_connect(200)):
2810N/A+ with _mock_process([(0, "stuff in log")] * 100):
2810N/A+ self.replicator.replicate()
2810N/A
2810N/A if __name__ == '__main__':
2810N/A unittest.main()