Model a failure of the pipelined segments under concurrency.
()
| 156 | |
| 157 | |
| 158 | def test_multi_pipeline_fail(): |
| 159 | """Model a failure of the pipelined segments under concurrency.""" |
| 160 | group = worker.WalTransferGroup(FakeWalUploader()) |
| 161 | segments = list(prepare_multi_upload_segments()) |
| 162 | |
| 163 | exp = Explosion('fail') |
| 164 | fail_idx = 2 |
| 165 | segments[fail_idx]._upload_explosive = exp |
| 166 | |
| 167 | for seg in segments: |
| 168 | group.start(seg) |
| 169 | |
| 170 | with pytest.raises(Explosion) as e: |
| 171 | group.join() |
| 172 | |
| 173 | assert e.value is exp |
| 174 | |
| 175 | for i, seg in enumerate(segments): |
| 176 | if i == fail_idx: |
| 177 | assert failed(seg) |
| 178 | else: |
| 179 | # Given race conditions in conjunction with exceptions -- |
| 180 | # which will abort waiting for other greenlets to finish |
| 181 | # -- one can't know very much about the final state of |
| 182 | # segment. |
| 183 | assert indeterminate(seg) |
| 184 | |
| 185 | |
| 186 | def test_finally_execution(): |
nothing calls this directly
no test coverage detected