Skip to content

Commit

Permalink
Update CNS to run on chromeperf34 and CNS tests to run on windows per…
Browse files Browse the repository at this point in the history
…f_av bot.

(Added OWNERS file to chrome/test/functional/media)

BUG=139262
NOTRY=true
TEST=none

Review URL: https://chromiumcodereview.appspot.com/10825051

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@149695 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
shadi@chromium.org committed Aug 2, 2012
1 parent d0ae861 commit 0500f7c
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 21 deletions.
3 changes: 3 additions & 0 deletions chrome/test/functional/media/OWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dalecurtis@chromium.org
scherkus@chromium.org
shadi@chromium.org
39 changes: 30 additions & 9 deletions chrome/test/functional/media/cns_test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
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:
# ('TEST_NAME', [BANDWIDTH_Kbps, LATENCY_ms, PACKET_LOSS_%])
Expand Down Expand Up @@ -42,7 +44,10 @@
_CNS_PORT = 9000

# Base CNS URL, only requires & separated parameter names appended.
CNS_BASE_URL = 'http://127.0.0.1:%d/ServeConstrained?' % _CNS_PORT
if WINDOWS:
CNS_BASE_URL = 'http://chromeperf34.chrome:%d/ServeConstrained?' % _CNS_PORT
else:
CNS_BASE_URL = 'http://127.0.0.1:%d/ServeConstrained?' % _CNS_PORT

# Used for server sanity check.
_TEST_VIDEO = 'roller.webm'
Expand All @@ -69,7 +74,22 @@ def __init__(self, *args, **kwargs):
pyauto.PyUITest.__init__(self, *args, **kwargs)

def setUp(self):
"""Starts the Constrained Network Server (CNS)."""
"""Ensures the Constrained Network Server (CNS) server is up and running."""
if WINDOWS:
self._SetUpWin()
else:
self._SetUpLinux()

def _SetUpWin(self):
"""Ensures the test can connect to the external CNS server."""
if self.WaitUntil(self._CanAccessServer, retry_sleep=3, timeout=30,
debug=False):
pyauto.PyUITest.setUp(self)
else:
self.fail('Failed to connect to CNS.')

def _SetUpLinux(self):
"""Starts the CNS server locally."""
cmd = [sys.executable, os.path.join(pyauto_paths.GetSourceDir(), _CNS_PATH),
'--port', str(self._port),
'--interface', self._interface,
Expand Down Expand Up @@ -103,13 +123,14 @@ def _CanAccessServer(self):
def tearDown(self):
"""Stops the Constrained Network Server (CNS)."""
pyauto.PyUITest.tearDown(self)
logging.debug('Stopping CNS server.')
# Do not use process.kill(), it will not clean up cns.
self.Kill(self._cns_process.pid)
# Need to wait since the process logger has a lock on the process stderr.
self._cns_process.wait()
self.assertFalse(self._cns_process.returncode is None)
logging.debug('CNS server stopped.')
if not WINDOWS:
logging.debug('Stopping CNS server.')
# Do not use process.kill(), it will not clean up cns.
self.Kill(self._cns_process.pid)
# Need to wait since the process logger has a lock on the process stderr.
self._cns_process.wait()
self.assertFalse(self._cns_process.returncode is None)
logging.debug('CNS server stopped.')


class ProcessLogger(threading.Thread):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import logging
import os
import posixpath
import Queue

import pyauto_media
Expand Down Expand Up @@ -54,14 +55,14 @@

# Media file names used for measuring epp and tpp.
_TEST_MEDIA_EPP = ['roller.webm']
_TEST_MEDIA_EPP.extend(os.path.join('crowd', name) for name in
_TEST_MEDIA_EPP.extend(posixpath.join('crowd', name) for name in
['crowd360.ogv', 'crowd.wav', 'crowd.ogg'])

# Media file names used for measuring tpp without epp.
_TEST_MEDIA_NO_EPP = [os.path.join('dartmoor', name) for name in
_TEST_MEDIA_NO_EPP = [posixpath.join('dartmoor', name) for name in
['dartmoor2.ogg', 'dartmoor2.m4a', 'dartmoor2.mp3',
'dartmoor2.wav']]
_TEST_MEDIA_NO_EPP.extend(os.path.join('crowd', name) for name in
_TEST_MEDIA_NO_EPP.extend(posixpath.join('crowd', name) for name in
['crowd1080.webm', 'crowd1080.ogv', 'crowd1080.mp4',
'crowd360.webm', 'crowd360.mp4'])

Expand Down
5 changes: 3 additions & 2 deletions chrome/test/functional/media/media_seek_perf.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import logging
import os
import posixpath

import pyauto_media
import pyauto_utils
Expand All @@ -26,10 +27,10 @@

# The media files used for testing.
# Path under CNS root folder (pyauto_private/media).
_TEST_VIDEOS = [os.path.join('dartmoor', name) for name in
_TEST_VIDEOS = [posixpath.join('dartmoor', name) for name in
['dartmoor2.ogg', 'dartmoor2.m4a', 'dartmoor2.mp3',
'dartmoor2.wav']]
_TEST_VIDEOS.extend(os.path.join('crowd', name) for name in
_TEST_VIDEOS.extend(posixpath.join('crowd', name) for name in
['crowd1080.webm', 'crowd1080.ogv', 'crowd1080.mp4',
'crowd360.webm', 'crowd360.ogv', 'crowd360.mp4'])

Expand Down
15 changes: 8 additions & 7 deletions media/tools/constrained_network_server/cns.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"""

import logging
from logging import handlers
import mimetypes
import optparse
import os
Expand Down Expand Up @@ -321,22 +322,22 @@ def ParseArgs():
# Convert the path to an absolute to remove any . or ..
options.www_root = os.path.abspath(options.www_root)

# Required so that cherrypy logs do not get propagated to root logger causing
# the logs to be printed twice.
cherrypy.log.error_log.propagate = False
cherrypy.log.access_log.propagate = False

_SetLogger(options.verbose)

return options


def _SetLogger(verbose):
# Logging is used for traffic_control debug statements.
file_handler = handlers.RotatingFileHandler('cns.log', 'a', 10000000, 10)
file_handler.setFormatter(logging.Formatter('[%(threadName)s] %(message)s'))

log_level = _DEFAULT_LOG_LEVEL
if verbose:
log_level = logging.DEBUG
logging.basicConfig(level=log_level, format='[%(threadName)s] %(message)s')
file_handler.setLevel(log_level)

cherrypy.log.error_log.addHandler(file_handler)
cherrypy.log.access_log.addHandler(file_handler)


def Main():
Expand Down

0 comments on commit 0500f7c

Please sign in to comment.