kopia lustrzana https://github.com/micropython/micropython-lib
uasyncio: Add automated script for validation testing with Boom.
rodzic
1bb98d55cc
commit
171717dc8a
|
@ -0,0 +1,28 @@
|
||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# This in one-shot scripts to test "heavy load" uasyncio HTTP server using
|
||||||
|
# Boom tool https://github.com/tarekziade/boom .
|
||||||
|
#
|
||||||
|
# Note that this script doesn't test performance, but rather test functional
|
||||||
|
# correctness of uasyncio server implementation, while serving large amounts
|
||||||
|
# of data (guaranteedly more than a socket buffer). Thus, this script should
|
||||||
|
# not be used for benchmarking.
|
||||||
|
#
|
||||||
|
|
||||||
|
if [ ! -d .venv-boom ]; then
|
||||||
|
virtualenv .venv-boom
|
||||||
|
. .venv-boom/bin/activate
|
||||||
|
# PyPI currently has 0.8 which is too old
|
||||||
|
#pip install boom
|
||||||
|
pip install git+https://github.com/tarekziade/boom
|
||||||
|
else
|
||||||
|
. .venv-boom/bin/activate
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
micropython -X heapsize=300000000 -O test_http_server_heavy.py &
|
||||||
|
sleep 1
|
||||||
|
|
||||||
|
PYTHONPATH=. boom -n1000 -c30 http://localhost:8081 --post-hook=boom_uasyncio.validate
|
||||||
|
|
||||||
|
kill %1
|
|
@ -0,0 +1,39 @@
|
||||||
|
import uasyncio as asyncio
|
||||||
|
import signal
|
||||||
|
import errno
|
||||||
|
|
||||||
|
|
||||||
|
cnt = 0
|
||||||
|
|
||||||
|
@asyncio.coroutine
|
||||||
|
def serve(reader, writer):
|
||||||
|
global cnt
|
||||||
|
#s = "Hello.\r\n"
|
||||||
|
s = "Hello. %07d\r\n" % cnt
|
||||||
|
cnt += 1
|
||||||
|
yield from reader.read()
|
||||||
|
yield from writer.awrite("HTTP/1.0 200 OK\r\n\r\n")
|
||||||
|
try:
|
||||||
|
yield from writer.awrite(s)
|
||||||
|
yield from writer.awrite(s * 100)
|
||||||
|
yield from writer.awrite(s * 400000)
|
||||||
|
yield from writer.awrite("=== END ===")
|
||||||
|
yield from writer.close()
|
||||||
|
except OSError as e:
|
||||||
|
if e.args[0] == errno.EPIPE:
|
||||||
|
print("EPIPE")
|
||||||
|
elif e.args[0] == errno.ECONNRESET:
|
||||||
|
print("ECONNRESET")
|
||||||
|
else:
|
||||||
|
raise
|
||||||
|
|
||||||
|
|
||||||
|
import logging
|
||||||
|
logging.basicConfig(level=logging.INFO)
|
||||||
|
#logging.basicConfig(level=logging.DEBUG)
|
||||||
|
signal.signal(signal.SIGPIPE, signal.SIG_IGN)
|
||||||
|
loop = asyncio.get_event_loop()
|
||||||
|
mem_info()
|
||||||
|
loop.call_soon(asyncio.start_server(serve, "0.0.0.0", 8081, backlog=100))
|
||||||
|
loop.run_forever()
|
||||||
|
loop.close()
|
Ładowanie…
Reference in New Issue