Closed kantaroso closed 2 years ago
docker-compose
https://github.com/grafana/k6/blob/master/docker-compose.yml
Influxdbの設定変更
wordpress を使って post の検証
version: '3'
services: db: image: mysql:5.7 volumes:
db_data:/var/lib/mysql restart: always environment: MYSQL_ROOT_PASSWORD: somewordpress MYSQL_DATABASE: wordpress MYSQL_USER: wordpress MYSQL_PASSWORD: wordpress
wordpress: depends_on:
import http from 'k6/http';
import { sleep } from 'k6';
export let options = { vus: 10, iterations: 100 };
export default function () { //http.get('http://host.docker.internal/maker/list'); const post_input = { 'log': 'admin', 'pwd': 'kqMd$V95%Cu&gS((JV', 'redirect_to':'http://host.docker.internal:8000/wp-admin/' }; let res; res = http.get('http://host.docker.internal:8000/wp-login.php'); res = http.post('http://host.docker.internal:8000/wp-login.php', post_input, { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } }); if ( res.url.indexOf('wp-login.php') !== -1 ) { console.log('login failed'); return; } const params = { cookies: res.cookies }; res = http.get('http://host.docker.internal:8000/wp-admin/', params); console.log('login success'); sleep(1); }
adminnoMacBook-Air:game-information admin$ docker-compose -f infra/docker-compose/stresstest/docker-compose.yml run --rm k6 run /scripts/script.js
/\ |‾‾| /‾‾/ /‾‾/
/\ / \ | |/ / / /
/ \/ \ | ( / ‾‾\
/ \ | |\ \ | (‾) | / __ \ || __\ ___/ .io
execution: local script: /scripts/script.js output: InfluxDBv1 (http://influxdb:8086)
scenarios: (100.00%) 1 scenario, 100 max VUs, 2m0s max duration (incl. graceful stop):
INFO[0001] login success source=console INFO[0002] login success source=console INFO[0002] login success source=console INFO[0002] login success source=console INFO[0003] login success source=console INFO[0004] login success source=console INFO[0005] login success source=console INFO[0005] login success source=console INFO[0006] login success source=console : : INFO[0097] login failed source=console INFO[0097] login failed source=console INFO[0097] login failed source=console INFO[0097] login failed source=console INFO[0097] login failed source=console INFO[0097] login success source=console INFO[0098] login failed source=console INFO[0098] login failed source=console INFO[0098] login failed source=console INFO[0098] login success source=console INFO[0098] login failed source=console INFO[0098] login failed source=console INFO[0098] login success source=console INFO[0098] login success source=console INFO[0098] login success source=console INFO[0098] login success source=console INFO[0098] login success source=console INFO[0098] login success source=console
running (1m38.4s), 000/100 VUs, 357 complete and 0 interrupted iterations default ↓ [======================================] 070/100 VUs 1m30s
data_received..................: 25 MB 252 kB/s
data_sent......................: 589 kB 6.0 kB/s
http_req_blocked...............: avg=334.48µs min=28.7µs med=38.19µs max=24.17ms p(90)=231.4µs p(95)=2.73ms
http_req_connecting............: avg=201.77µs min=0s med=0s max=11.89ms p(90)=0s p(95)=2ms
http_req_duration..............: avg=5.01s min=81.68ms med=5.11s max=16.42s p(90)=7.59s p(95)=8.61s
{ expected_response:true }...: avg=5.01s min=81.68ms med=5.11s max=16.42s p(90)=7.59s p(95)=8.61s
http_req_failed................: 0.00% ✓ 0 ✗ 1456
http_req_receiving.............: avg=218.76ms min=132.89µs med=23.68ms max=3.26s p(90)=785.72ms p(95)=1.7s
http_req_sending...............: avg=191.11µs min=32.8µs med=75.44µs max=9.95ms p(90)=364.2µs p(95)=657.3µs
http_req_tls_handshaking.......: avg=0s min=0s med=0s max=0s p(90)=0s p(95)=0s
http_req_waiting...............: avg=4.79s min=81.42ms med=5.02s max=16.42s p(90)=6.97s p(95)=7.67s
http_reqs......................: 1456 14.79214/s
iteration_duration.............: avg=20.81s min=1.58s med=21.75s max=42.04s p(90)=30.24s p(95)=32.31s
iterations.....................: 357 3.626919/s
vus............................: 7 min=4 max=100
vus_max........................: 100 min=100 max=100
ログインがうまくできてたりダメだったりするぽい
大規模テストをするときの使い方 https://zenn.dev/kawabatas/articles/k6-running-large-tests
https://github.com/kantaroso/stress-test-sample
成果物は別リポジトリに格納
概要
https://k6.io/
上記が良さそうなので使ってみる