Skip to content

Commit

Permalink
[#1464] Fix curl schedule
Browse files Browse the repository at this point in the history
  • Loading branch information
dedenbangkit committed May 16, 2024
1 parent e118654 commit f57894c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 23 deletions.
22 changes: 11 additions & 11 deletions doc/script/stress_tests/household_submission.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,23 +76,23 @@
"1699435455818": ["g3_malariasafe_home"],
"1699435526190": ["g3_not_in_sthendemic_area"],
"1699354220734": ["new"],
"1699354849382": 61380.0,
"1699354849382": 61380,
"1702914753957": [-7.8360744, 110.3311868],
"1702914803732": "b0acba11-8064-4cb0-b1f2-59d3797ecae1",
"1699417958748": ["hh_head"],
"1699419048095": "Gaturi",
"1699419165632": "Mother",
"1699419372643": ["male"],
"1699419815660": 35.0,
"1699419861172": 1.0,
"1699419951523": 0.0,
"1699419815660": 35,
"1699419861172": 1,
"1699419951523": 0,
"1712229529": "1",
"1699419994672": 1.0,
"1699420051321": 0.0,
"1699420070055": 1.0,
"1699420103720": 1.0,
"1699420121397": 0.0,
"1699420137191": 0.0,
"1699419994672": 1,
"1699420051321": 0,
"1699420070055": 1,
"1699420103720": 1,
"1699420121397": 0,
"1699420137191": 0,
"1703265705460": "3",
"1703265879204": "1",
"1712234331": "1",
Expand All @@ -117,7 +117,7 @@
"1702282796765": ["g2_low_risk_of_groundwater_contamination"],
"1699428072669": ["g1_use_own_toilet"],
"1699428400205": ["g1_toilet_notshared_less_than_1015_users"],
"1710742384": 0.0,
"1710742384": 0,
"1699428351326": ["g1_all_use_toilet"],
"1699428535663": ["hh_member_1_g2_use_own_toilet_not_shared"],
"1711626271": ["hh_member_1_g2_use_own_toilet_not_shared"],
Expand Down
16 changes: 4 additions & 12 deletions doc/script/stress_tests/push_submissions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ get_auth_token() {
'https://rtmis.akvotest.org/api/v1/device/auth' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-H 'X-CSRFTOKEN: 8inxCl7WRqWt2enWNQaxpym2N7hN9StDGiccC6YofLz9AC6ORiraiHyuLYYCieTP' \
-d '{"code": "'$code'"}' | jq -r '.syncToken'
}

Expand Down Expand Up @@ -40,22 +39,15 @@ mkdir -p ./tmp
# The sync endpoint
push_schedule() {
# the submission payload
DATA=$(<"./tmp/$1.json")

# Prevent curl argument list too long
TMP_DATA_FILE="./tmp/tmp_$1.json"
echo "$DATA" >"$TMP_DATA_FILE"
DATA=$(jq . "./tmp/$1.json")

# Create the curl command to get only the status code
CURL_CMD="curl -o /dev/null -s -w \"File:$1.json | Status Code:%{http_code} | Time Total: %{time_total}\n\" -X 'POST' \
echo "curl -s -o /dev/null -w \"File:$1.json | Status Code:%{http_code} | Time Total: %{time_total}\n\" -X 'POST' \
'$URL' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer $MOBILE_AUTH_TOKEN' \
--data-binary @$TMP_DATA_FILE >> $LOG_FILE 2>&1; rm $TMP_DATA_FILE"

# Schedule the curl command using 'at'
echo "$CURL_CMD" | at "$SCHEDULE_TIME" >/dev/null 2>&1
-d '$DATA' >> $LOG_FILE 2>&1" | at "$SCHEDULE_TIME" >/dev/null 2>&1
}

push_data() {
Expand Down Expand Up @@ -89,6 +81,6 @@ push_data() {
input_file="./household_submission.json"

# Repeat 10 times
for i in $(seq 2 "$2"); do
for i in $(seq 1 "$2"); do
push_data "$input_file" "$i"
done

0 comments on commit f57894c

Please sign in to comment.