-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconcurrent_requests.sh
More file actions
executable file
·44 lines (34 loc) · 1.05 KB
/
concurrent_requests.sh
File metadata and controls
executable file
·44 lines (34 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/bash
# Configuration
BASE_URL="https://domain.com"
JWT_TOKEN="<redacted>"
ENDPOINT="/endpoint"
CONCURRENT_REQUESTS=10
# Sample request body (modify as needed)
REQUEST_BODY='
'
# Function to make a single request
make_request() {
local request_id=$1
echo "Starting request #$request_id"
response=$(curl -s -w "\n%{http_code}" -X PUT \
"${BASE_URL}${ENDPOINT}" \
-H "Authorization: Bearer ${JWT_TOKEN}" \
-H "Content-Type: application/json" \
-d "${REQUEST_BODY}")
http_code=$(echo "$response" | tail -n1)
body=$(echo "$response" | sed '$d')
echo "Request #$request_id completed with status: $http_code"
echo "Response body: $body"
}
# Export function and variables for parallel execution
export -f make_request
export BASE_URL JWT_TOKEN ENDPOINT REQUEST_BODY
# Run multiple requests in parallel
echo "Starting $CONCURRENT_REQUESTS concurrent requests..."
for i in $(seq 1 $CONCURRENT_REQUESTS); do
make_request $i &
done
# Wait for all background jobs to complete
wait
echo "All requests completed!"