183
183
lock_base = lf2.transport.abspath(lf2.path)
184
184
self.assertEqual(1, len(self._logged_reports))
185
self.assertEqual('Unable to obtain %s\n'
185
self.assertEqual('%s %s\n'
187
187
'Will continue to try for %s seconds\n',
188
188
self._logged_reports[0][0])
189
189
args = self._logged_reports[0][1]
190
self.assertEqual('lock %s' % (lock_base,), args[0])
191
self.assertStartsWith(args[1], 'held by ')
192
self.assertStartsWith(args[2], 'locked ')
193
self.assertEndsWith(args[2], ' ago')
190
self.assertEqual('Unable to obtain', args[0])
191
self.assertEqual('lock %s' % (lock_base,), args[1])
192
self.assertStartsWith(args[2], 'held by ')
193
self.assertStartsWith(args[3], 'locked ')
194
self.assertEndsWith(args[3], ' ago')
195
196
def test_31_lock_wait_easy(self):
196
197
"""Succeed when waiting on a lock with no contention.
239
240
# wait for a while
240
241
lock_base = lf2.transport.abspath(lf2.path)
241
242
self.assertEqual(1, len(self._logged_reports))
242
self.assertEqual('Unable to obtain %s\n'
243
self.assertEqual('%s %s\n'
244
245
'Will continue to try for %s seconds\n',
245
246
self._logged_reports[0][0])
246
247
args = self._logged_reports[0][1]
247
self.assertEqual('lock %s' % (lock_base,), args[0])
248
self.assertStartsWith(args[1], 'held by ')
249
self.assertStartsWith(args[2], 'locked ')
250
self.assertEndsWith(args[2], ' ago')
248
self.assertEqual('Unable to obtain', args[0])
249
self.assertEqual('lock %s' % (lock_base,), args[1])
250
self.assertStartsWith(args[2], 'held by ')
251
self.assertStartsWith(args[3], 'locked ')
252
self.assertEndsWith(args[3], ' ago')
252
254
def test_33_wait(self):
253
255
"""Succeed when waiting on a lock that gets released
303
304
# wait for a while
304
305
lock_base = lf2.transport.abspath(lf2.path)
305
306
self.assertEqual(1, len(self._logged_reports))
306
self.assertEqual('Unable to obtain %s\n'
307
self.assertEqual('%s %s\n'
308
309
'Will continue to try for %s seconds\n',
309
310
self._logged_reports[0][0])
310
311
args = self._logged_reports[0][1]
311
self.assertEqual('lock %s' % (lock_base,), args[0])
312
self.assertStartsWith(args[1], 'held by ')
313
self.assertStartsWith(args[2], 'locked ')
314
self.assertEndsWith(args[2], ' ago')
312
self.assertEqual('Unable to obtain', args[0])
313
self.assertEqual('lock %s' % (lock_base,), args[1])
314
self.assertStartsWith(args[2], 'held by ')
315
self.assertStartsWith(args[3], 'locked ')
316
self.assertEndsWith(args[3], ' ago')
316
318
def test_35_wait_lock_changing(self):
317
319
"""LockDir.wait_lock() will report if the lock changes underneath.
410
412
# There should be 2 reports, because the lock changed
411
413
lock_base = lf2.transport.abspath(lf2.path)
412
414
self.assertEqual(2, len(self._logged_reports))
413
def check_one(index):
414
self.assertEqual('Unable to obtain %s\n'
415
def check_one(index, msg):
416
self.assertEqual('%s %s\n'
416
418
'Will continue to try for %s seconds\n',
417
419
self._logged_reports[index][0])
418
420
args = self._logged_reports[index][1]
419
self.assertEqual('lock %s' % (lock_base,), args[0])
420
self.assertStartsWith(args[1], 'held by ')
421
self.assertStartsWith(args[2], 'locked ')
422
self.assertEndsWith(args[2], ' ago')
421
self.assertEqual(msg, args[0])
422
self.assertEqual('lock %s' % (lock_base,), args[1])
423
self.assertStartsWith(args[2], 'held by ')
424
self.assertStartsWith(args[3], 'locked ')
425
self.assertEndsWith(args[3], ' ago')
426
check_one(0, 'Unable to obtain')
427
check_one(1, 'Lock owner changed for')
426
429
def test_40_confirm_easy(self):
427
430
"""Confirm a lock that's already held"""