diff --git a/maint/test/README b/maint/test/README new file mode 100644 index 00000000..e4e6cd97 --- /dev/null +++ b/maint/test/README @@ -0,0 +1,3 @@ +This directory contains additional tests that are not included in the main +suite (because e.g. they have extra dependencies, run slowly, or produce +more output than a simple pass/fail) diff --git a/maint/test/websocket/.gitignore b/maint/test/websocket/.gitignore new file mode 100644 index 00000000..a9a1bd38 --- /dev/null +++ b/maint/test/websocket/.gitignore @@ -0,0 +1 @@ +reports/ diff --git a/maint/test/websocket/client.py b/maint/test/websocket/client.py new file mode 100644 index 00000000..f549b218 --- /dev/null +++ b/maint/test/websocket/client.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python +import sys +from tornado.options import options, define, parse_command_line +from twisted.python import log +from twisted.internet import reactor +from autobahn.fuzzing import FuzzingClientFactory + +define('servers', type=str, multiple=True, + default=['Tornado=ws://localhost:9000']) + +define('cases', type=str, multiple=True, + default=["*"]) +define('exclude', type=str, multiple=True, + default=[]) + +if __name__ == '__main__': + parse_command_line() + log.startLogging(sys.stdout) + servers = [] + for server in options.servers: + name, _, url = server.partition('=') + servers.append({"agent": name, "url": url, "options": {"version": 17}}) + spec = { + "options": {"failByDrop": False}, + "enable-ssl": False, + "servers": servers, + "cases": options.cases, + "exclude-cases": options.exclude, + "exclude-agent-cases": {}, + } + fuzzer = FuzzingClientFactory(spec) + reactor.run() diff --git a/maint/test/websocket/run.sh b/maint/test/websocket/run.sh new file mode 100755 index 00000000..2ca103e4 --- /dev/null +++ b/maint/test/websocket/run.sh @@ -0,0 +1,26 @@ +#!/bin/sh +# +# Runs the autobahn websocket conformance test against tornado in both +# python2 and python3. Output goes in ./reports/servers/index.html. +# +# The --cases and --exclude arguments can be used to run only part of +# the suite. --exclude="9.*" is useful to skip the relatively slow +# performance tests. + +set -e + +# build/update the virtualenvs +tox + +.tox/py27/bin/python server.py --port=9001 & +PY27_SERVER_PID=$! + +.tox/py32/bin/python server.py --port=9002 & +PY32_SERVER_PID=$! + +sleep 1 + +.tox/py27/bin/python ./client.py --servers=Tornado/py27=ws://localhost:9001,Tornado/py32=ws://localhost:9002 "$@" + +kill $PY27_SERVER_PID +kill $PY32_SERVER_PID diff --git a/maint/test/websocket/server.py b/maint/test/websocket/server.py new file mode 100644 index 00000000..276343ae --- /dev/null +++ b/maint/test/websocket/server.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python + +from tornado.ioloop import IOLoop +from tornado.options import define, options, parse_command_line +from tornado.websocket import WebSocketHandler +from tornado.web import Application + +define('port', default=9000) + +class EchoHandler(WebSocketHandler): + def on_message(self, message): + self.write_message(message) + +if __name__ == '__main__': + parse_command_line() + app = Application([ + ('/', EchoHandler), + ]) + app.listen(options.port, address='localhost') + IOLoop.instance().start() diff --git a/maint/test/websocket/tox.ini b/maint/test/websocket/tox.ini new file mode 100644 index 00000000..b85d9728 --- /dev/null +++ b/maint/test/websocket/tox.ini @@ -0,0 +1,12 @@ +# We don't actually use tox to run this test, but it's the easiest way +# to install autobahn and deal with 2to3 for the python3 version. +# See run.sh for the real test runner. +[tox] +envlist = py27, py32 +setupdir=../../.. + +[testenv] +commands = python -c pass + +[testenv:py27] +deps = autobahn