This is an automated email from the ASF dual-hosted git repository.

zhangliang2022 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git


The following commit(s) were added to refs/heads/main by this push:
     new 7e3ea54c feat: cover orderby/since parameter for jira-api-benchmark 
(#3554)
7e3ea54c is described below

commit 7e3ea54cc8fa0f8c5cb8abf90c2f0e107e5af86e
Author: Klesh Wong <[email protected]>
AuthorDate: Wed Oct 26 14:18:58 2022 +0800

    feat: cover orderby/since parameter for jira-api-benchmark (#3554)
---
 scripts/jira-api-benchmark.sh | 54 +++++++++++++++++++++++++++----------------
 1 file changed, 34 insertions(+), 20 deletions(-)

diff --git a/scripts/jira-api-benchmark.sh b/scripts/jira-api-benchmark.sh
index efc5f762..aaeed912 100755
--- a/scripts/jira-api-benchmark.sh
+++ b/scripts/jira-api-benchmark.sh
@@ -26,6 +26,8 @@ HOST=
 # id of a Scrum Board with more than 3000 issues
 BOARD=8
 PAGES=30
+PAGE_SIZE=100
+FILENAME=jira-server-benchmark-$(date +"%Y-%m-%d_%H_%M").csv
 
     # -w "%{http_code}" \
 # check if settings are correct
@@ -33,7 +35,7 @@ curl -H "Accept: application/json" -vv \
     -u "$USER:$PASSWORD" \
     $HOST/rest/api/2/serverInfo 2> /tmp/jira-server-stderr
 
-STATUS=$(grep -oP '^< HTTP.* \K([0-9]{3})' /tmp/jira-server-stderr)
+STATUS=$(grep -oP '^< HTTP.* \K([0-9]{3})' /tmp/jira-server-stderr | tail -n 1)
 if [ "$STATUS" != 200 ]; then
     awk '{ if ($0 ~ /authorization/) $0 = "==AUTHORIZATION FILTERED=="; print 
}' /tmp/jira-server-stderr
     echo "Failed to fetch jira server information, please make sure 
USER/PASSWORD/HOST and BOARD are set correct."
@@ -44,25 +46,37 @@ echo
 echo "Settings looks good, start benchmarking"
 
 
-# benchmark api response time and save to result.csv
-echo "EXPAND,PAGE_SIZE,PAGE,STATUS_CODE,ELLAPSE" > result.csv
-for PAGE_SIZE in 50 100; do
-    for EXPAND in "" "changelog"; do
-        for PAGE in $(seq 1 $PAGES); do
-            STARTAT=$((PAGE_SIZE * (PAGE - 1)))
-            
URL="$HOST/rest/agile/1.0/board/$BOARD/issue?expand=$EXPAND&jql=ORDER+BY+created+ASC&maxResults=100&startAt=$STARTAT"
-            printf "%s" "$URL" 
-            STARTED_TS=$(date +%s)
-            STATUS=$(
-            curl -H "Accept: application/json" \
-                -u "$USER:$PASSWORD" \
-                -s -o /dev/null -w "%{http_code}" \
-                $URL
-            )
-            ENDED_TS=$(date +%s)
-            ELLAPSE=$(( ENDED_TS - STARTED_TS ))
-            printf " %s %s\n" "$STATUS" "$ELLAPSE"
-            echo "$EXPAND","$PAGE_SIZE","$PAGE","$STATUS","$ELLAPSE" >> 
result.csv
+# benchmark api response time and save to file
+echo "ORDERBY,SINCE,EXPAND,PAGE_SIZE,PAGE,STATUS_CODE,ELLAPSE" > $FILENAME
+for ORDERBY in  " ORDER BY created ASC" ""; do
+    for SINCE in "-6 month" "-12 month" ""; do
+        for EXPAND in "" "changelog"; do
+            for PAGE in $(seq 1 $PAGES); do
+                JQL=
+                if [ -n "$SINCE" ]; then
+                    JQL="updated > '$(date --date="$SINCE" +"%Y/%m/%d %H:%M")'"
+                fi
+                JQL="$JQL$ORDERBY"
+                STARTAT=$((PAGE_SIZE * (PAGE - 1)))
+                URL="$HOST/rest/agile/1.0/board/$BOARD/issue"
+                printf "%s" "$URL" 
+                STARTED_TS=$(date +%s)
+                STATUS=$(
+                curl -H "Accept: application/json" \
+                    -u "$USER:$PASSWORD" \
+                    -s -o /dev/null -w "%{http_code}" \
+                    -G \
+                    --data-urlencode "jql=$JQL" \
+                    --data-urlencode "expand=$EXPAND" \
+                    --data-urlencode "maxResults=100" \
+                    --data-urlencode "startAt=$STARTAT" \
+                    $URL
+                )
+                ENDED_TS=$(date +%s)
+                ELLAPSE=$(( ENDED_TS - STARTED_TS ))
+                printf " %s %s\n" "$STATUS" "$ELLAPSE"
+                echo 
"$ORDERBY,$SINCE,$EXPAND,$PAGE_SIZE,$PAGE,$STATUS,$ELLAPSE" >> $FILENAME
+            done
         done
     done
 done

Reply via email to