wip
This commit is contained in:
parent
7331ed2b7b
commit
07f8045fbc
|
@ -6,7 +6,7 @@ default:
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
-rm -rf ./reports
|
-rm -rf ./reports
|
||||||
-rm -rf ./downloads
|
#-rm -rf ./downloads
|
||||||
-rm -rf ./venv*
|
-rm -rf ./venv*
|
||||||
-rm -rf ./wstest
|
-rm -rf ./wstest
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ build_wstest:
|
||||||
build_pypy2:
|
build_pypy2:
|
||||||
mkdir -p ./pypy2
|
mkdir -p ./pypy2
|
||||||
tar xvf ./downloads/pypy2-v5.7.0-linux64.tar.bz2 --strip-components=1 -C ./pypy2
|
tar xvf ./downloads/pypy2-v5.7.0-linux64.tar.bz2 --strip-components=1 -C ./pypy2
|
||||||
cd ./pypy2/bin && ln -s pypy python && cd ../..
|
#cd ./pypy2/bin && ln -s pypy python && cd ../..
|
||||||
./pypy2/bin/python ./downloads/get-pip.py
|
./pypy2/bin/python ./downloads/get-pip.py
|
||||||
./pypy2/bin/pip install virtualenv
|
./pypy2/bin/pip install virtualenv
|
||||||
./pypy2/bin/python -V
|
./pypy2/bin/python -V
|
||||||
|
@ -41,7 +41,7 @@ build_pypy2:
|
||||||
build_pypy3:
|
build_pypy3:
|
||||||
mkdir -p ./pypy3
|
mkdir -p ./pypy3
|
||||||
tar xvf ./downloads/pypy3-v5.7.0-linux64.tar.bz2 --strip-components=1 -C ./pypy3
|
tar xvf ./downloads/pypy3-v5.7.0-linux64.tar.bz2 --strip-components=1 -C ./pypy3
|
||||||
cd ./pypy3/bin && ln -s pypy3 python && cd ../..
|
#cd ./pypy3/bin && ln -s pypy3 python && cd ../..
|
||||||
./pypy3/bin/python ./downloads/get-pip.py
|
./pypy3/bin/python ./downloads/get-pip.py
|
||||||
./pypy3/bin/pip install virtualenv
|
./pypy3/bin/pip install virtualenv
|
||||||
./pypy3/bin/python -V
|
./pypy3/bin/python -V
|
||||||
|
@ -72,6 +72,13 @@ build: build_wstest \
|
||||||
build_cpy3
|
build_cpy3
|
||||||
|
|
||||||
|
|
||||||
|
versions:
|
||||||
|
./cpy2/bin/python -V
|
||||||
|
./cpy3/bin/python -V
|
||||||
|
./pypy2/bin/python -V
|
||||||
|
./pypy3/bin/python -V
|
||||||
|
|
||||||
|
|
||||||
setup_pypy2_tx:
|
setup_pypy2_tx:
|
||||||
./pypy2/bin/virtualenv ./venv_pypy2_tx
|
./pypy2/bin/virtualenv ./venv_pypy2_tx
|
||||||
./venv_pypy2_tx/bin/pip install -e ..[twisted]
|
./venv_pypy2_tx/bin/pip install -e ..[twisted]
|
||||||
|
@ -154,3 +161,7 @@ test_aio_client: \
|
||||||
test_pypy3_aio_client \
|
test_pypy3_aio_client \
|
||||||
test_cpy2_aio_client \
|
test_cpy2_aio_client \
|
||||||
test_cpy3_aio_client
|
test_cpy3_aio_client
|
||||||
|
|
||||||
|
test_client: \
|
||||||
|
test_tx_client \
|
||||||
|
test_aio_client
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
```console
|
||||||
|
make downloads
|
||||||
|
```
|
||||||
|
|
||||||
|
```console
|
||||||
|
make build
|
||||||
|
```
|
||||||
|
|
||||||
|
```console
|
||||||
|
oberstet@office-corei7:~/scm/crossbario/autobahn-python/wstest$ make versions
|
||||||
|
./cpy2/bin/python -V
|
||||||
|
Python 2.7.13
|
||||||
|
./cpy3/bin/python -V
|
||||||
|
Python 3.6.0
|
||||||
|
./pypy2/bin/python -V
|
||||||
|
Python 2.7.13 (fa3249d55d15, Mar 19 2017, 20:21:48)
|
||||||
|
[PyPy 5.7.0 with GCC 6.2.0 20160901]
|
||||||
|
./pypy3/bin/python -V
|
||||||
|
Python 3.5.3 (b16a4363e930, Mar 20 2017, 16:13:46)
|
||||||
|
[PyPy 5.7.0-beta0 with GCC 6.2.0 20160901]
|
||||||
|
```
|
||||||
|
|
||||||
|
```console
|
||||||
|
make setup
|
||||||
|
```
|
||||||
|
|
|
@ -24,6 +24,8 @@
|
||||||
#
|
#
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
|
||||||
import txaio
|
import txaio
|
||||||
txaio.use_asyncio()
|
txaio.use_asyncio()
|
||||||
|
|
||||||
|
@ -34,6 +36,8 @@ except ImportError:
|
||||||
|
|
||||||
import autobahn
|
import autobahn
|
||||||
|
|
||||||
|
from autobahn.websocket.util import parse_url
|
||||||
|
|
||||||
from autobahn.asyncio.websocket import WebSocketClientProtocol, \
|
from autobahn.asyncio.websocket import WebSocketClientProtocol, \
|
||||||
WebSocketClientFactory
|
WebSocketClientFactory
|
||||||
|
|
||||||
|
@ -60,14 +64,17 @@ class TesteeClientProtocol(WebSocketClientProtocol):
|
||||||
else:
|
else:
|
||||||
self.sendMessage(msg, binary)
|
self.sendMessage(msg, binary)
|
||||||
|
|
||||||
|
def onClose(self, wasClean, code, reason):
|
||||||
|
txaio.resolve(self.factory._done, None)
|
||||||
|
|
||||||
|
|
||||||
class TesteeClientFactory(WebSocketClientFactory):
|
class TesteeClientFactory(WebSocketClientFactory):
|
||||||
|
|
||||||
protocol = TesteeClientProtocol
|
protocol = TesteeClientProtocol
|
||||||
|
|
||||||
def __init__(self, url):
|
def __init__(self, url, agent):
|
||||||
self.agent = autobahn.asyncio.__ident__
|
self.agent = agent
|
||||||
WebSocketClientFactory.__init__(self, url, useragent=self.agent)
|
WebSocketClientFactory.__init__(self, url, useragent=agent)
|
||||||
|
|
||||||
self.setProtocolOptions(failByDrop=False) # spec conformance
|
self.setProtocolOptions(failByDrop=False) # spec conformance
|
||||||
|
|
||||||
|
@ -81,39 +88,42 @@ class TesteeClientFactory(WebSocketClientFactory):
|
||||||
|
|
||||||
self.setProtocolOptions(perMessageCompressionAccept=accept)
|
self.setProtocolOptions(perMessageCompressionAccept=accept)
|
||||||
|
|
||||||
# setup client testee stuff
|
|
||||||
self.endCaseId = None
|
|
||||||
self.currentCaseId = 0
|
|
||||||
self.updateReports = True
|
|
||||||
self.resource = "/getCaseCount"
|
|
||||||
|
|
||||||
# FIXME: port to asyncio
|
|
||||||
def clientConnectionLost(self, connector, reason):
|
|
||||||
self.currentCaseId += 1
|
|
||||||
if self.currentCaseId <= self.endCaseId:
|
|
||||||
self.resource = "/runCase?case={}&agent={}".format(self.currentCaseId, self.agent)
|
|
||||||
connector.connect()
|
|
||||||
elif self.updateReports:
|
|
||||||
self.resource = "/updateReports?agent={}".format(self.agent)
|
|
||||||
self.updateReports = False
|
|
||||||
connector.connect()
|
|
||||||
else:
|
|
||||||
reactor.stop()
|
|
||||||
|
|
||||||
# FIXME: port to asyncio
|
|
||||||
def clientConnectionFailed(self, connector, reason):
|
|
||||||
self.log.info("Connection to {url} failed: {error_message}", url=self.url, error_message=reason.getErrorMessage())
|
|
||||||
reactor.stop()
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
||||||
txaio.start_logging(level='info')
|
parser = argparse.ArgumentParser(description='Autobahn Testee Client (Twisted)')
|
||||||
|
parser.add_argument('--url', dest='url', type=str, default=u'ws://127.0.0.1:9001', help='The WebSocket fuzzing server URL.')
|
||||||
|
parser.add_argument('--loglevel', dest='loglevel', type=str, default=u'info', help='Log level, eg "info" or "debug".')
|
||||||
|
|
||||||
factory = TesteeClientFactory(u"ws://127.0.0.1:9001")
|
options = parser.parse_args()
|
||||||
|
|
||||||
|
txaio.start_logging(level=options.loglevel)
|
||||||
|
|
||||||
|
factory = TesteeClientFactory(options.url, autobahn.asyncio.__ident__)
|
||||||
|
|
||||||
|
_, host, port, _, _, _ = parse_url(options.url)
|
||||||
|
|
||||||
loop = asyncio.get_event_loop()
|
loop = asyncio.get_event_loop()
|
||||||
coro = loop.create_connection(factory, '127.0.0.1', 9001)
|
|
||||||
loop.run_until_complete(coro)
|
factory.resource = u'/getCaseCount'
|
||||||
loop.run_forever()
|
factory.endCaseId = None
|
||||||
|
factory.currentCaseId = 0
|
||||||
|
factory.updateReports = True
|
||||||
|
|
||||||
|
while True:
|
||||||
|
|
||||||
|
factory._done = txaio.create_future()
|
||||||
|
coro = loop.create_connection(factory, host, port)
|
||||||
|
loop.run_until_complete(coro)
|
||||||
|
loop.run_until_complete(factory._done)
|
||||||
|
|
||||||
|
factory.currentCaseId += 1
|
||||||
|
if factory.currentCaseId <= factory.endCaseId:
|
||||||
|
factory.resource = u"/runCase?case={}&agent={}".format(factory.currentCaseId, factory.agent)
|
||||||
|
elif factory.updateReports:
|
||||||
|
factory.resource = u"/updateReports?agent={}".format(factory.agent)
|
||||||
|
factory.updateReports = False
|
||||||
|
else:
|
||||||
|
break
|
||||||
|
|
||||||
loop.close()
|
loop.close()
|
||||||
|
|
|
@ -24,6 +24,8 @@
|
||||||
#
|
#
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
|
||||||
import txaio
|
import txaio
|
||||||
txaio.use_twisted()
|
txaio.use_twisted()
|
||||||
|
|
||||||
|
@ -103,9 +105,15 @@ class TesteeClientFactory(WebSocketClientFactory):
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
||||||
txaio.start_logging(level='info')
|
parser = argparse.ArgumentParser(description='Autobahn Testee Client (Twisted)')
|
||||||
|
parser.add_argument('--url', dest='url', type=str, default=u'ws://127.0.0.1:9001', help='The WebSocket fuzzing server URL.')
|
||||||
|
parser.add_argument('--loglevel', dest='loglevel', type=str, default=u'info', help='Log level, eg "info" or "debug".')
|
||||||
|
|
||||||
factory = TesteeClientFactory(u"ws://127.0.0.1:9001")
|
options = parser.parse_args()
|
||||||
|
|
||||||
|
txaio.start_logging(level=options.loglevel)
|
||||||
|
|
||||||
|
factory = TesteeClientFactory(options.url)
|
||||||
|
|
||||||
connectWS(factory)
|
connectWS(factory)
|
||||||
reactor.run()
|
reactor.run()
|
||||||
|
|
Loading…
Reference in New Issue