components/openstack/swift/patches/test.patch
changeset 1944 56ac2df1785b
parent 1896 f83e6dde6c3b
child 2167 c9ff638a3018
equal deleted inserted replaced
1943:1a27f000029f 1944:56ac2df1785b
     3   - Tests involving large (5GB+) bodies are mocked, but on 32-bit python,
     3   - Tests involving large (5GB+) bodies are mocked, but on 32-bit python,
     4     len() is limited to returning a ssize_t, which can represent 2GB.
     4     len() is limited to returning a ssize_t, which can represent 2GB.
     5 
     5 
     6   - Solaris doesn't yet support syslog logging to /dev/log.
     6   - Solaris doesn't yet support syslog logging to /dev/log.
     7 
     7 
     8   - Solaris doesn't have TCP_KEEPIDLE.
     8 The first, while potentially useful elsewhere, is really only an issue on
     9 
     9 Solaris because Linux runs almost exclusively 64-bit, which makes this a
    10   - Three tests make connections to 127.0.0.[234], which take minutes to
    10 non-issue.  The last is Solaris-only -- though clearly a similar problem
    11     timeout (and one test fails).  Mock the connections to make the return
    11 exists on MacOS -- and we will want to fix this in our Python.
    12     success immediately.
       
    13 
       
    14 The last has already been fixed upstream, as of 1.9.1.  The middle two are
       
    15 Solaris-only, and not suitable for upstream.  The first, while potentially
       
    16 useful elsewhere, is really only an issue on Solaris because Linux runs
       
    17 almost exclusively 64-bit, which makes this a non-issue.
       
    18 
    12 
    19 diff --git a/test/unit/__init__.py b/test/unit/__init__.py
    13 diff --git a/test/unit/__init__.py b/test/unit/__init__.py
    20 --- a/test/unit/__init__.py
    14 --- a/test/unit/__init__.py
    21 +++ b/test/unit/__init__.py
    15 +++ b/test/unit/__init__.py
    22 @@ -315,7 +315,7 @@ def fake_http_connect(*code_iter, **kwar
    16 @@ -450,7 +450,7 @@ def fake_http_connect(*code_iter, **kwar
    23                  else:
    17                  else:
    24                      etag = '"68b329da9893e34099c7d8ad5cb9c940"'
    18                      etag = '"68b329da9893e34099c7d8ad5cb9c940"'
    25  
    19  
    26 -            headers = {'content-length': len(self.body),
    20 -            headers = {'content-length': len(self.body),
    27 +            headers = {'content-length': self.body.__len__(),
    21 +            headers = {'content-length': self.body.__len__(),
    29                         'x-timestamp': self.timestamp,
    23                         'x-timestamp': self.timestamp,
    30                         'last-modified': self.timestamp,
    24                         'last-modified': self.timestamp,
    31 diff --git a/test/unit/proxy/test_server.py b/test/unit/proxy/test_server.py
    25 diff --git a/test/unit/proxy/test_server.py b/test/unit/proxy/test_server.py
    32 --- a/test/unit/proxy/test_server.py
    26 --- a/test/unit/proxy/test_server.py
    33 +++ b/test/unit/proxy/test_server.py
    27 +++ b/test/unit/proxy/test_server.py
    34 @@ -2310,6 +2310,9 @@ class TestObjectController(unittest.Test
    28 @@ -2876,6 +2876,9 @@ class TestObjectController(unittest.Test
    35  
    29  
    36              class LargeResponseBody(object):
    30              class LargeResponseBody(object):
    37  
    31  
    38 +                def __nonzero__(self):
    32 +                def __nonzero__(self):
    39 +                    return True
    33 +                    return True
    40 +
    34 +
    41                  def __len__(self):
    35                  def __len__(self):
    42                      return MAX_FILE_SIZE + 1
    36                      return MAX_FILE_SIZE + 1
    43  
    37  
    44 @@ -2439,6 +2442,9 @@ class TestObjectController(unittest.Test
    38 @@ -3006,6 +3009,9 @@ class TestObjectController(unittest.Test
    45  
    39  
    46              class LargeResponseBody(object):
    40              class LargeResponseBody(object):
    47  
    41  
    48 +                def __nonzero__(self):
    42 +                def __nonzero__(self):
    49 +                    return True
    43 +                    return True
    52                      return MAX_FILE_SIZE + 1
    46                      return MAX_FILE_SIZE + 1
    53  
    47  
    54 diff --git a/test/unit/common/test_utils.py b/test/unit/common/test_utils.py
    48 diff --git a/test/unit/common/test_utils.py b/test/unit/common/test_utils.py
    55 --- a/test/unit/common/test_utils.py
    49 --- a/test/unit/common/test_utils.py
    56 +++ b/test/unit/common/test_utils.py
    50 +++ b/test/unit/common/test_utils.py
    57 @@ -425,9 +425,15 @@ class TestUtils(unittest.TestCase):
    51 @@ -437,7 +437,8 @@ class TestUtils(unittest.TestCase):
    58              logger = utils.get_logger({
       
    59                  'log_facility': 'LOG_LOCAL3',
       
    60              }, 'server', log_route='server')
    52              }, 'server', log_route='server')
    61 +            if sys.platform == 'sunos5':
    53              expected_args = [((), {'address': '/dev/log',
    62 +                extra = [
    54                                     'facility': orig_sysloghandler.LOG_LOCAL3})]
    63 +                  ((), {'facility': orig_sysloghandler.LOG_LOCAL3})
    55 -            if not os.path.exists('/dev/log') or \
    64 +                ]
    56 +            if sys.platform == 'sunos5' or \
    65 +            else:
    57 +                    not os.path.exists('/dev/log') or \
    66 +                extra = []
    58                      os.path.isfile('/dev/log') or \
    67              self.assertEquals([
    59                      os.path.isdir('/dev/log'):
    68                  ((), {'address': '/dev/log',
    60                  # Since socket on OSX is in /var/run/syslog, there will be
    69 -                      'facility': orig_sysloghandler.LOG_LOCAL3})],
       
    70 +                      'facility': orig_sysloghandler.LOG_LOCAL3})] + extra,
       
    71                  syslog_handler_args)
       
    72  
       
    73              syslog_handler_args = []
       
    74 diff --git a/test/unit/common/test_wsgi.py b/test/unit/common/test_wsgi.py
       
    75 --- a/test/unit/common/test_wsgi.py
       
    76 +++ b/test/unit/common/test_wsgi.py
       
    77 @@ -116,11 +116,12 @@ class TestWSGI(unittest.TestCase):
       
    78                  socket.SOL_SOCKET: {
       
    79                      socket.SO_REUSEADDR: 1,
       
    80                      socket.SO_KEEPALIVE: 1,
       
    81 -                },
       
    82 -                socket.IPPROTO_TCP: {
       
    83 +                }
       
    84 +            }
       
    85 +            if hasattr(socket, 'TCP_KEEPIDLE'):
       
    86 +                expected_socket_opts[socket.IPPROTO_TCP] = {
       
    87                      socket.TCP_KEEPIDLE: 600,
       
    88 -                },
       
    89 -            }
       
    90 +                }
       
    91              self.assertEquals(sock.opts, expected_socket_opts)
       
    92              # test ssl
       
    93              sock = wsgi.get_socket(ssl_conf)
       
    94 diff --git a/test/unit/obj/test_replicator.py b/test/unit/obj/test_replicator.py
       
    95 --- a/test/unit/obj/test_replicator.py
       
    96 +++ b/test/unit/obj/test_replicator.py
       
    97 @@ -17,6 +17,7 @@ from __future__ import with_statement
       
    98  
       
    99  import unittest
       
   100  import os
       
   101 +from mock import patch as mockpatch
       
   102  from gzip import GzipFile
       
   103  from shutil import rmtree
       
   104  import cPickle as pickle
       
   105 @@ -482,14 +483,16 @@ class TestObjectReplicator(unittest.Test
       
   106              self.replicator.logger.log_dict['warning'])
       
   107  
       
   108      def test_delete_partition(self):
       
   109 -        df = DiskFile(self.devices, 'sda', '0', 'a', 'c', 'o', FakeLogger())
       
   110 -        mkdirs(df.datadir)
       
   111 -        ohash = hash_path('a', 'c', 'o')
       
   112 -        data_dir = ohash[-3:]
       
   113 -        part_path = os.path.join(self.objects, '1')
       
   114 -        self.assertTrue(os.access(part_path, os.F_OK))
       
   115 -        self.replicator.replicate()
       
   116 -        self.assertFalse(os.access(part_path, os.F_OK))
       
   117 +        with mockpatch('swift.obj.replicator.http_connect',
       
   118 +                        mock_http_connect(200)):
       
   119 +            df = DiskFile(self.devices, 'sda', '0', 'a', 'c', 'o', FakeLogger())
       
   120 +            mkdirs(df.datadir)
       
   121 +            ohash = hash_path('a', 'c', 'o')
       
   122 +            data_dir = ohash[-3:]
       
   123 +            part_path = os.path.join(self.objects, '1')
       
   124 +            self.assertTrue(os.access(part_path, os.F_OK))
       
   125 +            self.replicator.replicate()
       
   126 +            self.assertFalse(os.access(part_path, os.F_OK))
       
   127  
       
   128      def test_delete_partition_override_params(self):
       
   129          df = DiskFile(self.devices, 'sda', '0', 'a', 'c', 'o', FakeLogger())
       
   130 @@ -613,12 +616,16 @@ class TestObjectReplicator(unittest.Test
       
   131              tpool.execute = was_execute
       
   132  
       
   133      def test_run(self):
       
   134 -        with _mock_process([(0, '')] * 100):
       
   135 -            self.replicator.replicate()
       
   136 +        with mockpatch('swift.obj.replicator.http_connect',
       
   137 +                        mock_http_connect(200)):
       
   138 +            with _mock_process([(0, '')] * 100):
       
   139 +                self.replicator.replicate()
       
   140  
       
   141      def test_run_withlog(self):
       
   142 -        with _mock_process([(0, "stuff in log")] * 100):
       
   143 -            self.replicator.replicate()
       
   144 +        with mockpatch('swift.obj.replicator.http_connect',
       
   145 +                        mock_http_connect(200)):
       
   146 +            with _mock_process([(0, "stuff in log")] * 100):
       
   147 +                self.replicator.replicate()
       
   148  
       
   149  if __name__ == '__main__':
       
   150      unittest.main()