[autotest] Save parent job id, build, board and suite info to tko_jobs.
parent job id is passed in through autoserv commandline. autoserv saves the
value to keyval file in results folder. The parser job then reads the parent
job id from keyval file.
build, board and suite info are parsed from job name. The label column in
tko_jobs is essentially the job name. However, that column has a size limit of
100 characters, thus the name could be truncated. This CL parse the actual job
name to get the build, board and suite info and save to tko_jobs table.
BUG=chromium:509770,chromium:509901
TEST=local test
CQ-DEPEND=CL:285026
Change-Id: I06b073b052a9d07ffd36308b1682a7bc12699898
Reviewed-on: https://chromium-review.googlesource.com/286265
Tested-by: Dan Shi <[email protected]>
Reviewed-by: Mungyung Ryu <[email protected]>
Commit-Queue: Dan Shi <[email protected]>
diff --git a/server/server_job.py b/server/server_job.py
index eb81db0..45ff890 100644
--- a/server/server_job.py
+++ b/server/server_job.py
@@ -153,7 +153,8 @@
ssh_options=host_factory.DEFAULT_SSH_OPTIONS,
test_retry=0, group_name='',
tag='', disable_sysinfo=False,
- control_filename=SERVER_CONTROL_FILENAME):
+ control_filename=SERVER_CONTROL_FILENAME,
+ parent_job_id=None):
"""
Create a server side job object.
@@ -181,6 +182,8 @@
tests for a modest shortening of test time. [optional]
@param control_filename: The filename where the server control file
should be written in the results directory.
+ @param parent_job_id: Job ID of the parent job. Default to None if the
+ job does not have a parent job.
"""
super(base_server_job, self).__init__(resultdir=resultdir,
test_retry=test_retry)
@@ -229,6 +232,10 @@
'drone' : platform.node(),
'status_version' : str(self._STATUS_VERSION),
'job_started' : str(int(time.time()))}
+ # Save parent job id to keyvals, so parser can retrieve the info and
+ # write to tko_jobs record.
+ if parent_job_id:
+ job_data['parent_job_id'] = parent_job_id
if group_name:
job_data['host_group_name'] = group_name
@@ -261,6 +268,8 @@
# unexpected reboot.
self.failed_with_device_error = False
+ self.parent_job_id = parent_job_id
+
@classmethod
def _find_base_directories(cls):
@@ -337,7 +346,8 @@
# it does not
job_idx = self.results_db.find_job(self._parse_job)
if job_idx is None:
- self.results_db.insert_job(self._parse_job, self.job_model)
+ self.results_db.insert_job(self._parse_job, self.job_model,
+ self.parent_job_id)
else:
machine_idx = self.results_db.lookup_machine(self.job_model.machine)
self.job_model.index = job_idx