Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5981)

Unified Diff: chrome/test/functional/media/cns_test_base.py

Issue 10831249: Clean up ports allocated by perf windows tests on CNS external server. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Make external server default for Lin and Win Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/functional/media/cns_test_base.py
diff --git a/chrome/test/functional/media/cns_test_base.py b/chrome/test/functional/media/cns_test_base.py
index 89bbbfbf3069f500f3b54462d4b5624df50ac7e6..6d481e2b0bfe5817b44ab94984ff745ba38eaa59 100644
--- a/chrome/test/functional/media/cns_test_base.py
+++ b/chrome/test/functional/media/cns_test_base.py
@@ -15,7 +15,6 @@ import urllib2
import pyauto
import pyauto_paths
-WINDOWS = 'win32' in sys.platform
# List of commonly used network constraints settings.
# Each setting is a tuppe of the form:
@@ -43,9 +42,15 @@ _CNS_PATH = os.path.join(
# Port to start the CNS on.
_CNS_PORT = 9000
+# A flag to determine whether to launch a local CNS instance or to connect
+# to the external CNS server. Default to True since all current bots use an
+# external instance. Set to false when running a local test.
+USE_EXTERNAL_SERVER = False
DaleCurtis 2012/08/16 00:15:58 Can we make this a command line option? Also the c
shadi 2012/08/16 19:49:27 After offline discussion, we decided to use an env
+
# Base CNS URL, only requires & separated parameter names appended.
-if WINDOWS:
+if USE_EXTERNAL_SERVER:
CNS_BASE_URL = 'http://chromeperf34:%d/ServeConstrained?' % _CNS_PORT
+ CNS_CLEANUP_URL = 'http://chromeperf34:%d/Cleanup' % _CNS_PORT
else:
CNS_BASE_URL = 'http://127.0.0.1:%d/ServeConstrained?' % _CNS_PORT
@@ -75,12 +80,12 @@ class CNSTestBase(pyauto.PyUITest):
def setUp(self):
"""Ensures the Constrained Network Server (CNS) server is up and running."""
- if WINDOWS:
- self._SetUpWin()
+ if USE_EXTERNAL_SERVER:
+ self._SetUpExternal()
else:
- self._SetUpLinux()
+ self._SetUpLocal()
- def _SetUpWin(self):
+ def _SetUpExternal(self):
"""Ensures the test can connect to the external CNS server."""
if self.WaitUntil(self._CanAccessServer, retry_sleep=3, timeout=30,
debug=False):
@@ -88,7 +93,7 @@ class CNSTestBase(pyauto.PyUITest):
else:
self.fail('Failed to connect to CNS.')
- def _SetUpLinux(self):
+ def _SetUpLocal(self):
"""Starts the CNS server locally."""
cmd = [sys.executable, os.path.join(pyauto_paths.GetSourceDir(), _CNS_PATH),
'--port', str(self._port),
@@ -122,8 +127,10 @@ class CNSTestBase(pyauto.PyUITest):
def tearDown(self):
"""Stops the Constrained Network Server (CNS)."""
- pyauto.PyUITest.tearDown(self)
- if not WINDOWS:
+ if USE_EXTERNAL_SERVER:
+ # Call CNS Cleanup to remove all ports created by this client.
+ self.NavigateToURL(CNS_CLEANUP_URL)
+ else:
logging.debug('Stopping CNS server.')
# Do not use process.kill(), it will not clean up cns.
self.Kill(self._cns_process.pid)
@@ -131,6 +138,7 @@ class CNSTestBase(pyauto.PyUITest):
self._cns_process.wait()
self.assertFalse(self._cns_process.returncode is None)
logging.debug('CNS server stopped.')
+ pyauto.PyUITest.tearDown(self)
class ProcessLogger(threading.Thread):
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698