Last active
April 23, 2020 18:50
-
-
Save cirocosta/58399a95f21c62177932e4c6903a1691 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -o errexit | |
main () { | |
local stats_collector_pid | |
make_all_jobs_active | |
login | |
collect_mem_metrics & stats_collector_pid=$! | |
for i in $(seq 1 20); do | |
make_concurrent_requests $i | |
sleep 3 | |
done | |
kill $stats_collector_pid | |
} | |
login () { | |
fly -t local login -u test -p test | |
} | |
request_jobs () { | |
fly -t local curl /api/v1/jobs &> /dev/null | |
} | |
collect_mem_metrics () { | |
while true; do | |
mem >> stats.txt | |
sleep 0.1 | |
done | |
} | |
make_concurrent_requests () { | |
local inflight=$1 | |
local pids=() | |
for i in $(seq 1 $inflight); do | |
request_jobs & pids+=($!) | |
done | |
for pid in ${pids[@]}; do | |
wait $pid | |
done | |
} | |
mem () { | |
curl -s localhost:8079/debug/mem | |
} | |
make_all_jobs_active () { | |
local qry="UPDATE jobs SET active=true;" | |
echo "$qry" | docker exec -i concourse_db_1 psql -U dev \ | |
--dbname concourse; | |
} | |
main "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment