[autotest] Support run_suite with suite package and SSP for Brillo.

This change allows one to run run_suite command without using
--run_prod_code for Brillo build.
create_suite_job will use test_suites and control_files packages from
the Brillo build to create suite job and its test jobs.

Server-side packaging is also supported for newer builds that have
autotest_server_package artifact build.

BUG=chromium:584705
TEST=run in local instance, unittest, verify in moblab

Change-Id: Ia96ca4de919b178302580c23f911bb6445016285
Reviewed-on: https://chromium-review.googlesource.com/332431
Commit-Ready: Dan Shi <dshi@google.com>
Tested-by: Dan Shi <dshi@google.com>
Reviewed-by: Dan Shi <dshi@google.com>
diff --git a/frontend/afe/site_rpc_interface.py b/frontend/afe/site_rpc_interface.py
index ac7e9a4..e709ba7 100644
--- a/frontend/afe/site_rpc_interface.py
+++ b/frontend/afe/site_rpc_interface.py
@@ -107,13 +107,13 @@
     # Ensure components of |build| necessary for installing images are staged
     # on the dev server. However set synchronous to False to allow other
     # components to be downloaded in the background.
-    ds = dev_server.ImageServer.resolve(build)
+    ds = dev_server.resolve(build)
     timings[constants.DOWNLOAD_STARTED_TIME] = formatted_now()
     timer = autotest_stats.Timer('control_files.stage.%s' % (
             ds.get_server_name(ds.url()).replace('.', '_')))
     try:
         with timer:
-            ds.stage_artifacts(build, ['test_suites'])
+            ds.stage_artifacts(image=build, artifacts=['test_suites'])
     except dev_server.DevServerException as e:
         raise error.StageControlFileFailure(
                 "Failed to stage %s: %s" % (build, e))
@@ -209,7 +209,7 @@
 
     suite_name = canonicalize_suite_name(name)
     if run_prod_code:
