Add websocket conformance tests using autobahn
This commit is contained in:
parent
877aa9d861
commit
34b59827c9
|
@ -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)
|
|
@ -0,0 +1 @@
|
|||
reports/
|
|
@ -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()
|
|
@ -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
|
|
@ -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()
|
|
@ -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
|
Loading…
Reference in New Issue