Skip to content

Commit 38bda12

Browse files
committed
CI runs integration tests
1 parent e4858d3 commit 38bda12

7 files changed

Lines changed: 54 additions & 9 deletions

File tree

.travis.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,23 @@
11
dist: xenial
2+
23
language: python
4+
35
python:
46
- "3.5"
57
- "3.6"
68
- "3.7"
9+
10+
before_install:
11+
- sudo apt-get install -y wrk
12+
713
install:
8-
- pip install --upgrade pip wheel pyo3-pack pytest hypothesis
14+
- pip install --upgrade pip wheel pyo3-pack pytest hypothesis gunicorn uwsgi flask
915
- curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain nightly -y
1016
- PATH=$HOME/.cargo/bin:$PATH cargo update
17+
1118
script:
1219
- PATH=$HOME/.cargo/bin:$PATH ./build --strip
1320
- pytest -v test
21+
- ./integration/run thread
22+
- ./integration/run gunicorn
23+
- ./integration/run uwsgi

develop

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,7 @@ pip install --upgrade \
1111
ujson \
1212
python-rapidjson \
1313
matplotlib \
14-
tabulate
14+
tabulate \
15+
uwsgi \
16+
gunicorn \
17+
flask

integration/client

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/bin/sh -e
22

3-
wrk -d 30 -c 4 http://127.0.0.1:8000/
3+
wrk -d 15 -c 2 http://127.0.0.1:8000/

integration/gunicorn

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1-
#!/bin/sh -e
1+
#!/usr/bin/env bash
22

3-
PYTHONPATH=. gunicorn --preload --workers 4 "$@" wsgi:app
3+
set -e
4+
5+
_dir="$(dirname "${BASH_SOURCE[0]}")"
6+
7+
PYTHONPATH=${_dir} gunicorn --preload --max-requests 100 --workers 2 "$@" wsgi:app

integration/run

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
_dir="$(dirname "${BASH_SOURCE[0]}")"
6+
7+
to_run="${@:-thread uwsgi gunicorn}"
8+
9+
if [[ $to_run == *"thread"* ]]; then
10+
"${_dir}"/thread
11+
fi
12+
13+
if [[ $to_run == *"gunicorn"* ]]; then
14+
"${_dir}"/gunicorn --daemon
15+
sleep 2
16+
"${_dir}"/client
17+
pkill -f -9 'wsgi:app'
18+
fi
19+
20+
if [[ $to_run == *"uwsgi"* ]]; then
21+
"${_dir}"/uwsgi --daemonize 2
22+
sleep 2
23+
"${_dir}"/client
24+
pkill -f -9 'wsgi:app'
25+
fi

integration/thread

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,14 @@ STATUS = 0
3030
def test_func(n):
3131
try:
3232
assert sorted(orjson.loads(orjson.dumps(DATA)), key=itemgetter('id')) == DATA
33-
print("thread %s: %s dumps, loads" % (get_ident(), n))
3433
except Exception:
3534
STATUS = 1
3635
traceback.print_exc()
3736
print("thread %s: %s dumps, loads ERROR" % (get_ident(), n))
3837

3938

4039
with ThreadPoolExecutor(max_workers=4) as executor:
41-
executor.map(test_func, range(50000), chunksize=1000)
40+
executor.map(test_func, range(20000), chunksize=1000)
4241
executor.shutdown(wait=True)
4342

4443

integration/uwsgi

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1-
#!/bin/sh -e
1+
#!/usr/bin/env bash
22

3-
PYTHONPATH=. uwsgi --http :8000 --processes 4 "$@" --mount /=wsgi:app
3+
set -e
4+
5+
_dir="$(dirname "${BASH_SOURCE[0]}")"
6+
7+
PYTHONPATH=${_dir} uwsgi --http :8000 --processes 2 "$@" --mount /=wsgi:app

0 commit comments

Comments
 (0)