Check script/loadtest's duration before the build
A duration must be a whole number above zero followed by ms, s, m or h; anything else prints the usage line and exits 2 before the image build, as a bad number of clients already did. vegeta takes 0 to mean no end. The load test's entry moves to the top of Completed Steps in TODO.md. Model: opus-5-5
This commit is contained in:
+17
-4
@@ -32,14 +32,27 @@ VEGETA_COMMIT=4b240c3089fa4aa10816542d64a74294d974211f
|
||||
# routed on the internet.
|
||||
SUBNET=203.0.113.0/24
|
||||
|
||||
usage() {
|
||||
echo "usage: script/loadtest [duration [clients]]" >&2
|
||||
exit 2
|
||||
}
|
||||
|
||||
main() {
|
||||
duration="${1:-10s}"
|
||||
clients="${2:-4}"
|
||||
# The duration is a whole number, not zero (vegeta takes 0 to mean no
|
||||
# end), followed by ms, s, m or h.
|
||||
case "$duration" in
|
||||
*ms) number="${duration%ms}" ;;
|
||||
*s | *m | *h) number="${duration%?}" ;;
|
||||
*) usage ;;
|
||||
esac
|
||||
case "$number" in
|
||||
"" | *[!0-9]*) usage ;;
|
||||
esac
|
||||
[ "$number" -gt 0 ] || usage
|
||||
case "$clients" in
|
||||
*[!0-9]* | 0)
|
||||
echo "usage: script/loadtest [duration [clients]]" >&2
|
||||
exit 2
|
||||
;;
|
||||
*[!0-9]* | 0) usage ;;
|
||||
esac
|
||||
|
||||
cd "$ROOT"
|
||||
|
||||
Reference in New Issue
Block a user