示例#1
0
def test_retry_missing_revision_succeeds(sample_data, sample_push,
                                         test_repository, mock_log_parser,
                                         monkeypatch):
    """
    Ensure that when the missing push exists after a retry, that the job
    is then ingested.
    """
    thread_data = local()
    thread_data.retries = 0
    rs = sample_push[0]
    job = sample_data.pulse_jobs[0]
    job["origin"]["revision"] = rs["revision"]
    job["origin"]["project"] = test_repository.name

    orig_retry = store_pulse_jobs.retry

    def retry_mock(exc=None, countdown=None):
        assert isinstance(exc, MissingPushException)
        thread_data.retries += 1
        store_push_data(test_repository, [rs])
        return orig_retry(exc=exc, countdown=countdown)

    monkeypatch.setattr(store_pulse_jobs, "retry", retry_mock)
    store_pulse_jobs.delay(job, "foo", "bar")

    assert Job.objects.count() == 1
    assert Job.objects.values()[0]["guid"] == job["taskId"]
    assert thread_data.retries == 1
示例#2
0
def test_retry_missing_revision_succeeds(sample_data, sample_resultset,
                                         test_project, jm, mock_log_parser,
                                         monkeypatch):
    """
    Ensure that when the missing resultset exists after a retry, that the job
    is then ingested.
    """
    thread_data = local()
    thread_data.retries = 0
    rs = sample_resultset[0]
    job = sample_data.pulse_jobs[0]
    job["origin"]["revision"] = rs["revision"]
    job["origin"]["project"] = test_project

    orig_retry = store_pulse_jobs.retry

    def retry_mock(exc=None, countdown=None):
        assert isinstance(exc, MissingPushException)
        thread_data.retries += 1
        jm.store_result_set_data([rs])
        return orig_retry(exc=exc, countdown=countdown)

    monkeypatch.setattr(store_pulse_jobs, "retry", retry_mock)
    store_pulse_jobs.delay(job, "foo", "bar")

    assert Job.objects.count() == 1
    assert Job.objects.values()[0]["guid"] == job["taskId"]
    assert thread_data.retries == 1
示例#3
0
def test_retry_missing_revision_never_succeeds(sample_data, test_repository,
                                               mock_log_parser, monkeypatch):
    """
    Ensure that when the missing push exists after a retry, that the job
    is then ingested.
    """
    job = sample_data.pulse_jobs[0]
    job["origin"]["project"] = test_repository.name

    with pytest.raises(MissingPushException):
        store_pulse_jobs.delay(job, "foo", "bar")

    assert Job.objects.count() == 0
示例#4
0
def test_retry_missing_revision_never_succeeds(sample_data, test_project,
                                               jm, mock_log_parser, monkeypatch):
    """
    Ensure that when the missing resultset exists after a retry, that the job
    is then ingested.
    """
    job = sample_data.pulse_jobs[0]
    job["origin"]["project"] = test_project

    with pytest.raises(MissingPushException):
        store_pulse_jobs.delay(job, "foo", "bar")

    assert Job.objects.count() == 0