~ubuntu-branches/ubuntu/trusty/swift/trusty-updates

« back to all changes in this revision

Viewing changes to test/unit/container/test_sync.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short, James Page, Chuck Short
  • Date: 2013-08-13 10:37:13 UTC
  • mfrom: (1.2.21)
  • Revision ID: package-import@ubuntu.com-20130813103713-1ctbx4zifyljs2aq
Tags: 1.9.1-0ubuntu1
[ James Page ]
* d/control: Update VCS fields for new branch locations.

[ Chuck Short ]
* New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
126
126
 
127
127
        def fake_audit_location_generator(*args, **kwargs):
128
128
            audit_location_generator_calls[0] += 1
129
 
            # Makes .container_sync() short-circuit because 'path' doesn't end
130
 
            # with .db
131
 
            return [('path', 'device', 'partition')]
 
129
            # Makes .container_sync() short-circuit
 
130
            yield 'container.db', 'device', 'partition'
 
131
            return
132
132
 
133
133
        orig_time = sync.time
134
134
        orig_sleep = sync.sleep
135
135
        orig_audit_location_generator = sync.audit_location_generator
 
136
        orig_ContainerBroker = sync.ContainerBroker
136
137
        try:
 
138
            sync.ContainerBroker = lambda p: FakeContainerBroker(p,
 
139
                info={'account': 'a', 'container': 'c'})
137
140
            sync.time = fake_time
138
141
            sync.sleep = fake_sleep
139
142
            sync.audit_location_generator = fake_audit_location_generator
147
150
            sync.time = orig_time
148
151
            sync.sleep = orig_sleep
149
152
            sync.audit_location_generator = orig_audit_location_generator
 
153
            sync.ContainerBroker = orig_ContainerBroker
150
154
 
151
155
        self.assertEquals(time_calls, [9])
152
156
        self.assertEquals(len(sleep_calls), 2)
180
184
 
181
185
        def fake_audit_location_generator(*args, **kwargs):
182
186
            audit_location_generator_calls[0] += 1
183
 
            # Makes .container_sync() short-circuit because 'path' doesn't end
184
 
            # with .db
185
 
            return [('path', 'device', 'partition')]
 
187
            # Makes .container_sync() short-circuit
 
188
            yield 'container.db', 'device', 'partition'
 
189
            return
186
190
 
187
191
        orig_time = sync.time
188
192
        orig_audit_location_generator = sync.audit_location_generator
 
193
        orig_ContainerBroker = sync.ContainerBroker
189
194
        try:
 
195
            sync.ContainerBroker = lambda p: FakeContainerBroker(p,
 
196
                info={'account': 'a', 'container': 'c'})
190
197
            sync.time = fake_time
191
198
            sync.audit_location_generator = fake_audit_location_generator
192
199
            cs = sync.ContainerSync({}, container_ring=FakeRing(),
202
209
        finally:
203
210
            sync.time = orig_time
204
211
            sync.audit_location_generator = orig_audit_location_generator
 
212
            sync.ContainerBroker = orig_ContainerBroker
205
213
 
206
214
        self.assertEquals(time_calls, [10])
207
215
        self.assertEquals(audit_location_generator_calls, [2])
295
303
            cs.container_sync('isa.db')
296
304
            self.assertEquals(cs.container_failures, 0)
297
305
            self.assertEquals(cs.container_skips, 1)
298
 
 
 
306
 
299
307
            sync.ContainerBroker = lambda p: FakeContainerBroker(p,
300
308
                info={'account': 'a', 'container': 'c',
301
309
                      'x_container_sync_point1': -1,
308
316
            cs.container_sync('isa.db')
309
317
            self.assertEquals(cs.container_failures, 0)
310
318
            self.assertEquals(cs.container_skips, 2)
311
 
 
 
319
 
312
320
            sync.ContainerBroker = lambda p: FakeContainerBroker(p,
313
321
                info={'account': 'a', 'container': 'c',
314
322
                      'x_container_sync_point1': -1,
321
329
            cs.container_sync('isa.db')
322
330
            self.assertEquals(cs.container_failures, 0)
323
331
            self.assertEquals(cs.container_skips, 3)
324
 
 
 
332
 
325
333
            sync.ContainerBroker = lambda p: FakeContainerBroker(p,
326
334
                info={'account': 'a', 'container': 'c',
327
335
                      'x_container_sync_point1': -1,
336
344
            cs.container_sync('isa.db')
337
345
            self.assertEquals(cs.container_failures, 1)
338
346
            self.assertEquals(cs.container_skips, 3)
339
 
 
 
347
 
340
348
            sync.ContainerBroker = lambda p: FakeContainerBroker(p,
341
349
                info={'account': 'a', 'container': 'c',
342
350
                      'x_container_sync_point1': -1,
385
393
 
386
394
            def fake_time():
387
395
                return fake_times.pop(0)
388
 
                
 
396
 
389
397
            sync.time = fake_time
390
398
            # This same sync won't fail since it will look like it took so long
391
399
            # as to be time to move on (before it ever actually tries to do