-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathfruit_intake_generator.sh
executable file
·40 lines (38 loc) · 1.23 KB
/
fruit_intake_generator.sh
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
#!/bin/bash
# NOTE: Uses the decodable CLI to get the url for the rest connection.
# If you don't have the CLI installed go into the Decodable UI
# and check the configuration of the rest-source connection
# to manually set the URL here:
#
# api_endpoint='https://<XY>.api.data.decodable.co/v1alpha2/connections/<ID>/events'
#
api_endpoint=`decodable query --kind connection --name "rest-source" | yq '.status.properties.url'`
fruits=("Apple" "Banana" "Cherry" "Fig" "Grape" "Kiwi" "Lemon" "Raspberry" "Mango" "Blueberry" "Apricot" "Melon" "Cranberry")
max_num_events=10000
max_fruit_count=10
min_delay_secs=0.25
max_delay_secs=1.5
for ((i=0; i<max_num_events; i++)); do
fruit=${fruits[$RANDOM % ${#fruits[@]}]}
count=$(( (RANDOM % $max_fruit_count) + 1 ))
payload=$(cat <<EOF
{
"events": [
{
"name": "$fruit",
"count": $count
}
]
}
EOF
)
echo "sending fruit intake event:"
echo $payload
curl -X POST "$api_endpoint" \
-H "Content-Type: application/json" \
-H 'Authorization: Bearer JGUocmVU' \
-d "$payload"
echo ""
echo "pausing a bit ..."
sleep $(awk -v min=$min_delay_secs -v max=$max_delay_secs 'BEGIN{srand(); print min+rand()*(max-min)}')
done