diff options
author | jadmanski <jadmanski@592f7852-d20e-0410-864c-8624ca9c26a4> | 2008-07-15 20:04:42 +0000 |
---|---|---|
committer | jadmanski <jadmanski@592f7852-d20e-0410-864c-8624ca9c26a4> | 2008-07-15 20:04:42 +0000 |
commit | 8a0ee3f99b8873711d5a68fe9ca4a398ed0d5fde (patch) | |
tree | 362924b21b19efe2533e219a0bb7e86c45e61cec /tko/db.py | |
parent | 9174546c6c318b204a525a01bbd47b1fcf042b32 (diff) |
Modify the parser and tko db code to flag test models as being for
insertion or update, add a new "RUNNING" status to tko, and then add
code to the v1 parser to generate a "RUNNING" record when the test
starts and then a final update record when the test ends.
Risk: High
Visibility: When a test is in progress mostly-empty RUNNING results
should show up in tko, to be replaced by the final record when the
test finishes.
Signed-off-by: John Admanski <jadmanski@google.com>
git-svn-id: svn://test.kernel.org/autotest/trunk@1836 592f7852-d20e-0410-864c-8624ca9c26a4
Diffstat (limited to 'tko/db.py')
-rw-r--r-- | tko/db.py | 31 |
1 files changed, 20 insertions, 11 deletions
@@ -164,10 +164,14 @@ class db_sql(object): values = [] if where and isinstance(where, types.DictionaryType): - # key/value pairs (which should be equal) - keys = [field + '=%s' for field in where.keys()] - values = [where[field] for field in where.keys()] - + # key/value pairs (which should be equal, or None for null) + keys, values = [], [] + for field, value in where.iteritems(): + if value is None: + keys.append(field + ' is null') + else: + keys.append(field + '=%s') + values.append(value) cmd.append(' where ' + ' and '.join(keys)) elif where and isinstance(where, types.StringTypes): # the exact string @@ -282,14 +286,14 @@ class db_sql(object): fields = data.keys() data_refs = [field + '=%s' for field in fields] data_values = [data[field] for field in fields] - cmd += ' set ' + ' and '.join(data_refs) + cmd += ' set ' + ', '.join(data_refs) where_keys = [field + '=%s' for field in where.keys()] where_values = [where[field] for field in where.keys()] cmd += ' where ' + ' and '.join(where_keys) values = data_values + where_values - print '%s %s' % (cmd, values) + self.dprint('%s %s' % (cmd, values)) self._exec_sql_with_commit(cmd, values, commit) @@ -299,6 +303,7 @@ class db_sql(object): for test_idx in self.find_tests(job_idx): where = {'test_idx' : test_idx} self.delete('iteration_result', where) + self.delete('iteration_attributes', where) self.delete('test_attributes', where) where = {'job_idx' : job_idx} self.delete('tests', where) @@ -331,9 +336,13 @@ class db_sql(object): 'reason':test.reason, 'machine_idx':job.machine_idx, 'started_time': test.started_time, 'finished_time':test.finished_time} - self.insert('tests', data, commit=commit) - test_idx = self.get_last_autonumber_value() - data = { 'test_idx':test_idx } + if hasattr(test, "test_idx"): + test_idx = test.test_idx + self.update('tests', data, {'test_idx': test_idx}, commit=commit) + else: + self.insert('tests', data, commit=commit) + test_idx = test.test_idx = self.get_last_autonumber_value() + data = {'test_idx': test_idx} for i in test.iterations: data['iteration'] = i.index @@ -441,8 +450,8 @@ class db_sql(object): commit=commit) - def find_test(self, job_idx, subdir): - where = { 'job_idx':job_idx , 'subdir':subdir } + def find_test(self, job_idx, testname, subdir): + where = {'job_idx': job_idx , 'test': testname, 'subdir': subdir} rows = self.select('test_idx', 'tests', where) if rows: return rows[0][0] |