autotest: Remove duplicate tko.models.job.index attribute
Both job.job_idx and job.index were being used to store the same
information (tko_jobs.job_idx column). We now consistently use
job.job_idx
BUG=chromium:833988
TEST=None
Change-Id: I2bdf1b41dc5c55db0f4f59386b8407952c1db087
Reviewed-on: https://chromium-review.googlesource.com/1020500
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: Prathmesh Prabhu <pprabhu@chromium.org>
Reviewed-by: Prathmesh Prabhu <pprabhu@chromium.org>
Reviewed-by: Xixuan Wu <xixuan@chromium.org>
diff --git a/tko/db.py b/tko/db.py
index 8fa4976..0dda40d 100644
--- a/tko/db.py
+++ b/tko/db.py
@@ -445,11 +445,12 @@
'afe_job_id': job.afe_job_id,
'afe_parent_job_id': job.afe_parent_job_id,
})
- if job.index is not None:
- self.update('tko_jobs', data, {'job_idx': job.index}, commit=commit)
+ if job.job_idx is not None:
+ self.update(
+ 'tko_jobs', data, {'job_idx': job.job_idx}, commit=commit)
else:
self.insert('tko_jobs', data, commit=commit)
- job.index = self.get_last_autonumber_value()
+ job.job_idx = self.get_last_autonumber_value()
def _get_common_job_data(self, tag, job):
@@ -487,7 +488,7 @@
parent_task_id = job.skylab_parent_task_id
data = {
'reference_type': reference_type,
- 'tko_job_idx': job.index,
+ 'tko_job_idx': job.job_idx,
'task_id': task_id,
'parent_task_id': parent_task_id,
}
@@ -511,7 +512,7 @@
@param commit: If commit the transaction .
"""
for key, value in job.keyval_dict.iteritems():
- where = {'job_id': job.index, 'key': key}
+ where = {'job_id': job.job_idx, 'key': key}
data = dict(where, value=value)
exists = self.select('id', 'tko_job_keyvals', where=where)
@@ -529,7 +530,7 @@
@param commit: If commit the transaction .
"""
kver = self.insert_kernel(test.kernel, commit=commit)
- data = {'job_idx':job.index, 'test':test.testname,
+ data = {'job_idx':job.job_idx, 'test':test.testname,
'subdir':test.subdir, 'kernel_idx':kver,
'status':self.status_idx[test.status],
'reason':test.reason, 'machine_idx':job.machine_idx,
@@ -631,15 +632,15 @@
@param job: tko.models.job object.
"""
- if job.index is None:
+ if job.job_idx is None:
return None
rows = self.select(
- 'id', 'tko_task_references', {'tko_job_idx': job.index})
+ 'id', 'tko_task_references', {'tko_job_idx': job.job_idx})
if not rows:
return None
if len(rows) > 1:
raise MySQLTooManyRows('Got %d tko_task_references for tko_job %d'
- % (len(rows), job.index))
+ % (len(rows), job.job_idx))
return rows[0][0]
diff --git a/tko/models.py b/tko/models.py
index 0e9febc..9bf91ae 100644
--- a/tko/models.py
+++ b/tko/models.py
@@ -28,7 +28,7 @@
self.build_version = None
self.suite = None
self.board = None
- self.index = None
+ self.job_idx = None
# id of the corresponding tko_task_references entry.
# This table is used to refer to skylab task / afe job corresponding to
# this tko_job.
diff --git a/tko/parse.py b/tko/parse.py
index 9b61dc6..50ed896 100755
--- a/tko/parse.py
+++ b/tko/parse.py
@@ -411,13 +411,13 @@
# Verify the job data is written to the database.
if job.tests:
- tests_in_db = db.find_tests(job.index)
+ tests_in_db = db.find_tests(job.job_idx)
tests_in_db_count = len(tests_in_db) if tests_in_db else 0
if tests_in_db_count != len(job.tests):
tko_utils.dprint(
'Failed to find enough tests for job_idx: %d. The '
'job should have %d tests, only found %d tests.' %
- (job.index, len(job.tests), tests_in_db_count))
+ (job.job_idx, len(job.tests), tests_in_db_count))
metrics.Counter(
'chromeos/autotest/result/db_save_failure',
description='The number of times parse failed to '
@@ -435,7 +435,7 @@
if orig_afe_job_id:
orig_job_idx = tko_models.Job.objects.get(
afe_job_id=orig_afe_job_id).job_idx
- _invalidate_original_tests(orig_job_idx, job.index)
+ _invalidate_original_tests(orig_job_idx, job.job_idx)
except Exception as e:
tko_utils.dprint("Hit exception while uploading to tko db:\n%s" %
traceback.format_exc())