Skip to content

Instantly share code, notes, and snippets.

@benfairless
Created December 6, 2017 11:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benfairless/ee0aa3b58180f0d16325be044a84675f to your computer and use it in GitHub Desktop.
Save benfairless/ee0aa3b58180f0d16325be044a84675f to your computer and use it in GitHub Desktop.
Test Session IDs in JBoss EAP
#!/usr/bin/env bash
endpoint='127.0.0.1'
filename="/tmp/$(date +%Y-%m-%d-%H-%M-%S)"
cookiejar="${filename}_cookie.txt"
first="${filename}_first.txt"
second="${filename}_second.txt"
cmd="curl http://${endpoint}/balancer/ -c ${cookiejar} -b ${cookiejar}"
# Run curl twice, first to get sessionid and second to see if the sessionid results in the same response
$cmd -o $first 2>/dev/null
$cmd -o $second 2>/dev/null
# Compare the output of both runs
diff -q --label 'First run' $first --label 'Second run' $second >/dev/null 2>&1
if [[ $? == '0' ]]; then
echo 'Session state is persisted. :)'
rm -f ${filename}*
exit 0
else
echo 'Session state is not persisted. :('
rm -f ${filename}*
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment