Switch to using the new dev_server_wrapper interface

The wrapper no longer uses a fixed port number. This CL makes sure
that the tests either passes the correct port number to connect to the
devserver, or start the devserver with a designated port (8080).

BUG=chromium:391994
CQ-DEPEND=CL:207952
TEST=dev_install test, VM AU test

Change-Id: I01e6797f990a99145ae9b0db26103c2c1df88cf7
Reviewed-on: https://chromium-review.googlesource.com/207963
Tested-by: Yu-Ju Hong <yjhong@chromium.org>
Reviewed-by: Chris Sosa <sosa@chromium.org>
Commit-Queue: Yu-Ju Hong <yjhong@chromium.org>
diff --git a/au_test_harness/au_test.py b/au_test_harness/au_test.py
index 4182f7d..abe83fc 100644
--- a/au_test_harness/au_test.py
+++ b/au_test_harness/au_test.py
@@ -11,6 +11,7 @@
 import urllib
 
 from chromite.lib import cros_build_lib
+from chromite.lib import dev_server_wrapper
 from crostestutils.au_test_harness import cros_test_proxy
 from crostestutils.au_test_harness import real_au_worker
 from crostestutils.au_test_harness import update_exception
@@ -60,13 +61,15 @@
     """Update through a proxy, with a specified filter, and expect success."""
     target_image_path = self.worker.PrepareBase(self.target_image_path)
 
-    # The devserver runs at port 8080 by default. We assume that here, and
-    # start our proxy at a different one. We then tell our update tools to
-    # have the client connect to our proxy_port instead of 8080.
-    proxy = cros_test_proxy.CrosTestProxy(port_in=proxy_port,
-                                          address_out='127.0.0.1',
-                                          port_out=8080,
-                                          filter=update_filter)
+    # We assume that devserver starts at the default port (8080), and start
+    # our proxy at a different one. We then tell our update tools to
+    # have the client connect to our proxy_port instead of the 8080.
+    proxy = cros_test_proxy.CrosTestProxy(
+        port_in=proxy_port,
+        address_out='127.0.0.1',
+        port_out=dev_server_wrapper.DEFAULT_PORT,
+        filter=update_filter
+    )
     proxy.serve_forever_in_thread()
     try:
       self.worker.PerformUpdate(target_image_path, target_image_path,
diff --git a/au_test_harness/cros_au_test_harness.py b/au_test_harness/cros_au_test_harness.py
index 54bee7f..9c2f349 100755
--- a/au_test_harness/cros_au_test_harness.py
+++ b/au_test_harness/cros_au_test_harness.py
@@ -116,8 +116,8 @@
 
   Args:
     parser: Parser used to parse options.
-    options:  Parsed options.
-    leftover_args:  Args left after parsing.
+    options: Parsed options.
+    leftover_args: Args left after parsing.
   """
   if leftover_args: parser.error('Found unsupported flags ' + leftover_args)
   if not options.type in ['real', 'vm']:
@@ -215,6 +215,7 @@
       # Only start a devserver if we'll need it.
       if update_cache:
         my_server = dev_server_wrapper.DevServerWrapper(
+            port=dev_server_wrapper.DEFAULT_PORT,
             log_dir=options.test_results_root)
         my_server.Start()
 
diff --git a/devmode-test/devinstall_test.py b/devmode-test/devinstall_test.py
index 64832ef..f9b1e44 100755
--- a/devmode-test/devinstall_test.py
+++ b/devmode-test/devinstall_test.py
@@ -116,7 +116,7 @@
       logging.info('Starting the devserver.')
       self.devserver = dev_server_wrapper.DevServerWrapper()
       self.devserver.Start()
-      self.binhost = dev_server_wrapper.DevServerWrapper.GetDevServerURL(
+      self.binhost = self.devserver.GetURL(
           sub_dir='static/pkgroot/%s/packages' % self.board)
 
     logging.info('Using binhost %s', self.binhost)
@@ -145,7 +145,7 @@
     try:
       self.device.RunCommand(
           ['gmerge', 'gmerge', '--accept_stable', '--usepkg',
-           '--devserver_url', self.devserver.GetDevServerURL(),
+           '--devserver_url', self.devserver.GetURL(),
            '--board', self.board])
     except (cros_build_lib.RunCommandError,
             remote_access.SSHConnectionError) as e: