micropython-lib/uasyncio
Peter Hinch 65605e3de8 uasyncio: Add test showing I/O scheduling starvation.
If there is a coroutine to run immediately (with wait delay <= 0),
uasyncio.core never calls .wait() method, which is required to
process I/O events (and schedule coroutines waiting for them).

This test demonstrates the problem.
2017-08-20 16:36:15 +03:00
..
benchmark uasyncio: test-ab-medium.sh: Run ab on http://127.0.0.1 . 2017-06-06 21:37:55 +03:00
uasyncio uasyncio: Add awriteiter() method. 2017-06-10 16:10:27 +03:00
README.test uasyncio: Add instructions for testing/benchmarking. 2014-11-11 23:17:35 +02:00
example_http_client.py uasyncio: Rename examples as such. 2017-01-04 18:01:05 +03:00
example_http_server.py uasyncio: Rename examples as such. 2017-01-04 18:01:05 +03:00
metadata.txt uasyncio: Release 1.2.2. 2017-06-10 16:11:41 +03:00
setup.py uasyncio: Release 1.2.2. 2017-06-10 16:11:41 +03:00
test_echo.py uasyncio: Add echo test 2017-01-01 19:06:54 -08:00
test_io_starve.py uasyncio: Add test showing I/O scheduling starvation. 2017-08-20 16:36:15 +03:00
test_readexactly.py uasyncio: Implement StreamReader.readexactly(). 2017-01-28 01:04:21 +03:00
test_readline.py uasyncio: StreamReader.readline: Handle partial reads. 2017-01-27 01:09:19 +03:00

README.test

Testing and Validating
----------------------

To test uasyncio correctness and performance, HTTP server samples can be
used. The simplest test is with test_http_server.py and Apache Benchmark
(ab). In one window, run:

micropython -O test_http_server.py

(-O is needed to short-circuit debug logging calls.)

In another:

ab -n10000 -c10 http://localhost:8081/

ab tests that all responses have the same length, but doesn't check
content. test_http_server.py also serves very short, static reply.


For more heavy testing, test_http_server_heavy.py is provided. It serves
large response split among several async writes. It is also dynamic -
includes incrementing counter, so each response will be different. The
response size generates is more 4Mb, because under Linux, socket writes
can buffer up to 4Mb of content (this appear to be controlled by
/proc/sys/net/ipv4/tcp_wmem and not /proc/sys/net/core/wmem_default).
test_http_server_heavy.py also includes (trivial) handling of
client-induced errors like EPIPE and ECONNRESET. To validate content
served, a post-hook script for "boom" tool
(https://github.com/tarekziade/boom) is provided.

Before start, you may want to bump .listen() value in uasyncio/__init__.py
from default 10 to at least 30.

Start:

micropython -X heapsize=300000000 -O test_http_server_heavy.py

(Yes, that's 300Mb of heap - we'll be serving 4+Mb of content with 30
concurrent connections).

And:

PYTHONPATH=. boom -n1000 -c30 http://localhost:8081 --post-hook=boom_uasyncio.validate

There should be no Python exceptions in the output.