Skip to content

Instantly share code, notes, and snippets.

@brentertz
Created March 27, 2012 14:35
Show Gist options
  • Save brentertz/2216466 to your computer and use it in GitHub Desktop.
Save brentertz/2216466 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