Skip to content

Instantly share code, notes, and snippets.

@stujo
Forked from brentertz/ab.sh
Created April 3, 2018 18:15
Show Gist options
  • Save stujo/0a791753a578d4cd261fb890454c1af5 to your computer and use it in GitHub Desktop.
Save stujo/0a791753a578d4cd261fb890454c1af5 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