[autotest] filter suite and individual jobs on AFE.
Modified rpc_interface get_jobs and get_num_jobs to take in three extra
filters, suite, sub, and standalone. Add a rpc_util to add a where clause
to SQL, and add a unittest accordingly.
On GWT, add a group of radiobuttons as filters.
BUG=chromium:390345
TEST=ran afe, ran Job List, use filters
DEPLOY=afe,apache
Change-Id: Ibce875b47bef7e89bcc94972e23261290f0ac0e0
Reviewed-on: https://chromium-review.googlesource.com/206415
Tested-by: Jiaxi Luo <jiaxiluo@chromium.org>
Reviewed-by: Simran Basi <sbasi@chromium.org>
Commit-Queue: Jiaxi Luo <jiaxiluo@chromium.org>
diff --git a/frontend/afe/rpc_interface.py b/frontend/afe/rpc_interface.py
index 879a148..b2bb62f 100644
--- a/frontend/afe/rpc_interface.py
+++ b/frontend/afe/rpc_interface.py
@@ -669,19 +669,30 @@
models.Host.query_objects(filter_data))
-def get_jobs(not_yet_run=False, running=False, finished=False, **filter_data):
+def get_jobs(not_yet_run=False, running=False, finished=False,
+ suite=False, sub=False, standalone=False, **filter_data):
"""\
- Extra filter args for get_jobs:
+ Extra status filter args for get_jobs:
-not_yet_run: Include only jobs that have not yet started running.
-running: Include only jobs that have start running but for which not
all hosts have completed.
-finished: Include only jobs for which all hosts have completed (or
aborted).
At most one of these three fields should be specified.
+
+ Extra type filter args for get_jobs:
+ -suite: Include only jobs with child jobs.
+ -sub: Include only jobs with a parent job.
+ -standalone: Inlcude only jobs with no child or parent jobs.
+ At most one of these three fields should be specified.
"""
- filter_data['extra_args'] = rpc_utils.extra_job_filters(not_yet_run,
- running,
- finished)
+ extra_args = rpc_utils.extra_job_status_filters(not_yet_run,
+ running,
+ finished)
+ filter_data['extra_args'] = rpc_utils.extra_job_type_filters(extra_args,
+ suite,
+ sub,
+ standalone)
job_dicts = []
jobs = list(models.Job.query_objects(filter_data))
models.Job.objects.populate_relationships(jobs, models.Label,
@@ -700,13 +711,18 @@
def get_num_jobs(not_yet_run=False, running=False, finished=False,
+ suite=False, sub=False, standalone=False,
**filter_data):
"""\
See get_jobs() for documentation of extra filter parameters.
"""
- filter_data['extra_args'] = rpc_utils.extra_job_filters(not_yet_run,
- running,
- finished)
+ extra_args = rpc_utils.extra_job_status_filters(not_yet_run,
+ running,
+ finished)
+ filter_data['extra_args'] = rpc_utils.extra_job_type_filters(extra_args,
+ suite,
+ sub,
+ standalone)
return models.Job.query_count(filter_data)