(mocker, worker, exception_thrown)
| 1108 | ], |
| 1109 | ) |
| 1110 | async def test_worker_crash(mocker, worker, exception_thrown): |
| 1111 | # Testing redis exceptions, no retry settings specified |
| 1112 | worker = worker(functions=[func(foobar)]) |
| 1113 | |
| 1114 | # patch db read_response to mimic connection exceptions |
| 1115 | p = patch.object(worker.pool.connection_pool.connection_class, 'read_response', side_effect=exception_thrown) |
| 1116 | |
| 1117 | # baseline |
| 1118 | await worker.main() |
| 1119 | await worker._poll_iteration() |
| 1120 | |
| 1121 | # spy method handling call_with_retry failure |
| 1122 | spy = mocker.spy(worker.pool, '_disconnect_raise') |
| 1123 | |
| 1124 | try: |
| 1125 | # start patch |
| 1126 | p.start() |
| 1127 | |
| 1128 | # assert exception thrown |
| 1129 | with pytest.raises(type(exception_thrown)): |
| 1130 | await worker._poll_iteration() |
| 1131 | |
| 1132 | # assert no retry counts and exception thrown during '_disconnect_raise' |
| 1133 | assert spy.call_count == 1 |
| 1134 | assert spy.spy_exception == exception_thrown |
| 1135 | |
| 1136 | finally: |
| 1137 | # stop patch to allow worker cleanup |
| 1138 | p.stop() |
nothing calls this directly
no test coverage detected
searching dependent graphs…