[autotest] use parent_id to reduce number of db queries in suite.wait
This CL reduces the number of queries required when waiting for a
suite's job results, by replacing (when suite_job_id is known) a loop
over afe.get_jobs(id=job.id, finished=True) for all remaining jobs in a
suite with a single call to
afe.get_jobs(parent_job_id=parent_job_id, finished=True)
I have not yet done a performance benchmark with this change, nor
examined whether the underlying SQL queries could be significantly
optimized with an intelligently chosen new database index.
CQ-DEPEND=CL:I4b407fd0cc1a769ad0d4829bdffed87213e2da04
BUG=chromium:276471
TEST=Used run_suite locally, verified that suite waiting on its child
jobs and that results were reported correctly. Added a unit test, which
passes.
Change-Id: I47dbc5f1a3348bdd5297ffbd2e26b82dc9d705f6
Reviewed-on: https://gerrit.chromium.org/gerrit/66443
Reviewed-by: Aviv Keshet <akeshet@chromium.org>
Tested-by: Aviv Keshet <akeshet@chromium.org>
Commit-Queue: Aviv Keshet <akeshet@chromium.org>
diff --git a/server/cros/dynamic_suite/fakes.py b/server/cros/dynamic_suite/fakes.py
index cd18645..3a5d8d9 100644
--- a/server/cros/dynamic_suite/fakes.py
+++ b/server/cros/dynamic_suite/fakes.py
@@ -26,12 +26,13 @@
class FakeJob(object):
"""Faked out RPC-client-side Job object."""
- def __init__(self, id=0, statuses=[], hostnames=[]):
+ def __init__(self, id=0, statuses=[], hostnames=[], parent_job_id=None):
self.id = id
self.hostnames = hostnames if hostnames else ['host%d' % id]
self.owner = 'tester'
self.name = 'Fake Job %d' % self.id
self.statuses = statuses
+ self.parent_job_id = parent_job_id
class FakeHost(object):