Skip to content

Commit

Permalink
Pad URL list when it's too short.
Browse files Browse the repository at this point in the history
  • Loading branch information
ndouglas committed Sep 22, 2023
1 parent 5248e2c commit 04dc036
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion scripts/stress-test-json-api.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@ echo "Getting URLs...";
request_urls=( $(curl --user "${username}:${password}" ${socks_option:-} --silent ${base_url}/jsonapi/node/news_story\?fields%5Bnode--news_story%5D\=path%2Ctitle\&page%5Blimit%5D\=${total_requests} | jq -r '.data[].links.self.href') );
echo "Got ${#request_urls[@]} URLs.";

# If there aren't sufficient URLs, pad the list.
if [ "${#request_urls[@]}" -lt "${total_requests}" ]; then
echo "Not enough URLs (have ${#request_urls[@]}, want ${total_requests}). Padding URLs...";
while [ "${#request_urls[@]}" -lt "${total_requests}" ]; do
request_urls+=( "${request_urls[@]}" );
done;
echo "Padded URLs to ${#request_urls[@]}.";
fi;

# Make the request to the server.
do_curl() {
local config_file="${1}";
Expand Down Expand Up @@ -120,7 +129,7 @@ for ((i=1; i<=batches; i++)); do

# Clear cache.
echo "Clearing cache...";
${clear_cache_command};
# ${clear_cache_command};

# Run the threads.
echo "Running ${threads} threads...";
Expand Down

0 comments on commit 04dc036

Please sign in to comment.