Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add websocket conformance tests using autobahn

  • Loading branch information...
commit 34b59827c9264ff43661ee3e3aa8f137405cd5c5 1 parent 877aa9d
@bdarnell bdarnell authored
View
3  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)
View
1  maint/test/websocket/.gitignore
@@ -0,0 +1 @@
+reports/
View
32 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()
View
26 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
View
20 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()
View
12 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
Please sign in to comment.
Something went wrong with that request. Please try again.