Skip to content

Instantly share code, notes, and snippets.

@ledil
Forked from brentertz/ab.sh
Created September 28, 2017 08:15
Show Gist options
  • Save ledil/226c81f6c7a54a00083c26b715ee048e to your computer and use it in GitHub Desktop.
Save ledil/226c81f6c7a54a00083c26b715ee048e to your computer and use it in GitHub Desktop.
Apache Bench - Load test a protected page
#!/bin/bash
COOKIE_JAR="ab-cookie-jar"
COOKIE_NAME="_myapp_session"
USERNAME="foo@bar.com"
PASSWORD="password"
LOGIN_PAGE_URI="http://localhost:3000/users/sign_in"
TEST_PAGE_URI="http://localhost:3000/dashboard"
echo "Logging in and storing session id."
curl -i -c $COOKIE_JAR -X POST -d "user[email]=$USERNAME" -d "user[password]=$PASSWORD" $LOGIN_PAGE_URI
SESSION_ID=$(cat $COOKIE_JAR | grep $COOKIE_NAME | cut -f 7)
echo "Performing load test."
ab -n 1 -c 1 -v4 -C "$COOKIE_NAME=$SESSION_ID" $TEST_PAGE_URI
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment