[autotest] Create a suite for testing push to prod

Add suite push_to_prod for cbf run.
Add a tool, site_utils/test_push.py, used to test if code is ready to push.

BUG=chromium:263928,285453
TEST=unit test
Test with a trybot build: trybot-stumpy-release/R35-5526.0.0-b373
AU part is verified with latest stumpy canary build.

Change-Id: Ia221f0a1aa0f1687daab5d8a20307435baa6bdfc
Reviewed-on: https://chromium-review.googlesource.com/66460
Reviewed-by: Dan Shi <dshi@chromium.org>
Commit-Queue: Dan Shi <dshi@chromium.org>
Tested-by: Dan Shi <dshi@chromium.org>
diff --git a/server/site_utils.py b/server/site_utils.py
index 55b1cc6..7a6ad28 100644
--- a/server/site_utils.py
+++ b/server/site_utils.py
@@ -16,6 +16,7 @@
 from autotest_lib.client.common_lib import error
 from autotest_lib.client.common_lib import global_config
 from autotest_lib.server.cros.dynamic_suite import constants
+from autotest_lib.server.cros.dynamic_suite import job_status
 
 
 _SHERIFF_JS = global_config.global_config.get_config_value(
@@ -272,3 +273,25 @@
                          host.hostname, labels)
 
     raise error.TestError('Could not lock a device with labels %s' % labels)
+
+
+def get_test_views_from_tko(suite_job_id, tko):
+    """Get test name and result for given suite job ID.
+
+    @param suite_job_id: ID of suite job.
+    @param tko: an instance of TKO as defined in server/frontend.py.
+    @return: A dictionary of test status keyed by test name, e.g.,
+             {'dummy_Fail.Error': 'ERROR', 'dummy_Fail.NAError': 'TEST_NA'}
+    @raise: Exception when there is no test view found.
+
+    """
+    views = tko.run('get_detailed_test_views', afe_job_id=suite_job_id)
+    relevant_views = filter(job_status.view_is_relevant, views)
+    if not relevant_views:
+        raise Exception('Failed to retrieve job results.')
+
+    test_views = {}
+    for view in relevant_views:
+        test_views[view['test_name']] = view['status']
+
+    return test_views