mirror of
https://github.com/azures04/crafatar.git
synced 2026-03-21 23:41:18 +01:00
improve test script
This commit is contained in:
parent
1328f98746
commit
56765488e0
63
test/bulk.sh
63
test/bulk.sh
@ -1,36 +1,55 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
hostname="crafatar.com"
|
||||||
async="true"
|
async="true"
|
||||||
|
random="false"
|
||||||
interval="0.1"
|
interval="0.1"
|
||||||
if [ "$1" = "-s" ]; then
|
|
||||||
async=""
|
|
||||||
shift
|
|
||||||
elif [ "$1" = "-i" ]; then
|
|
||||||
interval="$2"
|
|
||||||
shift 2
|
|
||||||
fi
|
|
||||||
host="$1"
|
|
||||||
shift
|
|
||||||
if [ -z "$host" ] || [ ! -z "$@" ]; then
|
|
||||||
echo "Usage: $0 [-s | -i <interval>] <host uri>"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# insert newline after uuids
|
usage() {
|
||||||
ids="$(cat 'uuids.txt')"
|
echo "Usage: $0 [-s | -r | -i <interval> | -h <hostname>]... <host uri>" >&2
|
||||||
# `brew install coreutils` on OS X
|
exit 1
|
||||||
ids="$(shuf <<< "$ids" 2>/dev/null || gshuf <<< "$ids")"
|
}
|
||||||
|
|
||||||
|
get_ids() {
|
||||||
|
local shuf
|
||||||
|
if [ "$random" = "true" ]; then
|
||||||
|
while true; do uuid -v 4; done
|
||||||
|
else
|
||||||
|
# `brew install coreutils` on OS X for gshuf
|
||||||
|
shuf=$(command -v shuf gshuf)
|
||||||
|
# randomize ids
|
||||||
|
$shuf < uuids.txt
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
bulk() {
|
bulk() {
|
||||||
trap return INT
|
trap return INT # return from this function on Ctrl+C
|
||||||
echo "$ids" | while read id; do
|
get_ids | while read id; do
|
||||||
if [ -z "$async" ]; then
|
if [ "$async" = "false" ]; then
|
||||||
curl -sSL -o /dev/null -w "%{url_effective} %{http_code} %{time_total}s\\n" -- "$host/avatars/$id?overlay"
|
curl -H "Host: $hostname" -sSL -o /dev/null -w "%{url_effective} %{http_code} %{time_total}s\\n" -- "$host/avatars/$id?overlay"
|
||||||
else
|
else
|
||||||
curl -sSL -o /dev/null -w "%{url_effective} %{http_code} %{time_total}s\\n" -- "$host/avatars/$id?overlay" &
|
curl -H "Host: $hostname" -sSL -o /dev/null -w "%{url_effective} %{http_code} %{time_total}s\\n" -- "$host/avatars/$id?overlay" &
|
||||||
sleep "$interval"
|
sleep "$interval"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
while [ $# != 0 ]; do
|
||||||
|
case "$1" in
|
||||||
|
-s)
|
||||||
|
async="false";;
|
||||||
|
-r)
|
||||||
|
random="true";;
|
||||||
|
-i)
|
||||||
|
interval="$2"
|
||||||
|
shift;;
|
||||||
|
*)
|
||||||
|
[ -n "$host" ] && usage
|
||||||
|
host="$1";;
|
||||||
|
esac
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
|
||||||
|
[ -z "$host" ] && usage
|
||||||
|
|
||||||
time bulk
|
time bulk
|
||||||
@ -4424,4 +4424,4 @@ ffdd082bf54e415b943a8713f2885913
|
|||||||
ffe0be5f0cab4b3785f67974c23660bb
|
ffe0be5f0cab4b3785f67974c23660bb
|
||||||
ffe3d4c861354928b932794d85a30567
|
ffe3d4c861354928b932794d85a30567
|
||||||
ffe72a222ac9463d81d3ee5eafb7f68e
|
ffe72a222ac9463d81d3ee5eafb7f68e
|
||||||
fff854a189644f12b92764fdb4573f8b
|
fff854a189644f12b92764fdb4573f8b
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user