Skip to content

Instantly share code, notes, and snippets.

@oremj
Last active January 3, 2016 15:38
Show Gist options
  • Save oremj/8483782 to your computer and use it in GitHub Desktop.
Save oremj/8483782 to your computer and use it in GitHub Desktop.
Use AWS hosts for vegeta load test.
#!/bin/bash
# assumes hosts are tagged with tag_Name_marketplace-stage-loadtest
# ansible tag_Name_marketplace-stage-loadtest -m copy -a "src=./vegeta dest=/tmp/vegeta" to copy vegeta to the load test hosts.
set -e
URL='https://marketplace.allizom.org/'
RATE=10
DURATION="1s"
TMPDIR="$(mktemp -d)"
TMPFILE="$(mktemp)"
trap "rm -rf \"${TMPDIR}\" \"${TMPFILE}\"" EXIT
cat > "${TMPFILE}" <<SCRIPT
ulimit -n 100000
echo 'GET ${URL}' | /tmp/vegeta attack -rate=${RATE} -duration=${DURATION} -output=/tmp/vegeta.result
SCRIPT
reports=""
for h in $(ansible --list-hosts tag_Name_marketplace-stage-loadtest); do
scp -q "${TMPFILE}" "$h":"${TMPFILE}"
(
ssh -tt -q "$h" "sudo /bin/bash \"${TMPFILE}\""
scp -q "$h":/tmp/vegeta.result "${TMPDIR}/$h.vr"
) &
reports=",${TMPDIR}/$h.vr"
done
wait
reports=${reports:1}
./vegeta report -input="${reports}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment