mirror of
https://github.com/librecaptcha/lc-core.git
synced 2025-01-12 22:43:20 -05:00
Merge pull request #72 from UprootStaging/testing
Run locust tests in CI
This commit is contained in:
commit
02e9115641
@ -1,8 +1,7 @@
|
||||
name: Scala CI
|
||||
name: Core CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
pull_request:
|
||||
branches: [ master ]
|
||||
|
||||
@ -18,6 +17,8 @@ jobs:
|
||||
with:
|
||||
java-version: 1.11
|
||||
- name: Run tests
|
||||
run: sbt test
|
||||
run: sbt test assembly
|
||||
- name: Run linter
|
||||
run: sbt "scalafixAll --check"
|
||||
- name: Run locust tests
|
||||
run: ./tests/run.sh
|
3
.gitignore
vendored
3
.gitignore
vendored
@ -9,6 +9,9 @@
|
||||
.metals
|
||||
.vscode
|
||||
|
||||
# for python test env
|
||||
/testEnv/
|
||||
|
||||
# for various captcha
|
||||
/known/
|
||||
/unknown/
|
||||
|
@ -1,6 +1,22 @@
|
||||
from locust import task, between, SequentialTaskSet
|
||||
from locust.contrib.fasthttp import FastHttpUser
|
||||
from locust import events
|
||||
import json
|
||||
import logging
|
||||
|
||||
@events.quitting.add_listener
|
||||
def _(environment, **kw):
|
||||
if environment.stats.total.fail_ratio > 0.02:
|
||||
logging.error("Test failed due to failure ratio > 2%")
|
||||
environment.process_exit_code = 1
|
||||
elif environment.stats.total.avg_response_time > 300:
|
||||
logging.error("Test failed due to average response time ratio > 300 ms")
|
||||
environment.process_exit_code = 1
|
||||
elif environment.stats.total.get_response_time_percentile(0.95) > 800:
|
||||
logging.error("Test failed due to 95th percentile response time > 800 ms")
|
||||
environment.process_exit_code = 1
|
||||
else:
|
||||
environment.process_exit_code = 0
|
||||
|
||||
class QuickStartUser(SequentialTaskSet):
|
||||
wait_time = between(0.1,1)
|
||||
|
15
tests/run.sh
Executable file
15
tests/run.sh
Executable file
@ -0,0 +1,15 @@
|
||||
set -ex
|
||||
|
||||
python3 -m venv testEnv
|
||||
source ./testEnv/bin/activate
|
||||
pip install locust
|
||||
java -jar target/scala-2.13/LibreCaptcha.jar &
|
||||
JAVA_PID=$!
|
||||
sleep 4
|
||||
|
||||
locust --headless -u 1000 -r 100 --run-time 4m --stop-timeout 30 -f tests/locustfile.py
|
||||
status=$?
|
||||
|
||||
kill $JAVA_PID
|
||||
|
||||
exit $status
|
Loading…
Reference in New Issue
Block a user