[autotest] Convert more DB queries to be case insensitive
See https://chromium-review.googlesource.com/c/386306/ for an example of
where changing our django queries to be case insensitive brings down the
query execution time a lot.
This CL changes some more of these queries to be faster.
BUG=chromium:708679
TEST=Locally test that each of the DB query goes from being a BINARY
match to a text match
Change-Id: I27bffb7ab2206725eed08db74d3f0d99a8b374fe
Reviewed-on: https://chromium-review.googlesource.com/470286
Commit-Ready: Prathmesh Prabhu <pprabhu@chromium.org>
Tested-by: Prathmesh Prabhu <pprabhu@chromium.org>
Reviewed-by: Prathmesh Prabhu <pprabhu@chromium.org>
diff --git a/contrib/always_failing_tests.py b/contrib/always_failing_tests.py
index 9720842..32981a1 100755
--- a/contrib/always_failing_tests.py
+++ b/contrib/always_failing_tests.py
@@ -47,10 +47,10 @@
tests = tko_models.Test.objects.select_related('job'
).filter(started_time__gte=cutoff_date
- ).exclude(test__contains='/'
- ).exclude(test__contains='_JOB'
+ ).exclude(test__icontains='/'
+ ).exclude(test__icontains='_JOB'
).exclude(test='provision'
- ).exclude(test__contains='try_new_image')
+ ).exclude(test__icontains='try_new_image')
tests = list(tests)
# These prints are vague profiling work. We're handling a lot of data, so I
# had to dump some decent work into making sure things chug along at a
diff --git a/frontend/afe/rpc_interface.py b/frontend/afe/rpc_interface.py
index 2ea3d65..aa575b6 100644
--- a/frontend/afe/rpc_interface.py
+++ b/frontend/afe/rpc_interface.py
@@ -576,14 +576,15 @@
"""Gets the counts of all passed and failed tests from the matching jobs.
@param job_name_prefix: Name prefix of the jobs to get the summary
- from, e.g., 'butterfly-release/R40-6457.21.0/bvt-cq/'.
+ from, e.g., 'butterfly-release/r40-6457.21.0/bvt-cq/'. Prefix
+ matching is case insensitive.
@param label_name: Label that must be set in the jobs, e.g.,
'cros-version:butterfly-release/R40-6457.21.0'.
@returns A summary of the counts of all the passed and failed tests.
"""
job_ids = list(models.Job.objects.filter(
- name__startswith=job_name_prefix,
+ name__istartswith=job_name_prefix,
dependency_labels__name=label_name).values_list(
'pk', flat=True))
summary = {'passed': 0, 'failed': 0}
diff --git a/site_utils/abort_suite.py b/site_utils/abort_suite.py
index 63c4de9..c461463 100755
--- a/site_utils/abort_suite.py
+++ b/site_utils/abort_suite.py
@@ -60,11 +60,12 @@
by autotest scheduler.
@param afe: An instance of frontend.AFE to make RPCs with.
- @param substring: A string used to search for the jobs.
+ @param substring: A string used to search for the jobs (case insensitive
+ matching).
"""
hqe_info = afe.run('abort_host_queue_entries',
- job__name__contains=substring, job__owner=getpass.getuser(),
+ job__name__icontains=substring, job__owner=getpass.getuser(),
job__parent_job__isnull=True)
if hqe_info:
logging.info('The following suites have been aborted:\n%s', hqe_info)