Autotest TKO parser inserts perf measurements into the tko_iteration_perf_value database table.

This change is part of a series of changes in which we're modifying how
autotest handles/stores perf test measurements, to better align with chrome
team's perf dashboard.

Previously, the autotest TKO parser was taught how to parse the
perf_measurements output files produced by chromeOS perf tests.  In the
current CL, this parsed perf information is now inserted into the
autotest results database (table tko_iteration_perf_value).  Situations in
which autotest may need to delete information from this table are also
handled (mirrored off of how autotest handles perf keyvals).

Note that tko_iteration_perf_value is not yet exposed through the TKO RPC
interface.  This is because the scripts that upload to the perf dashboard
currently extract perf values from the database directly.  In the future,
those scripts may change to use the RPC interface, at which point the
RPC interface will need to be enhanced to expose data from
tko_iteration_perf_value.

BUG=chromium:258230
TEST=Verified using a local AFE and device that platform_GesturesRegressionTest
     runs successfully with these changes, and the outputted perf measurements
     are properly stored into the local results database.  Also verified that
     job_serializer_unittest.py passes with these changes (assuming that
     tko/tko.proto is compiled, which the unittests require as a pre-requisite).

Change-Id: I00799f2b96c9b45f5acdd5949c8f3dea0cc0821e
Reviewed-on: https://gerrit.chromium.org/gerrit/63232
Commit-Queue: Dennis Jeffrey <dennisjeffrey@chromium.org>
Reviewed-by: Dennis Jeffrey <dennisjeffrey@chromium.org>
Tested-by: Dennis Jeffrey <dennisjeffrey@chromium.org>
diff --git a/tko/db.py b/tko/db.py
index 6a2eb13..140a0f8 100644
--- a/tko/db.py
+++ b/tko/db.py
@@ -317,6 +317,7 @@
         for test_idx in self.find_tests(job_idx):
             where = {'test_idx' : test_idx}
             self.delete('tko_iteration_result', where)
+            self.delete('tko_iteration_perf_value', where)
             self.delete('tko_iteration_attributes', where)
             self.delete('tko_test_attributes', where)
             self.delete('tko_test_labels_tests', {'test_id': test_idx})
@@ -380,6 +381,7 @@
                         {'test_idx': test_idx}, commit=commit)
             where = {'test_idx': test_idx}
             self.delete('tko_iteration_result', where)
+            self.delete('tko_iteration_perf_value', where)
             self.delete('tko_iteration_attributes', where)
             where['user_created'] = 0
             self.delete('tko_test_attributes', where)
@@ -401,6 +403,17 @@
                 self.insert('tko_iteration_result', data,
                             commit=commit)
 
+        data = {'test_idx': test_idx}
+        for i in test.perf_values:
+            data['iteration'] = i.index
+            for perf_dict in i.perf_measurements:
+                data['description'] = perf_dict['description']
+                data['value'] = perf_dict['value']
+                data['stddev'] = perf_dict['stddev']
+                data['units'] = perf_dict['units']
+                data['higher_is_better'] = perf_dict['higher_is_better']
+                self.insert('tko_iteration_perf_value', data, commit=commit)
+
         for key, value in test.attributes.iteritems():
             data = {'test_idx': test_idx, 'attribute': key,
                     'value': value}