Bug 1521157 - Check for fixed_by_commit classification (#4822)

This commit is contained in:
Cameron Dawson 2019-03-25 13:16:12 -07:00 коммит произвёл GitHub
Родитель ffb236f399
Коммит 03bea62b50
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
4 изменённых файлов: 16 добавлений и 18 удалений

Просмотреть файл

@ -1,9 +1,7 @@
def set_classifications(failures, intermittent_history, fixed_by_commit_history):
for failure in failures:
if set_intermittent(failure, intermittent_history):
continue
if set_previous_regression(failure, fixed_by_commit_history):
continue
set_intermittent(failure, intermittent_history)
set_previous_regression(failure, fixed_by_commit_history)
def set_previous_regression(failure, fixed_by_commit_history):

Просмотреть файл

@ -4,8 +4,7 @@ from collections import defaultdict
from django.forms.models import model_to_dict
from treeherder.model.models import (FailureLine,
OptionCollection,
Repository)
OptionCollection)
from treeherder.push_health.classification import (get_grouped,
set_classifications)
from treeherder.push_health.filter import filter_failure
@ -14,6 +13,7 @@ from treeherder.push_health.utils import (clean_config,
clean_test)
intermittent_history_days = 14
fixed_by_commit_history_days = 30
ignored_log_lines = [
'Return code: 1',
'exit status 1',
@ -22,14 +22,13 @@ ignored_log_lines = [
]
def get_intermittent_history(prior_day, days, option_map):
def get_history(failure_classification_id, prior_day, days, option_map, repository_ids):
start_date = datetime.datetime.now() - datetime.timedelta(days=days)
repos = Repository.objects.filter(name__in=['mozilla-inbound', 'autoland', 'mozilla-central'])
failure_lines = FailureLine.objects.filter(
job_log__job__result='testfailed',
job_log__job__tier=1,
job_log__job__failure_classification_id=4,
job_log__job__push__repository__in=repos,
job_log__job__failure_classification_id=failure_classification_id,
job_log__job__push__repository_id__in=repository_ids,
job_log__job__push__time__gt=start_date,
job_log__job__push__time__lt=prior_day,
).exclude(
@ -104,15 +103,15 @@ def get_push_failures(push, option_map):
return sorted(tests.values(), key=lambda k: k['testName'])
def get_push_health_test_failures(push):
def get_push_health_test_failures(push, repository_ids):
# query for jobs for the last two weeks excluding today
# find tests that have failed in the last 14 days
# this is very cache-able for reuse on other pushes.
option_map = OptionCollection.objects.get_option_collection_map()
start_date = push.time.date() - datetime.timedelta(days=1)
intermittent_history = get_intermittent_history(start_date, intermittent_history_days, option_map)
prior_day = push.time.date() - datetime.timedelta(days=2)
intermittent_history = get_history(4, prior_day, intermittent_history_days, option_map, repository_ids)
fixed_by_commit_history = get_history(2, prior_day, fixed_by_commit_history_days, option_map, repository_ids)
push_failures = get_push_failures(push, option_map)
# push_failures = []
filtered_push_failures = [
failure for failure in push_failures if filter_failure(failure)
]
@ -120,6 +119,6 @@ def get_push_health_test_failures(push):
set_classifications(
filtered_push_failures,
intermittent_history,
{}, # TODO: Use fbc history
fixed_by_commit_history,
)
return get_grouped(filtered_push_failures)

Просмотреть файл

@ -11,7 +11,8 @@ from treeherder.model.models import (Push,
Repository)
from treeherder.push_health.push_health import get_push_health_test_failures
from treeherder.webapp.api.serializers import PushSerializer
from treeherder.webapp.api.utils import (to_datetime,
from treeherder.webapp.api.utils import (REPO_GROUPS,
to_datetime,
to_timestamp)
@ -205,7 +206,7 @@ class PushViewSet(viewsets.ViewSet):
except Push.DoesNotExist:
return Response("No push with revision: {0}".format(revision),
status=HTTP_404_NOT_FOUND)
push_health_test_failures = get_push_health_test_failures(push)
push_health_test_failures = get_push_health_test_failures(push, REPO_GROUPS['trunk'])
return Response({
'revision': revision,

Просмотреть файл

@ -238,7 +238,7 @@ class PushActionMenu extends React.PureComponent {
target="_blank"
rel="noopener noreferrer"
>
Prototype: Push Health)
Prototype: Push Health
</a>
</li>
</ul>