Autotest: Find long passing experimental tests.
This adds a script to that finds any autotest test that has been marked
as experimental but has been passing for at least 30 days. An email is sent
about these tests so that the appropriate action can be taken.
BUG=chromium:212671
TEST=Unittests. Manual testing by commenting out where emails are sent (so
as not to spam people). Also by commenting out the database updating call when
checking against the real database.
Change-Id: Ieae34adc2ef49458e50a5dd7d6f9851743e80a10
Reviewed-on: https://gerrit.chromium.org/gerrit/63479
Reviewed-by: Dennis Jeffrey <dennisjeffrey@chromium.org>
Tested-by: Keyar Hood <keyar@chromium.org>
Commit-Queue: Keyar Hood <keyar@chromium.org>
diff --git a/frontend/health/utils.py b/frontend/health/utils.py
index 8b3b58e..11186c9 100644
--- a/frontend/health/utils.py
+++ b/frontend/health/utils.py
@@ -10,7 +10,13 @@
from autotest_lib.frontend.tko import models as tko_models
from django.db import models as django_models
+_TEST_ERROR_STATUS = 'ERROR'
+_TEST_ABORT_STATUS = 'ABORT'
+_TEST_FAIL_STATUS = 'FAIL'
+_TEST_WARN_STATUS = 'WARN'
_TEST_PASS_STATUS = 'GOOD'
+_TEST_ALERT_STATUS = 'ALERT'
+
def get_last_pass_times():
"""
@@ -25,3 +31,24 @@
last_pass=django_models.Max('started_time'))
return {result['test']: result['last_pass'] for result in results}
+
+def get_last_fail_times():
+ """
+ Get all the tests that have failed and the time they last failed.
+
+ @return the dict of test_name:last_finish_time pairs for tests that have
+ failed.
+
+ """
+
+ failure_clauses = (django_models.Q(status__word=_TEST_FAIL_STATUS) |
+ django_models.Q(status__word=_TEST_ERROR_STATUS) |
+ django_models.Q(status__word=_TEST_ABORT_STATUS) |
+ django_models.Q(status__word=_TEST_WARN_STATUS) |
+ django_models.Q(status__word=_TEST_ALERT_STATUS))
+
+ results = tko_models.Test.objects.values('test').filter(
+ failure_clauses).annotate(
+ last_pass=django_models.Max('started_time'))
+
+ return {result['test']: result['last_pass'] for result in results}