From e70ccb91b110706fd9e3b4ce5c47e1f7c164d335 Mon Sep 17 00:00:00 2001 From: Don Garrett Date: Wed, 19 Jan 2011 13:41:23 -0800 Subject: [PATCH] Use different proxy ports, and log port conflicts. Hopefully works around build problems, and will give better diagnostics if not. Change-Id: I2f7a5d9b2e0c63a8189ad212125c7a5c0178c3c4 BUG=10567 TEST= Review URL: http://codereview.chromium.org/6331007 --- bin/cros_au_test_harness.py | 11 +++++------ lib/cros_test_proxy.py | 11 ++++++++--- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/bin/cros_au_test_harness.py b/bin/cros_au_test_harness.py index 7cf42935ec..f274b14e1a 100755 --- a/bin/cros_au_test_harness.py +++ b/bin/cros_au_test_harness.py @@ -139,15 +139,14 @@ class AUTest(object): Warning(err.stdout) self.fail('We managed to update when failure was expected') - def AttemptUpdateWithFilter(self, filter): + def AttemptUpdateWithFilter(self, filter, proxy_port=8081): """Update through a proxy, with a specified filter, and expect success.""" self.PrepareBase(self.target_image_path) # The devserver runs at port 8080 by default. We assume that here, and - # start our proxy at 8081. We then tell our update tools to have the - # client connect to 8081 instead of 8080. - proxy_port = 8081 + # start our proxy at a different. 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, @@ -350,7 +349,7 @@ class AUTest(object): self.data_size += len(data) return data - self.AttemptUpdateWithFilter(InterruptionFilter()) + self.AttemptUpdateWithFilter(InterruptionFilter(), proxy_port=8082) def testDelayedUpdate(self): """Tests what happens if some data is delayed during update delivery""" @@ -380,7 +379,7 @@ class AUTest(object): self.data_size += len(data) return data - self.AttemptUpdateWithFilter(DelayedFilter()) + self.AttemptUpdateWithFilter(DelayedFilter(), proxy_port=8083) def SimpleTest(self): """A simple update that updates once from a base image to a target. diff --git a/lib/cros_test_proxy.py b/lib/cros_test_proxy.py index 21709829c3..464dcb539b 100755 --- a/lib/cros_test_proxy.py +++ b/lib/cros_test_proxy.py @@ -2,6 +2,7 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. +import os import select import socket import SocketServer @@ -100,9 +101,13 @@ class CrosTestProxy(SocketServer.ThreadingMixIn, SocketServer.TCPServer): self.port_out = port_out self.filter = filter - SocketServer.TCPServer.__init__(self, - ('', port_in), - self._Handler) + try: + SocketServer.TCPServer.__init__(self, + ('', port_in), + self._Handler) + except socket.error: + os.system('sudo netstat -l --tcp -n -p') + raise def serve_forever_in_thread(self): """Helper method to start the server in a new background thread."""