From 2efe714b03cfc04c7bd2849e8cbde502632c3513 Mon Sep 17 00:00:00 2001 From: Jonas L Date: Tue, 27 Sep 2022 08:10:37 +0200 Subject: [PATCH] chore: add icecast stress script (#2185) --- tools/icecast-stress.sh | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100755 tools/icecast-stress.sh diff --git a/tools/icecast-stress.sh b/tools/icecast-stress.sh new file mode 100755 index 000000000..628fab640 --- /dev/null +++ b/tools/icecast-stress.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash + +set -eu + +error() { + echo >&2 "error: $*" + exit 1 +} + +command -v curl > /dev/null || error "curl command not found!" + +# Run concurrent curls which download from url to /dev/null. +url="$1" + +# max concurrent calls +max=1000 +# call duration (in seconds) +duration=100 +# number of calls to start in batch +batch=10 +# time to wait before starting a new batch of calls (in seconds) +delay=1 + +count=0 +while [[ "$count" -le "$max" ]]; do + echo "starting $batch new calls ($count)" + for ((i = 1; i <= batch; i++)); do + curl -o /dev/null -m "$duration" -s "$url" & + done + count=$((count + batch)) + + sleep "$delay" +done +echo "waiting for calls to finish" +wait +echo "done"