예제 #1
0
def test_get_test_selection_data_from_bugbug_handle_exceeded_timeout(
        responses, monkeypatch):
    rev = "a" * 40
    branch = "autoland"
    push = Push(rev, branch)

    task_url = f"{PRODUCTION_TASKCLUSTER_ROOT_URL}/api/index/v1/task/gecko.v2.{branch}.revision.{rev}.taskgraph.decision"
    responses.add(responses.GET,
                  task_url,
                  status=200,
                  json={"taskId": "a" * 10})

    cache_url = f"{PRODUCTION_TASKCLUSTER_ROOT_URL}/api/queue/v1/task/aaaaaaaaaa/artifacts/public/bugbug-push-schedules.json"
    responses.add(responses.GET, cache_url, status=404)

    url = f"{bugbug.BUGBUG_BASE_URL}/push/{branch}/{rev}/schedules"
    responses.add(responses.GET, url, status=202)

    monkeypatch.setattr(bugbug, "DEFAULT_RETRY_TIMEOUT", 3)
    monkeypatch.setattr(bugbug, "DEFAULT_RETRY_INTERVAL", 1)
    with pytest.raises(bugbug.BugbugTimeoutException) as e:
        push.get_test_selection_data()
    assert str(
        e.value) == "Timed out waiting for result from Bugbug HTTP Service"

    assert len(responses.calls) == 5
    assert [(call.request.method, call.request.url)
            for call in responses.calls] == [
                ("GET", task_url),
                ("GET", cache_url),
                # We retry 3 times the call to the Bugbug HTTP service
                ("GET", url),
                ("GET", url),
                ("GET", url),
            ]
예제 #2
0
def test_get_test_selection_data_from_bugbug(responses):
    rev = "a" * 40
    branch = "autoland"
    push = Push(rev, branch)

    task_url = f"{PRODUCTION_TASKCLUSTER_ROOT_URL}/api/index/v1/task/gecko.v2.{branch}.revision.{rev}.taskgraph.decision"
    responses.add(responses.GET,
                  task_url,
                  status=200,
                  json={"taskId": "a" * 10})

    cache_url = f"{PRODUCTION_TASKCLUSTER_ROOT_URL}/api/queue/v1/task/aaaaaaaaaa/artifacts/public/bugbug-push-schedules.json"
    responses.add(responses.GET, cache_url, status=404)

    url = f"{bugbug.BUGBUG_BASE_URL}/push/{branch}/{rev}/schedules"
    responses.add(responses.GET, url, status=200, json=SCHEDULES_EXTRACT)

    data = push.get_test_selection_data()
    assert data == SCHEDULES_EXTRACT

    assert len(responses.calls) == 3
    assert [(call.request.method, call.request.url)
            for call in responses.calls] == [
                ("GET", task_url),
                ("GET", cache_url),
                ("GET", url),
            ]
예제 #3
0
def test_get_test_selection_data_from_bugbug_handle_errors(
        responses, monkeypatch):
    rev = "a" * 40
    branch = "autoland"
    push = Push(rev, branch)

    task_url = f"{PRODUCTION_TASKCLUSTER_ROOT_URL}/api/index/v1/task/gecko.v2.{branch}.revision.{rev}.taskgraph.decision"
    responses.add(responses.GET,
                  task_url,
                  status=200,
                  json={"taskId": "a" * 10})

    cache_url = f"{PRODUCTION_TASKCLUSTER_ROOT_URL}/api/queue/v1/task/aaaaaaaaaa/artifacts/public/bugbug-push-schedules.json"
    responses.add(responses.GET, cache_url, status=404)

    url = f"{bugbug.BUGBUG_BASE_URL}/push/{branch}/{rev}/schedules"
    responses.add(responses.GET, url, status=500)

    monkeypatch.setattr(bugbug, "DEFAULT_RETRY_TIMEOUT", 3)
    monkeypatch.setattr(bugbug, "DEFAULT_RETRY_INTERVAL", 1)
    with pytest.raises(SourcesNotFound) as e:
        push.get_test_selection_data()
    assert (
        e.value.msg ==
        "No registered sources were able to fulfill 'push_test_selection_data'!"
    )

    assert len(responses.calls) == 5
    assert [(call.request.method, call.request.url)
            for call in responses.calls] == [
                ("GET", task_url),
                ("GET", cache_url),
                # We retry 3 times the call to the Bugbug HTTP service
                ("GET", url),
                ("GET", url),
                ("GET", url),
            ]