def test_store_error_summary_truncated(activate_responses, test_repository,
                                       test_job, monkeypatch):
    log_path = SampleData().get_log_path(
        "plain-chunked_errorsummary_10_lines.log")
    log_url = 'http://my-log.mozilla.org'

    monkeypatch.setattr(settings, 'FAILURE_LINES_CUTOFF', 5)

    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() == 5 + 1

    assert Group.objects.count() == 1

    failure = FailureLine.objects.get(pk=1)
    assert failure.group.all().first(
    ).name == "devtools/client/debugger/new/test/mochitest"

    failure = FailureLine.objects.get(action='truncated')

    assert failure.job_guid == test_job.guid

    assert failure.repository == test_repository
def test_store_error_summary(activate_responses, test_repository, test_job):
    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
    assert Group.objects.count() == 1

    failure = FailureLine.objects.get(pk=1)
    assert failure.group.all().first(
    ).name == "devtools/client/debugger/new/test/mochitest"

    assert failure.job_guid == test_job.guid

    assert failure.repository == test_repository
def test_store_error_summary_default_group(activate_responses, test_repository,
                                           test_job):
    log_path = SampleData().get_log_path("plain-chunked_errorsummary.log")
    log_url = 'http://my-log.mozilla.org'

    with open(log_path) as log_handler:
        resp_body = json.load(log_handler)

    resp_body["group"] = "default"
    responses.add(responses.GET,
                  log_url,
                  body=json.dumps(resp_body),
                  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
    assert Group.objects.count() == 1

    failure = FailureLine.objects.get(pk=1)
    assert failure.group.all().first().name == "default"
def test_store_error_summary_astral(activate_responses, test_repository,
                                    test_job):
    log_path = SampleData().get_log_path(
        "plain-chunked_errorsummary_astral.log")
    log_url = 'http://my-log.mozilla.org'

    with open(log_path) as log_handler:
        responses.add(responses.GET,
                      log_url,
                      content_type="text/plain;charset=utf-8",
                      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

    assert Group.objects.count() == 1

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

    assert failure.job_guid == test_job.guid

    assert failure.repository == test_repository

    assert failure.test == u"toolkit/content/tests/widgets/test_videocontrols_video_direction.html <U+01F346>"
    assert failure.subtest == u"Test timed out. <U+010081>"
    assert failure.message == u"<U+0F0151>"
    assert failure.stack.endswith("<U+0F0151>")
    assert failure.stackwalk_stdout is None
    assert failure.stackwalk_stderr is None
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
def test_store_error_summary_truncated(activate_responses, test_repository,
                                       test_job, monkeypatch):
    log_path = SampleData().get_log_path("plain-chunked_errorsummary_10_lines.log")
    log_url = 'http://my-log.mozilla.org'

    monkeypatch.setattr(settings, 'FAILURE_LINES_CUTOFF', 5)

    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() == 5 + 1

    assert Group.objects.count() == 1

    failure = FailureLine.objects.get(pk=1)
    assert failure.group.all().first().name == "devtools/client/debugger/new/test/mochitest"

    failure = FailureLine.objects.get(action='truncated')

    assert failure.job_guid == test_job.guid

    assert failure.repository == test_repository
def test_store_error_summary(activate_responses, test_repository, jm,
                             eleven_jobs_stored):
    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)

    job = Job.objects.get(guid=jm.get_job(1)[0]['job_guid'])

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

    store_failure_lines(jm.project, job.guid, log_obj)

    assert FailureLine.objects.count() == 1

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

    assert failure.job_guid == job.guid

    assert failure.repository == test_repository
def test_get_group_results_with_colon(activate_responses, test_repository,
                                      test_job):
    log_path = SampleData().get_log_path(
        "xpcshell-errorsummary-with-colon.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)

    groups = get_group_results(test_job.push)
    task_groups = groups['V3SVuxO8TFy37En_6HcXLs']

    assert task_groups[
        'toolkit/components/extensions/test/xpcshell/xpcshell-e10s.ini:toolkit/components/extensions/test/xpcshell/xpcshell-content.ini']
    assert task_groups['toolkit/components/places/tests/unit/xpcshell.ini']
    assert task_groups[
        'toolkit/components/extensions/test/xpcshell/xpcshell-e10s.ini:toolkit/components/extensions/test/xpcshell/xpcshell-common-e10s.ini']
def test_store_error_summary_truncated(activate_responses, test_repository, jm,
                                       eleven_jobs_stored, monkeypatch):
    log_path = SampleData().get_log_path(
        "plain-chunked_errorsummary_10_lines.log")
    log_url = 'http://my-log.mozilla.org'

    monkeypatch.setattr(settings, 'FAILURE_LINES_CUTOFF', 5)

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

    job = Job.objects.get(guid=jm.get_job(1)[0]['job_guid'])

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

    store_failure_lines(jm.project, job.guid, log_obj)

    assert FailureLine.objects.count() == 5 + 1

    failure = FailureLine.objects.get(action='truncated')

    assert failure.job_guid == job.guid

    assert failure.repository == test_repository
def test_store_error_summary_group_status(activate_responses, test_repository,
                                          test_job):
    log_path = SampleData().get_log_path(
        "mochitest-browser-chrome_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() == 5

    ok_groups = Group.objects.filter(group_result__status=GroupStatus.OK)
    error_groups = Group.objects.filter(group_result__status=GroupStatus.ERROR)

    assert ok_groups.count() == 28
    assert error_groups.count() == 1
    assert log_obj.groups.count() == 29

    assert log_obj.groups.all().first().name == "dom/base/test/browser.ini"
    assert ok_groups.first().name == "dom/base/test/browser.ini"
    assert error_groups.first(
    ).name == "toolkit/components/pictureinpicture/tests/browser.ini"
def test_store_error_summary_elastic_search(activate_responses,
                                            test_repository, jm,
                                            eleven_jobs_stored, 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)

    job = Job.objects.get(guid=jm.get_job(1)[0]['job_guid'])

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

    store_failure_lines(jm.project, job.guid, log_obj)

    assert FailureLine.objects.count() == 1

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

    es_line = TestFailureLine.get(1, routing=failure.test)
    for prop in ["test", "subtest", "status", "expected"]:
        assert getattr(es_line, prop) == getattr(failure, prop)
    assert es_line.best_classification is None
    assert es_line.best_is_verified is False
def test_store_error_summary_astral(activate_responses, test_repository, test_job):
    log_path = SampleData().get_log_path("plain-chunked_errorsummary_astral.log")
    log_url = 'http://my-log.mozilla.org'

    with open(log_path) as log_handler:
        responses.add(responses.GET, log_url, content_type="text/plain;charset=utf-8",
                      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

    assert Group.objects.count() == 1

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

    assert failure.job_guid == test_job.guid

    assert failure.repository == test_repository

    assert failure.test == u"toolkit/content/tests/widgets/test_videocontrols_video_direction.html <U+01F346>"
    assert failure.subtest == u"Test timed out. <U+010081>"
    assert failure.message == u"<U+0F0151>"
    assert failure.stack.endswith("<U+0F0151>")
    assert failure.stackwalk_stdout is None
    assert failure.stackwalk_stderr is None
Example #13
0
def test_store_error_summary_404(activate_responses, test_repository, test_job):
    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=404)

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

    store_failure_lines(log_obj)

    log_obj.refresh_from_db()
    assert log_obj.status == JobLog.FAILED
Example #14
0
def test_get_group_results(activate_responses, test_repository, test_job):
    log_path = SampleData().get_log_path("mochitest-browser-chrome_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)

    groups = get_group_results(test_job.push)
    task_groups = groups['V3SVuxO8TFy37En_6HcXLs']

    assert task_groups['dom/base/test']
def test_store_error_summary_404(activate_responses, test_repository, test_job):
    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=404)

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

    store_failure_lines(log_obj)

    log_obj.refresh_from_db()
    assert log_obj.status == JobLog.FAILED
Example #16
0
def test_store_error_summary_500(activate_responses, test_repository, jm, eleven_jobs_stored):
    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=500)

    job = Job.objects.get(guid=jm.get_job(1)[0]['job_guid'])

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

    with pytest.raises(HTTPError):
        store_failure_lines(log_obj)

    log_obj.refresh_from_db()
    assert log_obj.status == JobLog.FAILED
def test_store_error_summary(activate_responses, test_repository, test_job):
    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)

    assert failure.job_guid == test_job.guid

    assert failure.repository == test_repository
def test_store_error_summary_default_group(activate_responses, test_repository, test_job):
    log_path = SampleData().get_log_path("plain-chunked_errorsummary.log")
    log_url = 'http://my-log.mozilla.org'

    with open(log_path) as log_handler:
        resp_body = json.load(log_handler)

    resp_body["group"] = "default"
    responses.add(responses.GET, log_url,
                  body=json.dumps(resp_body), 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
    assert Group.objects.count() == 1

    failure = FailureLine.objects.get(pk=1)
    assert failure.group.all().first().name == "default"
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
def test_store_error_summary_truncated(activate_responses, test_repository, jm,
                                       eleven_jobs_stored, monkeypatch):
    log_path = SampleData().get_log_path("plain-chunked_errorsummary_10_lines.log")
    log_url = 'http://my-log.mozilla.org'

    monkeypatch.setattr(settings, 'FAILURE_LINES_CUTOFF', 5)

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

    job = Job.objects.get(guid=jm.get_job(1)[0]['job_guid'])

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

    store_failure_lines(log_obj)

    assert FailureLine.objects.count() == 5 + 1

    failure = FailureLine.objects.get(action='truncated')

    assert failure.job_guid == job.guid

    assert failure.repository == test_repository
def test_store_error_summary_elastic_search(activate_responses, test_repository,
                                            jm, eleven_jobs_stored, 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)

    job = Job.objects.get(guid=jm.get_job(1)[0]['job_guid'])

    log_obj = JobLog.objects.create(job=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 = TestFailureLine.get(1, routing=failure.test)
    for prop in ["test", "subtest", "status", "expected"]:
        assert getattr(es_line, prop) == getattr(failure, prop)
    assert es_line.best_classification is None
    assert es_line.best_is_verified is False