kantaroso / game-information

0 stars 0 forks source link

負荷テストツールを試してみる #36

Closed kantaroso closed 2 years ago

kantaroso commented 2 years ago

概要

https://k6.io/

上記が良さそうなので使ってみる

kantaroso commented 2 years ago

選定参考 https://pr.hedgehog-loader.io/blog/3r5ta4m94hnb46nssjjqnw

kantaroso commented 2 years ago

docker-compose

https://github.com/grafana/k6/blob/master/docker-compose.yml

kantaroso commented 2 years ago

構築参考

https://ichi.pro/k-6-to-dockercompose-o-shiyoshita-utsukushii-fuka-tesuto-75131555914467 https://qiita.com/KO_YAmajun/items/8f2433d1244a7d886275

kantaroso commented 2 years ago

grafanaは画面から設定する

Data SourceにInfluxを追加する

スクリーンショット 2022-02-19 18 17 29

設定のimport

設定 https://grafana.com/grafana/dashboards/2587

スクリーンショット 2022-02-19 18 21 56

スクリーンショット 2022-02-19 18 22 22

kantaroso commented 2 years ago

Influxdbの設定変更 スクリーンショット 2022-02-19 18 45 59 スクリーンショット 2022-02-19 18 43 34

kantaroso commented 2 years ago

テストのオプション設定

https://future-architect.github.io/articles/20210324/ https://k6.io/docs/using-k6/options/

kantaroso commented 2 years ago

wordpress を使って post の検証

services: db: image: mysql:5.7 volumes:

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


ログインがうまくできてたりダメだったりするぽい
kantaroso commented 2 years ago

大規模テストをするときの使い方 https://zenn.dev/kawabatas/articles/k6-running-large-tests

kantaroso commented 2 years ago

https://github.com/kantaroso/stress-test-sample

成果物は別リポジトリに格納