MCPcopy Create free account
hub / github.com/wal-e/wal-e / test_finally_execution

Function test_finally_execution

tests/test_wal_transfer.py:186–220  ·  view source on GitHub ↗

When one segment fails ensure parallel segments clean up.

()

Source from the content-addressed store, hash-verified

184
185
186def test_finally_execution():
187 """When one segment fails ensure parallel segments clean up."""
188 segBad = FakeWalSegment('1' * 8 * 3)
189 segOK = FakeWalSegment('2' * 8 * 3)
190
191 class CleanupCheckingUploader(object):
192 def __init__(self):
193 self.cleaned_up = False
194
195 def __call__(self, segment):
196 if segment is segOK:
197 try:
198 while True:
199 gevent.sleep(0.1)
200 finally:
201 self.cleaned_up = True
202
203 elif segment is segBad:
204 raise Explosion('fail')
205
206 else:
207 assert False, 'Expect only two segments'
208
209 segment._uploaded = True
210 return segment
211
212 uploader = CleanupCheckingUploader()
213 group = worker.WalTransferGroup(uploader)
214 group.start(segOK)
215 group.start(segBad)
216
217 with pytest.raises(Explosion):
218 group.join()
219
220 assert uploader.cleaned_up is True
221
222
223def test_start_after_join():

Callers

nothing calls this directly

Calls 4

startMethod · 0.95
joinMethod · 0.95
FakeWalSegmentClass · 0.85

Tested by

no test coverage detected