3 # ============LICENSE_START===============================================
4 # Copyright (C) 2021 Nordix Foundation. All rights reserved.
5 # ========================================================================
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
10 # http://www.apache.org/licenses/LICENSE-2.0
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
17 # ============LICENSE_END=================================================
20 # This script format http endpoint stats generated by testscripts
23 echo "Usage: format_endpoint_stats <log-base-dir> <app-id> <app-description> [tc-id]+ "
32 inputarr=(${input// / })
35 inputposarr=(${inputp//\// })
36 inputnegarr=(${inputn//\// })
39 while read -r line; do
40 linearr=(${line// / })
43 lineposarr=(${linep//\// })
44 linenegarr=(${linen//\// })
45 if [[ ${linearr[1]} == ${inputarr[1]} ]] && [[ ${linearr[2]} == ${inputarr[2]} ]]; then
46 let lineposarr[0]=lineposarr[0]+inputposarr[0]
47 let lineposarr[1]=lineposarr[1]+inputposarr[1]
48 let linenegarr[0]=linenegarr[0]+inputnegarr[0]
49 let linenegarr[1]=linenegarr[1]+inputnegarr[1]
52 printf '%-2s %-10s %-45s %-16s %-16s' "#" "${linearr[1]}" "${linearr[2]}" "${lineposarr[0]}/${lineposarr[1]}" "${linenegarr[0]}/${linenegarr[1]}" >> $SUMMARYFILE_TMP
53 echo "" >> $SUMMARYFILE_TMP
55 if [ $found -eq 0 ]; then
56 printf '%-2s %-10s %-45s %-16s %-16s' "#" "${inputarr[1]}" "${inputarr[2]}" "${inputposarr[0]}/${inputposarr[1]}" "${inputnegarr[0]}/${inputnegarr[1]}" >> $SUMMARYFILE_TMP
57 echo "" >> $SUMMARYFILE_TMP
59 cp $SUMMARYFILE_TMP $SUMMARYFILE
67 if [ ! -d $BASE_DIR ]; then
69 echo "<log-base-dir> $BASE_DIR does not exist or is not a dir"
72 SUMMARYFILE=$BASE_DIR/endpoint_summary.log
75 SUMMARYFILE_TMP=$BASE_DIR/endpoint_summary_tmp.log
81 echo "==================================================="
82 echo "Functional test cases for $1"
83 echo "==================================================="
86 while [ $# -gt 0 ]; do
88 if [ ! -d $FTC_DIR ]; then
89 echo "Dir $FTC_DIR does not exist"
92 IMAGE_INFO_FILE=$FTC_DIR/imageinfo_$APP_ID".log"
93 if [ -f $IMAGE_INFO_FILE ]; then
94 echo "=== Testscript: $1 ==="
95 echo "Image: "$(cat $IMAGE_INFO_FILE)
97 TC_RES_FILE=$FTC_DIR/.result$1.txt
98 if [ -f "$TC_RES_FILE" ]; then
99 TC_RESULT=$(< "$TC_RES_FILE")
100 if [ $TC_RESULT -ne 0 ]; then
101 echo " !!!!! TESTCASE FAILED !!!!!"
102 let TC_FAIL=TC_FAIL+1
105 echo "=== Results: positive=2XX http status, negative=non 2XX http status - (ok/total)==="
106 echo "Method Endpoint Positive Negative"
107 grep --no-filename "#" $FTC_DIR/endpoint_$APP_ID* | cut -c 4-
108 for filename in $FTC_DIR/endpoint_$APP_ID* ; do
109 filedata=$(< $filename)
110 update_summary $filedata
112 echo "==============================="
115 echo "=== No stats collected by Testscript $1 ==="
121 echo "Summary of all testscripts"
122 if [ $TC_FAIL -ne 0 ]; then
123 echo " !!!!! ONE OR MORE TESTCASE(S) FAILED - CHECK INDIVIDUAL TEST RESULT!!!!!"
125 echo "=== Results: positive=2XX http status, negative=non 2XX http status - (ok/total)==="
126 echo "Method Endpoint Positive Negative"
127 cat $SUMMARYFILE | cut -c 4-