示例#1
0
def test_auditor_check_survives_failures_and_queues_failed_rses():
    queue = multiprocessing.Queue()
    retry = multiprocessing.Queue()
    queue.put(('RSE_WITH_EXCEPTION', 1))
    queue.put(('RSE_SHOULD_WORK', 1))
    queue.put(('RSE_WITH_ERROR', 1))
    wr_pipe = collections.namedtuple('FakePipe', ('send', 'close'))(
        lambda _: None,
        lambda: None,
    )

    def fake_consistency(rse, delta, configuration, cache_dir, results_dir):
        if rse == 'RSE_WITH_EXCEPTION':
            raise Exception
        elif rse == 'RSE_SHOULD_WORK':
            pass
        else:
            return 1 / 0

    terminate = multiprocessing.Event()
    with stubbed(auditor.consistency, fake_consistency):
        with stubbed(terminate.is_set, lambda slf: queue.empty()):
            auditor.check(queue, retry, terminate, wr_pipe, None, None, 3,
                          False)

    ok_(queue.empty())
    eq_(retry.get(), ('RSE_WITH_EXCEPTION', 0))
    eq_(retry.get(), ('RSE_WITH_ERROR', 0))
    ok_(retry.empty())
示例#2
0
def test_auditor_check_survives_failures_and_queues_failed_rses(mock_auditor):
    queue = multiprocessing.Queue()
    retry = multiprocessing.Queue()
    queue.put(('RSE_WITH_EXCEPTION', 1))
    queue.put(('RSE_SHOULD_WORK', 1))
    queue.put(('RSE_WITH_ERROR', 1))
    wr_pipe = collections.namedtuple('FakePipe', ('send', 'close'))(
        lambda _: None,
        lambda: None,
    )

    class MockMultiProcessing():
        def is_set(self):
            return queue.empty()
    terminate = MockMultiProcessing()
    auditor.check(queue, retry, terminate, wr_pipe, None, None, 3, False)

    assert queue.empty()
    assert retry.get() == ('RSE_WITH_EXCEPTION', 0)
    assert retry.get() == ('RSE_WITH_ERROR', 0)
    assert retry.empty()