From f57894c9a448888783f3b8ec053f98b4476d6a6b Mon Sep 17 00:00:00 2001 From: dedenbangkit Date: Thu, 16 May 2024 13:24:57 +0700 Subject: [PATCH] [#1464] Fix curl schedule --- .../stress_tests/household_submission.json | 22 +++++++++---------- doc/script/stress_tests/push_submissions.sh | 16 ++++---------- 2 files changed, 15 insertions(+), 23 deletions(-) diff --git a/doc/script/stress_tests/household_submission.json b/doc/script/stress_tests/household_submission.json index 429cea27a..db447d7df 100644 --- a/doc/script/stress_tests/household_submission.json +++ b/doc/script/stress_tests/household_submission.json @@ -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", @@ -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"], diff --git a/doc/script/stress_tests/push_submissions.sh b/doc/script/stress_tests/push_submissions.sh index 20cc91833..c2fe3b4e1 100755 --- a/doc/script/stress_tests/push_submissions.sh +++ b/doc/script/stress_tests/push_submissions.sh @@ -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' } @@ -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() { @@ -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