-        ds = dev_server.ImageServer.resolve(build)
+        ds = dev_server.resolve(build)
         keyvals = {}
         getter = control_file_getter.FileSystemGetter(
                 [_CONFIG.get_config_value('SCHEDULER',
@@ -641,7 +641,7 @@
         raise ValueError('Could not resolve build %s: %s' % (build, e))
 
     try:
-        ds.stage_artifacts(build, ['test_suites'])
+        ds.stage_artifacts(image=build, artifacts=['test_suites'])
     except dev_server.DevServerException as e:
         raise error.StageControlFileFailure(
                 'Failed to stage %s: %s' % (build, e))
diff --git a/frontend/afe/site_rpc_interface_unittest.py b/frontend/afe/site_rpc_interface_unittest.py
index 0606dbe..db4a300 100755
--- a/frontend/afe/site_rpc_interface_unittest.py
+++ b/frontend/afe/site_rpc_interface_unittest.py
@@ -64,7 +64,7 @@
 
     def _setupDevserver(self):
         self.mox.StubOutClassWithMocks(dev_server, 'ImageServer')
-        dev_server.ImageServer.resolve(self._BUILD).AndReturn(self.dev_server)
+        dev_server.resolve(self._BUILD).AndReturn(self.dev_server)
 
 
     def _mockDevServerGetter(self, get_control_file=True):
@@ -114,7 +114,7 @@
         self.dev_server.url().AndReturn('mox_url')
         self.dev_server.get_server_name(mox.IgnoreArg()).AndReturn('mox_url')
         self.dev_server.stage_artifacts(
-            self._BUILD, ['test_suites']).AndRaise(
+                image=self._BUILD, artifacts=['test_suites']).AndRaise(
                 dev_server.DevServerException())
         self.mox.ReplayAll()
         self.assertRaises(error.StageControlFileFailure,
@@ -131,8 +131,8 @@
 
         self.dev_server.url().AndReturn('mox_url')
         self.dev_server.get_server_name(mox.IgnoreArg()).AndReturn('mox_url')
-        self.dev_server.stage_artifacts(self._BUILD,
-                                        ['test_suites']).AndReturn(True)
+        self.dev_server.stage_artifacts(
+                image=self._BUILD, artifacts=['test_suites']).AndReturn(True)
 
         self.dev_server.url().AndReturn('mox_url')
         self.dev_server.get_server_name(mox.IgnoreArg()).AndReturn('mox_url')
@@ -153,8 +153,8 @@
 
         self.dev_server.url().AndReturn('mox_url')
         self.dev_server.get_server_name(mox.IgnoreArg()).AndReturn('mox_url')
-        self.dev_server.stage_artifacts(self._BUILD,
-                                        ['test_suites']).AndReturn(True)
+        self.dev_server.stage_artifacts(
+                image=self._BUILD, artifacts=['test_suites']).AndReturn(True)
 
         self.dev_server.url().AndReturn('mox_url')
         self.dev_server.get_server_name(mox.IgnoreArg()).AndReturn('mox_url')
@@ -201,8 +201,8 @@
 
         self.dev_server.url().AndReturn('mox_url')
         self.dev_server.get_server_name(mox.IgnoreArg()).AndReturn('mox_url')
-        self.dev_server.stage_artifacts(self._BUILD,
-                                        ['test_suites']).AndReturn(True)
+        self.dev_server.stage_artifacts(
+                image=self._BUILD, artifacts=['test_suites']).AndReturn(True)
 
         self.dev_server.url().AndReturn('mox_url')
         self.dev_server.get_server_name(mox.IgnoreArg()).AndReturn('mox_url')
@@ -225,8 +225,8 @@
 
         self.dev_server.url().AndReturn('mox_url')
         self.dev_server.get_server_name(mox.IgnoreArg()).AndReturn('mox_url')
-        self.dev_server.stage_artifacts(self._BUILD,
-                                        ['test_suites']).AndReturn(True)
+        self.dev_server.stage_artifacts(
+                image=self._BUILD, artifacts=['test_suites']).AndReturn(True)
 
         self.dev_server.url().AndReturn('mox_url')
         self.dev_server.get_server_name(mox.IgnoreArg()).AndReturn('mox_url')
@@ -251,8 +251,8 @@
 
         self.dev_server.url().AndReturn('mox_url')
         self.dev_server.get_server_name(mox.IgnoreArg()).AndReturn('mox_url')
-        self.dev_server.stage_artifacts(self._BUILD,
-                                        ['test_suites']).AndReturn(True)
+        self.dev_server.stage_artifacts(
+                image=self._BUILD, artifacts=['test_suites']).AndReturn(True)
 
         self.dev_server.url().AndReturn('mox_url')
         self.dev_server.get_server_name(mox.IgnoreArg()).AndReturn('mox_url')
@@ -276,8 +276,8 @@
 
         self.dev_server.url().AndReturn('mox_url')
         self.dev_server.get_server_name(mox.IgnoreArg()).AndReturn('mox_url')
-        self.dev_server.stage_artifacts(self._BUILD,
-                                        ['test_suites']).AndReturn(True)
+        self.dev_server.stage_artifacts(
+                image=self._BUILD, artifacts=['test_suites']).AndReturn(True)
 
         self.dev_server.url().AndReturn('mox_url')
         self.dev_server.get_server_name(mox.IgnoreArg()).AndReturn('mox_url')
@@ -304,8 +304,8 @@
 
         self.dev_server.url().AndReturn('mox_url')
         self.dev_server.get_server_name(mox.IgnoreArg()).AndReturn('mox_url')
-        self.dev_server.stage_artifacts(self._BUILD,
-                                        ['test_suites']).AndReturn(True)
+        self.dev_server.stage_artifacts(
+                image=self._BUILD, artifacts=['test_suites']).AndReturn(True)
         self.dev_server.url().AndReturn('mox_url')
         job_id = 5
         self._mockRpcUtils(job_id)