Esempio n. 1
0
def test_update_error_verify_bug(client,
                                 test_repository,
                                 text_log_errors_failure_lines,
                                 classified_failures,
                                 test_user):
    text_log_errors, _ = text_log_errors_failure_lines
    client.force_authenticate(user=test_user)

    error_line = text_log_errors[0]
    assert error_line.metadata.best_classification == classified_failures[0]
    assert error_line.metadata.best_is_verified is False

    classified_failures[0].bug_number = 1234
    classified_failures[0].save()

    body = {"bug_number": classified_failures[0].bug_number}

    resp = client.put(
        reverse("text-log-error-detail", kwargs={"pk": error_line.id}),
        body)

    assert resp.status_code == 200

    error_line.metadata.refresh_from_db()

    assert error_line.metadata.best_classification == classified_failures[0]
    assert error_line.metadata.best_is_verified

    if settings.ELASTICSEARCH_URL:
        es_line = get_document(error_line.metadata.failure_line.id)
        assert es_line['best_classification'] == classified_failures[0].id
        assert es_line['best_is_verified']
def test_update_error_verify(client,
                             test_repository,
                             text_log_errors_failure_lines,
                             classified_failures,
                             test_user):

    text_log_errors, _ = text_log_errors_failure_lines
    client.force_authenticate(user=test_user)

    error_line = text_log_errors[0]
    assert error_line.metadata.best_classification == classified_failures[0]
    assert error_line.metadata.best_is_verified is False

    body = {"best_classification": classified_failures[0].id}

    resp = client.put(
        reverse("text-log-error-detail", kwargs={"pk": error_line.id}),
        body)

    assert resp.status_code == 200

    error_line.metadata.refresh_from_db()

    assert error_line.metadata.best_classification == classified_failures[0]
    assert error_line.metadata.best_is_verified

    es_line = get_document(error_line.metadata.failure_line.id)
    assert es_line['best_classification'] == classified_failures[0].id
    assert es_line['best_is_verified']
def test_store_error_summary_elastic_search(activate_responses,
                                            test_repository, test_job,
                                            elasticsearch):
    log_path = SampleData().get_log_path("plain-chunked_errorsummary.log")
    log_url = 'http://my-log.mozilla.org'

    with open(log_path) as log_handler:
        responses.add(responses.GET,
                      log_url,
                      body=log_handler.read(),
                      status=200)

    log_obj = JobLog.objects.create(job=test_job,
                                    name="errorsummary_json",
                                    url=log_url)

    store_failure_lines(log_obj)

    assert FailureLine.objects.count() == 1

    failure = FailureLine.objects.get(pk=1)

    es_line = get_document(1)
    for prop in ["test", "subtest", "status", "expected"]:
        assert es_line[prop] == getattr(failure, prop)
    assert es_line['best_classification'] is None
    assert es_line['best_is_verified'] is False
Esempio n. 4
0
def test_update_error_verify(client, test_repository,
                             text_log_errors_failure_lines,
                             classified_failures, test_user):

    text_log_errors, _ = text_log_errors_failure_lines
    client.force_authenticate(user=test_user)

    error_line = text_log_errors[0]
    assert error_line.metadata.best_classification == classified_failures[0]
    assert error_line.metadata.best_is_verified is False

    body = {"best_classification": classified_failures[0].id}

    resp = client.put(
        reverse("text-log-error-detail", kwargs={"pk": error_line.id}), body)

    assert resp.status_code == 200

    error_line.metadata.refresh_from_db()

    assert error_line.metadata.best_classification == classified_failures[0]
    assert error_line.metadata.best_is_verified

    if settings.ELASTICSEARCH_URL:
        es_line = get_document(error_line.metadata.failure_line.id)
        assert es_line['best_classification'] == classified_failures[0].id
        assert es_line['best_is_verified']
Esempio n. 5
0
def test_update_failure_line_verify(test_repository,
                                    text_log_errors_failure_lines,
                                    classified_failures, client, test_user):

    text_log_errors, _ = text_log_errors_failure_lines
    client.force_authenticate(user=test_user)

    error_line = text_log_errors[0]
    assert error_line.metadata.best_classification == classified_failures[0]
    assert error_line.metadata.best_is_verified is False

    body = {
        "project": test_repository.name,
        "best_classification": classified_failures[0].id
    }

    resp = client.put(
        reverse("failure-line-detail",
                kwargs={"pk": error_line.metadata.failure_line.id}), body)

    assert resp.status_code == 200

    error_line.metadata.refresh_from_db()
    error_line.refresh_from_db()

    assert error_line.metadata.best_classification == classified_failures[0]
    assert error_line.metadata.best_is_verified

    es_line = get_document(error_line.metadata.failure_line.id)
    assert es_line['best_classification'] == classified_failures[0].id
    assert es_line['best_is_verified']
def test_update_error_verify_bug(client,
                                 test_repository,
                                 text_log_errors_failure_lines,
                                 classified_failures,
                                 test_user):
    text_log_errors, _ = text_log_errors_failure_lines
    client.force_authenticate(user=test_user)

    error_line = text_log_errors[0]
    assert error_line.metadata.best_classification == classified_failures[0]
    assert error_line.metadata.best_is_verified is False

    classified_failures[0].bug_number = 1234
    classified_failures[0].save()

    body = {"bug_number": classified_failures[0].bug_number}

    resp = client.put(
        reverse("text-log-error-detail", kwargs={"pk": error_line.id}),
        body)

    assert resp.status_code == 200

    error_line.metadata.refresh_from_db()

    assert error_line.metadata.best_classification == classified_failures[0]
    assert error_line.metadata.best_is_verified

    es_line = get_document(error_line.metadata.failure_line.id)
    assert es_line['best_classification'] == classified_failures[0].id
    assert es_line['best_is_verified']
def test_store_error_summary_elastic_search(activate_responses, test_repository,
                                            test_job, elasticsearch):
    log_path = SampleData().get_log_path("plain-chunked_errorsummary.log")
    log_url = 'http://my-log.mozilla.org'

    with open(log_path) as log_handler:
        responses.add(responses.GET, log_url,
                      body=log_handler.read(), status=200)

    log_obj = JobLog.objects.create(job=test_job, name="errorsummary_json",
                                    url=log_url)

    store_failure_lines(log_obj)

    assert FailureLine.objects.count() == 1

    failure = FailureLine.objects.get(pk=1)

    es_line = get_document(1)
    for prop in ["test", "subtest", "status", "expected"]:
        assert es_line[prop] == getattr(failure, prop)
    assert es_line['best_classification'] is None
    assert es_line['best_is_verified'] is False