Last active
October 16, 2019 09:20
-
-
Save Integralist/d16924d70b14502cbe5bb443ac62a09b to your computer and use it in GitHub Desktop.
[Bash string wildcard glob conains example] #bash #wildcard #glob #contains
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# our CDN was serving stale content for a request that shouldn't be | |
# so we wrote a quick script to verify the behaviour wasn't happening | |
# more often than it should. | |
function get { | |
local id=$1 | |
local url="https://www.example.com/?id=$id" | |
local response=$(curl -D - -so /dev/null -H 'X-Debug:1' "$url") | |
local state=$(echo "$response" | grep 'Foo-State') | |
echo "$state" | |
} | |
for i in {1..50} | |
do | |
uid="attempt-$i-$(uuidgen)" | |
result1=$(get "$uid") | |
result2=$(get "$uid") | |
if [[ "$result2" == *"HIT-STALE"* ]]; then | |
echo "$uid: got stale :-(" | |
elif [[ "$result2" == *"HIT-"* ]]; then | |
echo "$uid: was fine :-)" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment