~gholt/swift/timeout_baseexception

« back to all changes in this revision

Viewing changes to test/unit/obj/test_replicator.py

  • Committer: Tarmac
  • Author(s): David Goetz
  • Date: 2011-03-29 20:19:09 UTC
  • mfrom: (238.3.11 obj_server_0b_check)
  • Revision ID: tarmac-20110329201909-jvhx1i93pvg8gn6f
Check the md5sum against metadata ETag on object GETs, and zero byte checks on GETs, HEADs, and POSTs.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
import time
26
26
import tempfile
27
27
from contextlib import contextmanager
28
 
from eventlet import tpool
29
 
 
30
28
from eventlet.green import subprocess
 
29
from test.unit import FakeLogger
31
30
from swift.common import utils
32
31
from swift.common.utils import hash_path, mkdirs, normalize_timestamp
33
32
from swift.common import ring
164
163
        was_connector = object_replicator.http_connect
165
164
        object_replicator.http_connect = mock_http_connect(200)
166
165
        cur_part = '0'
167
 
        df = DiskFile(self.devices, 'sda', cur_part, 'a', 'c', 'o')
 
166
        df = DiskFile(self.devices, 'sda', cur_part, 'a', 'c', 'o',
 
167
                      FakeLogger())
168
168
        mkdirs(df.datadir)
169
169
        f = open(os.path.join(df.datadir,
170
170
                              normalize_timestamp(time.time()) + '.data'),
189
189
        object_replicator.http_connect = was_connector
190
190
 
191
191
    def test_get_hashes(self):
192
 
        df = DiskFile(self.devices, 'sda', '0', 'a', 'c', 'o')
 
192
        df = DiskFile(self.devices, 'sda', '0', 'a', 'c', 'o', FakeLogger())
193
193
        mkdirs(df.datadir)
194
194
        with open(os.path.join(df.datadir, normalize_timestamp(
195
195
                    time.time()) + '.ts'), 'wb') as f:
206
206
        self.assert_('a83' in hashes)
207
207
 
208
208
    def test_hash_suffix_one_file(self):
209
 
        df = DiskFile(self.devices, 'sda', '0', 'a', 'c', 'o')
 
209
        df = DiskFile(self.devices, 'sda', '0', 'a', 'c', 'o', FakeLogger())
210
210
        mkdirs(df.datadir)
211
211
        f = open(os.path.join(df.datadir,
212
212
                     normalize_timestamp(time.time() - 100) + '.ts'),
223
223
        self.assertEquals(len(os.listdir(self.parts['0'])), 0)
224
224
 
225
225
    def test_hash_suffix_multi_file_one(self):
226
 
        df = DiskFile(self.devices, 'sda', '0', 'a', 'c', 'o')
 
226
        df = DiskFile(self.devices, 'sda', '0', 'a', 'c', 'o', FakeLogger())
227
227
        mkdirs(df.datadir)
228
228
        for tdiff in [1, 50, 100, 500]:
229
229
            for suff in ['.meta', '.data', '.ts']:
244
244
        self.assertEquals(len(os.listdir(whole_hsh_path)), 1)
245
245
 
246
246
    def test_hash_suffix_multi_file_two(self):
247
 
        df = DiskFile(self.devices, 'sda', '0', 'a', 'c', 'o')
 
247
        df = DiskFile(self.devices, 'sda', '0', 'a', 'c', 'o', FakeLogger())
248
248
        mkdirs(df.datadir)
249
249
        for tdiff in [1, 50, 100, 500]:
250
250
            suffs = ['.meta', '.data']
274
274
                fdata = fp.read()
275
275
                self.assertEquals(fdata, data)
276
276
 
277
 
        df = DiskFile(self.devices, 'sda', '0', 'a', 'c', 'o')
 
277
        df = DiskFile(self.devices, 'sda', '0', 'a', 'c', 'o', FakeLogger())
278
278
        mkdirs(df.datadir)
279
279
        ohash = hash_path('a', 'c', 'o')
280
280
        data_dir = ohash[-3:]
329
329
                              os.path.join(self.objects, part))
330
330
 
331
331
    def test_delete_partition(self):
332
 
        df = DiskFile(self.devices, 'sda', '0', 'a', 'c', 'o')
 
332
        df = DiskFile(self.devices, 'sda', '0', 'a', 'c', 'o', FakeLogger())
333
333
        mkdirs(df.datadir)
334
334
        ohash = hash_path('a', 'c', 'o')
335
335
        data_dir = ohash[-3:]
347
347
        # Write some files into '1' and run replicate- they should be moved
348
348
        # to the other partitoins and then node should get deleted.
349
349
        cur_part = '1'
350
 
        df = DiskFile(self.devices, 'sda', cur_part, 'a', 'c', 'o')
 
350
        df = DiskFile(self.devices, 'sda', cur_part, 'a', 'c', 'o',
 
351
                      FakeLogger())
351
352
        mkdirs(df.datadir)
352
353
        f = open(os.path.join(df.datadir,
353
354
                              normalize_timestamp(time.time()) + '.data'),