BjornMagnussonXA | bf3700b | 2020-10-05 08:39:40 +0200 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | # ============LICENSE_START=============================================== |
| 4 | # Copyright (C) 2020 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 |
| 9 | # |
| 10 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | # |
| 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================================================= |
| 18 | # |
| 19 | |
| 20 | # This is a script that contains specific test functions for ECS NB/SB API |
| 21 | |
| 22 | . ../common/api_curl.sh |
| 23 | |
| 24 | ############### EXPERIMENTAL ############# |
| 25 | |
| 26 | ########################################## |
| 27 | ###### Mainly only function skeletons #### |
| 28 | ########################################## |
| 29 | |
| 30 | ########################################## |
| 31 | ### A1-E Enrichment Data Consumer API #### |
| 32 | ########################################## |
| 33 | #Function prefix: ecs_api_a1 |
| 34 | |
| 35 | # API Test function: GET /A1-EI/v1/eitypes/{eiTypeId}/eijobs |
BjornMagnussonXA | f38e1e8 | 2020-10-11 23:05:02 +0200 | [diff] [blame] | 36 | # args: <response-code> <type-id> <owner-id>|NOOWNER [ EMPTY | <job-id>+ ] |
BjornMagnussonXA | bf3700b | 2020-10-05 08:39:40 +0200 | [diff] [blame] | 37 | # (Function for test scripts) |
| 38 | ecs_api_a1_get_job_ids() { |
| 39 | echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD |
| 40 | echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG |
| 41 | ((RES_TEST++)) |
| 42 | |
BjornMagnussonXA | f38e1e8 | 2020-10-11 23:05:02 +0200 | [diff] [blame] | 43 | # Valid number of parameters 3,4,5,6 etc |
BjornMagnussonXA | bf3700b | 2020-10-05 08:39:40 +0200 | [diff] [blame] | 44 | if [ $# -lt 1 ]; then |
BjornMagnussonXA | f38e1e8 | 2020-10-11 23:05:02 +0200 | [diff] [blame] | 45 | __print_err "<response-code> <type-id> <owner-id>|NOOWNER [ EMPTY | <job-id>+ ]" $@ |
BjornMagnussonXA | bf3700b | 2020-10-05 08:39:40 +0200 | [diff] [blame] | 46 | return 1 |
| 47 | fi |
BjornMagnussonXA | f38e1e8 | 2020-10-11 23:05:02 +0200 | [diff] [blame] | 48 | owner="" |
| 49 | if [ $3 != "NOWNER" ]; then |
| 50 | owner="?owner="$3 |
| 51 | fi |
| 52 | |
| 53 | query="/A1-EI/v1/eitypes/$2/eijobs$owner" |
| 54 | res="$(__do_curl_to_api ECS GET $query)" |
| 55 | status=${res:${#res}-3} |
| 56 | |
| 57 | if [ $status -ne $1 ]; then |
| 58 | echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED |
| 59 | ((RES_FAIL++)) |
| 60 | __check_stop_at_error |
| 61 | return 1 |
| 62 | fi |
| 63 | |
| 64 | if [ $# -gt 3 ]; then |
| 65 | body=${res:0:${#res}-3} |
| 66 | targetJson="[" |
| 67 | |
| 68 | for pid in ${@:4} ; do |
| 69 | if [ "$targetJson" != "[" ]; then |
| 70 | targetJson=$targetJson"," |
| 71 | fi |
| 72 | if [ $pid != "EMPTY" ]; then |
| 73 | targetJson=$targetJson"\"$pid\"" |
| 74 | fi |
| 75 | done |
| 76 | |
| 77 | targetJson=$targetJson"]" |
| 78 | echo " TARGET JSON: $targetJson" >> $HTTPLOG |
| 79 | res=$(python3 ../common/compare_json.py "$targetJson" "$body") |
| 80 | |
| 81 | if [ $res -ne 0 ]; then |
| 82 | echo -e $RED" FAIL, returned body not correct"$ERED |
| 83 | ((RES_FAIL++)) |
| 84 | __check_stop_at_error |
| 85 | return 1 |
| 86 | fi |
| 87 | fi |
BjornMagnussonXA | bf3700b | 2020-10-05 08:39:40 +0200 | [diff] [blame] | 88 | |
| 89 | ((RES_PASS++)) |
| 90 | echo -e $GREEN" PASS"$EGREEN |
| 91 | return 0 |
| 92 | } |
| 93 | |
| 94 | # API Test function: GET /A1-EI/v1/eitypes/{eiTypeId} |
BjornMagnussonXA | f38e1e8 | 2020-10-11 23:05:02 +0200 | [diff] [blame] | 95 | # args: <response-code> <type-id> [<schema-file>] |
BjornMagnussonXA | bf3700b | 2020-10-05 08:39:40 +0200 | [diff] [blame] | 96 | # (Function for test scripts) |
| 97 | ecs_api_a1_get_type() { |
| 98 | echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD |
| 99 | echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG |
| 100 | ((RES_TEST++)) |
| 101 | |
BjornMagnussonXA | f38e1e8 | 2020-10-11 23:05:02 +0200 | [diff] [blame] | 102 | if [ $# -lt 2 ] || [ $# -gt 3 ]; then |
| 103 | __print_err "<response-code> <type-id> [<schema-file>]" $@ |
BjornMagnussonXA | bf3700b | 2020-10-05 08:39:40 +0200 | [diff] [blame] | 104 | return 1 |
| 105 | fi |
| 106 | |
BjornMagnussonXA | f38e1e8 | 2020-10-11 23:05:02 +0200 | [diff] [blame] | 107 | query="/A1-EI/v1/eitypes/$2" |
| 108 | res="$(__do_curl_to_api ECS GET $query)" |
| 109 | status=${res:${#res}-3} |
| 110 | |
| 111 | if [ $status -ne $1 ]; then |
| 112 | echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED |
| 113 | ((RES_FAIL++)) |
| 114 | __check_stop_at_error |
| 115 | return 1 |
| 116 | fi |
| 117 | |
| 118 | if [ $# -eq 3 ]; then |
| 119 | body=${res:0:${#res}-3} |
| 120 | if [ -f $3 ]; then |
| 121 | schema=$(cat $3) |
| 122 | else |
| 123 | echo -e $RED" FAIL. Schema file "$3", does not exist"$ERED |
| 124 | ((RES_FAIL++)) |
| 125 | __check_stop_at_error |
| 126 | return 1 |
| 127 | fi |
| 128 | targetJson="{\"eiJobParametersSchema\":$schema}" |
| 129 | echo " TARGET JSON: $targetJson" >> $HTTPLOG |
| 130 | res=$(python3 ../common/compare_json.py "$targetJson" "$body") |
| 131 | |
| 132 | if [ $res -ne 0 ]; then |
| 133 | echo -e $RED" FAIL, returned body not correct"$ERED |
| 134 | ((RES_FAIL++)) |
| 135 | __check_stop_at_error |
| 136 | return 1 |
| 137 | fi |
| 138 | fi |
| 139 | |
| 140 | |
BjornMagnussonXA | bf3700b | 2020-10-05 08:39:40 +0200 | [diff] [blame] | 141 | ((RES_PASS++)) |
| 142 | echo -e $GREEN" PASS"$EGREEN |
| 143 | return 0 |
| 144 | } |
| 145 | |
| 146 | # API Test function: GET /A1-EI/v1/eitypes |
BjornMagnussonXA | f38e1e8 | 2020-10-11 23:05:02 +0200 | [diff] [blame] | 147 | # args: <response-code> (EMPTY | [<type-id>]+) |
BjornMagnussonXA | bf3700b | 2020-10-05 08:39:40 +0200 | [diff] [blame] | 148 | # (Function for test scripts) |
| 149 | ecs_api_a1_get_type_ids() { |
| 150 | echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD |
| 151 | echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG |
| 152 | ((RES_TEST++)) |
| 153 | |
BjornMagnussonXA | f38e1e8 | 2020-10-11 23:05:02 +0200 | [diff] [blame] | 154 | if [ $# -lt 2 ]; then |
| 155 | __print_err "<response-code> (EMPTY | [<type-id>]+)" $@ |
| 156 | return 1 |
| 157 | fi |
| 158 | |
| 159 | query="/A1-EI/v1/eitypes" |
| 160 | res="$(__do_curl_to_api ECS GET $query)" |
| 161 | status=${res:${#res}-3} |
| 162 | |
| 163 | if [ $status -ne $1 ]; then |
| 164 | echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED |
| 165 | ((RES_FAIL++)) |
| 166 | __check_stop_at_error |
| 167 | return 1 |
| 168 | fi |
| 169 | body=${res:0:${#res}-3} |
| 170 | targetJson="[" |
| 171 | if [ $2 != "EMPTY" ]; then |
| 172 | for pid in ${@:2} ; do |
| 173 | if [ "$targetJson" != "[" ]; then |
| 174 | targetJson=$targetJson"," |
| 175 | fi |
| 176 | targetJson=$targetJson"\"$pid\"" |
| 177 | done |
| 178 | fi |
| 179 | targetJson=$targetJson"]" |
| 180 | echo " TARGET JSON: $targetJson" >> $HTTPLOG |
| 181 | res=$(python3 ../common/compare_json.py "$targetJson" "$body") |
| 182 | |
| 183 | if [ $res -ne 0 ]; then |
| 184 | echo -e $RED" FAIL, returned body not correct"$ERED |
| 185 | ((RES_FAIL++)) |
| 186 | __check_stop_at_error |
BjornMagnussonXA | bf3700b | 2020-10-05 08:39:40 +0200 | [diff] [blame] | 187 | return 1 |
| 188 | fi |
| 189 | |
| 190 | ((RES_PASS++)) |
| 191 | echo -e $GREEN" PASS"$EGREEN |
| 192 | return 0 |
| 193 | } |
| 194 | |
| 195 | # API Test function: GET /A1-EI/v1/eitypes/{eiTypeId}/eijobs/{eiJobId}/status |
BjornMagnussonXA | f38e1e8 | 2020-10-11 23:05:02 +0200 | [diff] [blame] | 196 | # args: <response-code> <type-id> <job-id> [<status>] |
BjornMagnussonXA | bf3700b | 2020-10-05 08:39:40 +0200 | [diff] [blame] | 197 | # (Function for test scripts) |
| 198 | ecs_api_a1_get_job_status() { |
| 199 | echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD |
| 200 | echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG |
| 201 | ((RES_TEST++)) |
| 202 | |
BjornMagnussonXA | f38e1e8 | 2020-10-11 23:05:02 +0200 | [diff] [blame] | 203 | if [ $# -ne 3 ] && [ $# -ne 4 ]; then |
| 204 | __print_err "<response-code> <type-id> <job-id>" $@ |
BjornMagnussonXA | bf3700b | 2020-10-05 08:39:40 +0200 | [diff] [blame] | 205 | return 1 |
| 206 | fi |
| 207 | |
BjornMagnussonXA | f38e1e8 | 2020-10-11 23:05:02 +0200 | [diff] [blame] | 208 | query="/A1-EI/v1/eitypes/$2/eijobs/$3/status" |
| 209 | res="$(__do_curl_to_api ECS GET $query)" |
| 210 | status=${res:${#res}-3} |
| 211 | |
| 212 | if [ $status -ne $1 ]; then |
| 213 | echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED |
| 214 | ((RES_FAIL++)) |
| 215 | __check_stop_at_error |
| 216 | return 1 |
| 217 | fi |
| 218 | if [ $# -eq 4 ]; then |
| 219 | body=${res:0:${#res}-3} |
| 220 | targetJson="{\"operationalState\": \"$4\"}" |
| 221 | echo " TARGET JSON: $targetJson" >> $HTTPLOG |
| 222 | res=$(python3 ../common/compare_json.py "$targetJson" "$body") |
| 223 | |
| 224 | if [ $res -ne 0 ]; then |
| 225 | echo -e $RED" FAIL, returned body not correct"$ERED |
| 226 | ((RES_FAIL++)) |
| 227 | __check_stop_at_error |
| 228 | return 1 |
| 229 | fi |
| 230 | fi |
| 231 | |
BjornMagnussonXA | bf3700b | 2020-10-05 08:39:40 +0200 | [diff] [blame] | 232 | ((RES_PASS++)) |
| 233 | echo -e $GREEN" PASS"$EGREEN |
| 234 | return 0 |
| 235 | } |
| 236 | |
| 237 | # API Test function: GET /A1-EI/v1/eitypes/{eiTypeId}/eijobs/{eiJobId} |
BjornMagnussonXA | f38e1e8 | 2020-10-11 23:05:02 +0200 | [diff] [blame] | 238 | # args: <response-code> <type-id> <job-id> [<target-url> <owner-id> <template-job-file>] |
BjornMagnussonXA | bf3700b | 2020-10-05 08:39:40 +0200 | [diff] [blame] | 239 | # (Function for test scripts) |
| 240 | ecs_api_a1_get_job() { |
| 241 | echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD |
| 242 | echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG |
| 243 | ((RES_TEST++)) |
| 244 | |
BjornMagnussonXA | f38e1e8 | 2020-10-11 23:05:02 +0200 | [diff] [blame] | 245 | if [ $# -ne 3 ] && [ $# -ne 6 ]; then |
| 246 | __print_err "<response-code> <type-id> <job-id> [<target-url> <owner-id> <template-job-file>]" $@ |
BjornMagnussonXA | bf3700b | 2020-10-05 08:39:40 +0200 | [diff] [blame] | 247 | return 1 |
| 248 | fi |
| 249 | |
BjornMagnussonXA | f38e1e8 | 2020-10-11 23:05:02 +0200 | [diff] [blame] | 250 | query="/A1-EI/v1/eitypes/$2/eijobs/$3" |
| 251 | res="$(__do_curl_to_api ECS GET $query)" |
| 252 | status=${res:${#res}-3} |
| 253 | |
| 254 | if [ $status -ne $1 ]; then |
| 255 | echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED |
| 256 | ((RES_FAIL++)) |
| 257 | __check_stop_at_error |
| 258 | return 1 |
| 259 | fi |
| 260 | |
| 261 | if [ $# -eq 6 ]; then |
| 262 | body=${res:0:${#res}-3} |
| 263 | |
| 264 | if [ -f $6 ]; then |
| 265 | jobfile=$(cat $6) |
| 266 | jobfile=$(echo "$jobfile" | sed "s/XXXX/$3/g") |
| 267 | else |
| 268 | echo -e $RED" FAIL. Job template file "$6", does not exist"$ERED |
| 269 | ((RES_FAIL++)) |
| 270 | __check_stop_at_error |
| 271 | return 1 |
| 272 | fi |
| 273 | targetJson="{\"targetUri\": \"$4\",\"jobOwner\": \"$5\",\"jobParameters\": $jobfile}" |
| 274 | echo " TARGET JSON: $targetJson" >> $HTTPLOG |
| 275 | res=$(python3 ../common/compare_json.py "$targetJson" "$body") |
| 276 | |
| 277 | if [ $res -ne 0 ]; then |
| 278 | echo -e $RED" FAIL, returned body not correct"$ERED |
| 279 | ((RES_FAIL++)) |
| 280 | __check_stop_at_error |
| 281 | return 1 |
| 282 | fi |
| 283 | fi |
| 284 | |
BjornMagnussonXA | bf3700b | 2020-10-05 08:39:40 +0200 | [diff] [blame] | 285 | ((RES_PASS++)) |
| 286 | echo -e $GREEN" PASS"$EGREEN |
| 287 | return 0 |
| 288 | } |
| 289 | |
| 290 | # API Test function: DELETE /A1-EI/v1/eitypes/{eiTypeId}/eijobs/{eiJobId} |
BjornMagnussonXA | f38e1e8 | 2020-10-11 23:05:02 +0200 | [diff] [blame] | 291 | # args: <response-code> <type-id> <job-id> |
BjornMagnussonXA | bf3700b | 2020-10-05 08:39:40 +0200 | [diff] [blame] | 292 | # (Function for test scripts) |
| 293 | ecs_api_a1_delete_job() { |
| 294 | echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD |
| 295 | echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG |
| 296 | ((RES_TEST++)) |
| 297 | |
BjornMagnussonXA | f38e1e8 | 2020-10-11 23:05:02 +0200 | [diff] [blame] | 298 | if [ $# -lt 3 ]; then |
| 299 | __print_err "<response-code> <type-id> <job-id>" $@ |
| 300 | return 1 |
| 301 | fi |
| 302 | |
| 303 | query="/A1-EI/v1/eitypes/$2/eijobs/$3" |
| 304 | res="$(__do_curl_to_api ECS DELETE $query)" |
| 305 | status=${res:${#res}-3} |
| 306 | |
| 307 | if [ $status -ne $1 ]; then |
| 308 | echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED |
| 309 | ((RES_FAIL++)) |
| 310 | __check_stop_at_error |
BjornMagnussonXA | bf3700b | 2020-10-05 08:39:40 +0200 | [diff] [blame] | 311 | return 1 |
| 312 | fi |
| 313 | |
| 314 | ((RES_PASS++)) |
| 315 | echo -e $GREEN" PASS"$EGREEN |
| 316 | return 0 |
| 317 | } |
| 318 | |
| 319 | # API Test function: PUT /A1-EI/v1/eitypes/{eiTypeId}/eijobs/{eiJobId} |
BjornMagnussonXA | f38e1e8 | 2020-10-11 23:05:02 +0200 | [diff] [blame] | 320 | # args: <response-code> <type-id> <job-id> <target-url> <owner-id> <template-job-file> |
BjornMagnussonXA | bf3700b | 2020-10-05 08:39:40 +0200 | [diff] [blame] | 321 | # (Function for test scripts) |
| 322 | ecs_api_a1_put_job() { |
| 323 | echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD |
| 324 | echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG |
| 325 | ((RES_TEST++)) |
| 326 | |
BjornMagnussonXA | f38e1e8 | 2020-10-11 23:05:02 +0200 | [diff] [blame] | 327 | if [ $# -lt 6 ]; then |
| 328 | __print_err "<response-code> <type-id> <job-id> <target-url> <owner-id> <template-job-file>" $@ |
| 329 | return 1 |
| 330 | fi |
| 331 | if [ -f $6 ]; then |
| 332 | jobfile=$(cat $6) |
| 333 | jobfile=$(echo "$jobfile" | sed "s/XXXX/$3/g") |
| 334 | else |
| 335 | echo -e $RED" FAIL. Job template file "$6", does not exist"$ERED |
| 336 | ((RES_FAIL++)) |
| 337 | __check_stop_at_error |
| 338 | return 1 |
| 339 | fi |
| 340 | |
| 341 | inputJson="{\"targetUri\": \"$4\",\"jobOwner\": \"$5\",\"jobParameters\": $jobfile}" |
| 342 | file="./tmp/.p.json" |
| 343 | echo "$inputJson" > $file |
| 344 | |
| 345 | query="/A1-EI/v1/eitypes/$2/eijobs/$3" |
| 346 | res="$(__do_curl_to_api ECS PUT $query $file)" |
| 347 | status=${res:${#res}-3} |
| 348 | |
| 349 | if [ $status -ne $1 ]; then |
| 350 | echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED |
| 351 | ((RES_FAIL++)) |
| 352 | __check_stop_at_error |
BjornMagnussonXA | bf3700b | 2020-10-05 08:39:40 +0200 | [diff] [blame] | 353 | return 1 |
| 354 | fi |
| 355 | |
| 356 | ((RES_PASS++)) |
| 357 | echo -e $GREEN" PASS"$EGREEN |
| 358 | return 0 |
| 359 | } |
| 360 | |
| 361 | |
| 362 | ########################################## |
| 363 | #### Enrichment Data Producer API #### |
| 364 | ########################################## |
| 365 | # Function prefix: ecs_api_edp |
| 366 | |
| 367 | # API Test function: GET /ei-producer/v1/eitypes |
BjornMagnussonXA | f38e1e8 | 2020-10-11 23:05:02 +0200 | [diff] [blame] | 368 | # args: <response-code> [ EMPTY | <type-id>+] |
BjornMagnussonXA | bf3700b | 2020-10-05 08:39:40 +0200 | [diff] [blame] | 369 | # (Function for test scripts) |
| 370 | ecs_api_edp_get_type_ids() { |
| 371 | echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD |
| 372 | echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG |
| 373 | ((RES_TEST++)) |
| 374 | |
| 375 | if [ $# -lt 1 ]; then |
BjornMagnussonXA | f38e1e8 | 2020-10-11 23:05:02 +0200 | [diff] [blame] | 376 | __print_err "<response-code> [ EMPTY | <type-id>+]" $@ |
BjornMagnussonXA | bf3700b | 2020-10-05 08:39:40 +0200 | [diff] [blame] | 377 | return 1 |
| 378 | fi |
| 379 | |
BjornMagnussonXA | f38e1e8 | 2020-10-11 23:05:02 +0200 | [diff] [blame] | 380 | query="/ei-producer/v1/eitypes" |
| 381 | res="$(__do_curl_to_api ECS GET $query)" |
| 382 | status=${res:${#res}-3} |
| 383 | |
| 384 | if [ $status -ne $1 ]; then |
| 385 | echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED |
| 386 | ((RES_FAIL++)) |
| 387 | __check_stop_at_error |
| 388 | return 1 |
| 389 | fi |
| 390 | |
| 391 | if [ $# -gt 1 ]; then |
| 392 | body=${res:0:${#res}-3} |
| 393 | targetJson="[" |
| 394 | if [ $2 != "EMPTY" ]; then |
| 395 | for pid in ${@:2} ; do |
| 396 | if [ "$targetJson" != "[" ]; then |
| 397 | targetJson=$targetJson"," |
| 398 | fi |
| 399 | targetJson=$targetJson"\"$pid\"" |
| 400 | done |
| 401 | fi |
| 402 | targetJson=$targetJson"]" |
| 403 | echo " TARGET JSON: $targetJson" >> $HTTPLOG |
| 404 | res=$(python3 ../common/compare_json.py "$targetJson" "$body") |
| 405 | |
| 406 | if [ $res -ne 0 ]; then |
| 407 | echo -e $RED" FAIL, returned body not correct"$ERED |
| 408 | ((RES_FAIL++)) |
| 409 | __check_stop_at_error |
| 410 | return 1 |
| 411 | fi |
| 412 | fi |
| 413 | |
BjornMagnussonXA | bf3700b | 2020-10-05 08:39:40 +0200 | [diff] [blame] | 414 | ((RES_PASS++)) |
| 415 | echo -e $GREEN" PASS"$EGREEN |
| 416 | return 0 |
| 417 | } |
| 418 | |
| 419 | # API Test function: GET /ei-producer/v1/eiproducers/{eiProducerId}/status |
BjornMagnussonXA | f38e1e8 | 2020-10-11 23:05:02 +0200 | [diff] [blame] | 420 | # args: <response-code> <producer-id> [<status>] |
BjornMagnussonXA | bf3700b | 2020-10-05 08:39:40 +0200 | [diff] [blame] | 421 | # (Function for test scripts) |
| 422 | ecs_api_edp_get_producer_status() { |
| 423 | echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD |
| 424 | echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG |
| 425 | ((RES_TEST++)) |
| 426 | |
BjornMagnussonXA | f38e1e8 | 2020-10-11 23:05:02 +0200 | [diff] [blame] | 427 | if [ $# -lt 2 ] || [ $# -gt 3 ]; then |
| 428 | __print_err "<response-code> <producer-id> <status>" $@ |
BjornMagnussonXA | bf3700b | 2020-10-05 08:39:40 +0200 | [diff] [blame] | 429 | return 1 |
| 430 | fi |
| 431 | |
BjornMagnussonXA | f38e1e8 | 2020-10-11 23:05:02 +0200 | [diff] [blame] | 432 | query="/ei-producer/v1/eiproducers/$2/status" |
| 433 | res="$(__do_curl_to_api ECS GET $query)" |
| 434 | status=${res:${#res}-3} |
| 435 | |
| 436 | if [ $status -ne $1 ]; then |
| 437 | echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED |
| 438 | ((RES_FAIL++)) |
| 439 | __check_stop_at_error |
| 440 | return 1 |
| 441 | fi |
| 442 | if [ $# -eq 3 ]; then |
| 443 | body=${res:0:${#res}-3} |
| 444 | targetJson="{\"operational_state\": \"$3\"}" |
| 445 | echo " TARGET JSON: $targetJson" >> $HTTPLOG |
| 446 | res=$(python3 ../common/compare_json.py "$targetJson" "$body") |
| 447 | |
| 448 | if [ $res -ne 0 ]; then |
| 449 | echo -e $RED" FAIL, returned body not correct"$ERED |
| 450 | ((RES_FAIL++)) |
| 451 | __check_stop_at_error |
| 452 | return 1 |
| 453 | fi |
| 454 | fi |
| 455 | |
BjornMagnussonXA | bf3700b | 2020-10-05 08:39:40 +0200 | [diff] [blame] | 456 | ((RES_PASS++)) |
| 457 | echo -e $GREEN" PASS"$EGREEN |
| 458 | return 0 |
| 459 | } |
| 460 | |
| 461 | |
| 462 | # API Test function: GET /ei-producer/v1/eiproducers |
BjornMagnussonXA | f38e1e8 | 2020-10-11 23:05:02 +0200 | [diff] [blame] | 463 | # args: <response-code> [ EMPTY | <producer-id>+] |
BjornMagnussonXA | bf3700b | 2020-10-05 08:39:40 +0200 | [diff] [blame] | 464 | # (Function for test scripts) |
| 465 | ecs_api_edp_get_producer_ids() { |
| 466 | echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD |
| 467 | echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG |
| 468 | ((RES_TEST++)) |
| 469 | |
| 470 | if [ $# -lt 1 ]; then |
BjornMagnussonXA | f38e1e8 | 2020-10-11 23:05:02 +0200 | [diff] [blame] | 471 | __print_err "<response-code> [ EMPTY | <producer-id>+]" $@ |
BjornMagnussonXA | bf3700b | 2020-10-05 08:39:40 +0200 | [diff] [blame] | 472 | return 1 |
| 473 | fi |
| 474 | |
| 475 | query="/ei-producer/v1/eiproducers" |
| 476 | res="$(__do_curl_to_api ECS GET $query)" |
| 477 | status=${res:${#res}-3} |
| 478 | |
| 479 | if [ $status -ne $1 ]; then |
| 480 | echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED |
| 481 | ((RES_FAIL++)) |
| 482 | __check_stop_at_error |
| 483 | return 1 |
| 484 | fi |
| 485 | |
| 486 | if [ $# -gt 1 ]; then |
| 487 | body=${res:0:${#res}-3} |
| 488 | targetJson="[" |
| 489 | |
| 490 | for pid in ${@:2} ; do |
| 491 | if [ "$targetJson" != "[" ]; then |
| 492 | targetJson=$targetJson"," |
| 493 | fi |
BjornMagnussonXA | f38e1e8 | 2020-10-11 23:05:02 +0200 | [diff] [blame] | 494 | if [ $pid != "EMPTY" ]; then |
BjornMagnussonXA | bf3700b | 2020-10-05 08:39:40 +0200 | [diff] [blame] | 495 | targetJson=$targetJson"\"$pid\"" |
| 496 | fi |
| 497 | done |
| 498 | |
| 499 | targetJson=$targetJson"]" |
BjornMagnussonXA | f38e1e8 | 2020-10-11 23:05:02 +0200 | [diff] [blame] | 500 | echo " TARGET JSON: $targetJson" >> $HTTPLOG |
BjornMagnussonXA | bf3700b | 2020-10-05 08:39:40 +0200 | [diff] [blame] | 501 | res=$(python3 ../common/compare_json.py "$targetJson" "$body") |
| 502 | |
| 503 | if [ $res -ne 0 ]; then |
| 504 | echo -e $RED" FAIL, returned body not correct"$ERED |
| 505 | ((RES_FAIL++)) |
| 506 | __check_stop_at_error |
| 507 | return 1 |
| 508 | fi |
| 509 | fi |
| 510 | |
| 511 | ((RES_PASS++)) |
| 512 | echo -e $GREEN" PASS"$EGREEN |
| 513 | return 0 |
| 514 | } |
| 515 | |
| 516 | # API Test function: GET /ei-producer/v1/eitypes/{eiTypeId} |
BjornMagnussonXA | f38e1e8 | 2020-10-11 23:05:02 +0200 | [diff] [blame] | 517 | # args: <response-code> <type-id> [<job-schema-file> (NOID | [<producer-id>]+)] |
BjornMagnussonXA | bf3700b | 2020-10-05 08:39:40 +0200 | [diff] [blame] | 518 | # (Function for test scripts) |
| 519 | ecs_api_edp_get_type() { |
| 520 | echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD |
| 521 | echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG |
| 522 | ((RES_TEST++)) |
| 523 | |
BjornMagnussonXA | f38e1e8 | 2020-10-11 23:05:02 +0200 | [diff] [blame] | 524 | paramError=1 |
| 525 | if [ $# -eq 2 ]; then |
| 526 | paramError=0 |
| 527 | fi |
| 528 | if [ $# -gt 3 ]; then |
| 529 | paramError=0 |
| 530 | fi |
| 531 | if [ $paramError -ne 0 ]; then |
| 532 | __print_err "<response-code> <type-id> [<job-schema-file> NOID | ([<producer-id>]+)]" $@ |
BjornMagnussonXA | bf3700b | 2020-10-05 08:39:40 +0200 | [diff] [blame] | 533 | return 1 |
| 534 | fi |
| 535 | |
BjornMagnussonXA | f38e1e8 | 2020-10-11 23:05:02 +0200 | [diff] [blame] | 536 | query="/ei-producer/v1/eitypes/$2" |
| 537 | res="$(__do_curl_to_api ECS GET $query)" |
| 538 | status=${res:${#res}-3} |
| 539 | |
| 540 | if [ $status -ne $1 ]; then |
| 541 | echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED |
| 542 | ((RES_FAIL++)) |
| 543 | __check_stop_at_error |
| 544 | return 1 |
| 545 | fi |
| 546 | if [ $# -gt 3 ]; then |
| 547 | body=${res:0:${#res}-3} |
| 548 | |
| 549 | if [ -f $3 ]; then |
| 550 | schema=$(cat $3) |
| 551 | else |
| 552 | echo -e $RED" FAIL. Job template file "$3", does not exist"$ERED |
| 553 | ((RES_FAIL++)) |
| 554 | __check_stop_at_error |
| 555 | return 1 |
| 556 | fi |
| 557 | |
| 558 | targetJson="" |
| 559 | if [ $4 != "EMPTY" ]; then |
| 560 | for pid in ${@:4} ; do |
| 561 | if [ "$targetJson" != "" ]; then |
| 562 | targetJson=$targetJson"," |
| 563 | fi |
| 564 | targetJson=$targetJson"\"$pid\"" |
| 565 | done |
| 566 | fi |
| 567 | targetJson="{\"ei_job_data_schema\":$schema, \"ei_producer_ids\": [$targetJson]}" |
| 568 | |
| 569 | echo " TARGET JSON: $targetJson" >> $HTTPLOG |
| 570 | res=$(python3 ../common/compare_json.py "$targetJson" "$body") |
| 571 | |
| 572 | if [ $res -ne 0 ]; then |
| 573 | echo -e $RED" FAIL, returned body not correct"$ERED |
| 574 | ((RES_FAIL++)) |
| 575 | __check_stop_at_error |
| 576 | return 1 |
| 577 | fi |
| 578 | fi |
BjornMagnussonXA | bf3700b | 2020-10-05 08:39:40 +0200 | [diff] [blame] | 579 | ((RES_PASS++)) |
| 580 | echo -e $GREEN" PASS"$EGREEN |
| 581 | return 0 |
| 582 | } |
| 583 | |
| 584 | # API Test function: GET /ei-producer/v1/eiproducers/{eiProducerId} |
BjornMagnussonXA | f38e1e8 | 2020-10-11 23:05:02 +0200 | [diff] [blame] | 585 | # args: <response-code> <producer-id> [<create-callback> <delete-callback> <supervision-callback> (EMPTY | [<type-id> <schema-file>]+) ] |
BjornMagnussonXA | bf3700b | 2020-10-05 08:39:40 +0200 | [diff] [blame] | 586 | # (Function for test scripts) |
| 587 | ecs_api_edp_get_producer() { |
| 588 | echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD |
| 589 | echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG |
| 590 | ((RES_TEST++)) |
| 591 | |
BjornMagnussonXA | f38e1e8 | 2020-10-11 23:05:02 +0200 | [diff] [blame] | 592 | #Possible arg count: 2, 6 7, 9, 11 etc |
| 593 | paramError=1 |
| 594 | if [ $# -eq 2 ]; then |
| 595 | paramError=0 |
| 596 | fi |
| 597 | if [ $# -eq 6 ] && [ "$6" == "EMPTY" ]; then |
| 598 | paramError=0 |
| 599 | fi |
| 600 | variablecount=$(($#-5)) |
| 601 | if [ $# -gt 5 ] && [ $(($variablecount%2)) -eq 0 ]; then |
| 602 | paramError=0 |
| 603 | fi |
| 604 | |
| 605 | if [ $paramError -ne 0 ]; then |
| 606 | __print_err "<response-code> <producer-id> [<create-callback> <delete-callback> <supervision-callback> (NOID | [<type-id> <schema-file>]+) ]" $@ |
BjornMagnussonXA | bf3700b | 2020-10-05 08:39:40 +0200 | [diff] [blame] | 607 | return 1 |
| 608 | fi |
| 609 | |
BjornMagnussonXA | f38e1e8 | 2020-10-11 23:05:02 +0200 | [diff] [blame] | 610 | query="/ei-producer/v1/eiproducers/$2" |
| 611 | res="$(__do_curl_to_api ECS GET $query)" |
| 612 | status=${res:${#res}-3} |
| 613 | |
| 614 | if [ $status -ne $1 ]; then |
| 615 | echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED |
| 616 | ((RES_FAIL++)) |
| 617 | __check_stop_at_error |
| 618 | return 1 |
| 619 | fi |
| 620 | |
| 621 | if [ $# -gt 2 ]; then |
| 622 | body=${res:0:${#res}-3} |
| 623 | targetJson="[" |
| 624 | if [ $# -gt 6 ]; then |
| 625 | arr=(${@:6}) |
| 626 | for ((i=0; i<$(($#-6)); i=i+2)); do |
| 627 | if [ "$targetJson" != "[" ]; then |
| 628 | targetJson=$targetJson"," |
| 629 | fi |
| 630 | if [ -f ${arr[$i+1]} ]; then |
| 631 | schema=$(cat ${arr[$i+1]}) |
| 632 | else |
| 633 | echo -e $RED" FAIL. Schema file "${arr[$i+1]}", does not exist"$ERED |
| 634 | ((RES_FAIL++)) |
| 635 | __check_stop_at_error |
| 636 | return 1 |
| 637 | fi |
| 638 | |
| 639 | targetJson=$targetJson"{\"ei_type_identity\":\"${arr[$i]}\",\"ei_job_data_schema\":$schema}" |
| 640 | done |
| 641 | fi |
| 642 | targetJson=$targetJson"]" |
| 643 | if [ $# -gt 4 ]; then |
| 644 | targetJson="{\"supported_ei_types\":$targetJson,\"ei_job_creation_callback_url\": \"$3\",\"ei_job_deletion_callback_url\": \"$4\",\"ei_producer_supervision_callback_url\": \"$5\"}" |
| 645 | fi |
| 646 | echo " TARGET JSON: $targetJson" >> $HTTPLOG |
| 647 | res=$(python3 ../common/compare_json.py "$targetJson" "$body") |
| 648 | |
| 649 | if [ $res -ne 0 ]; then |
| 650 | echo -e $RED" FAIL, returned body not correct"$ERED |
| 651 | ((RES_FAIL++)) |
| 652 | __check_stop_at_error |
| 653 | return 1 |
| 654 | fi |
| 655 | fi |
| 656 | |
BjornMagnussonXA | bf3700b | 2020-10-05 08:39:40 +0200 | [diff] [blame] | 657 | ((RES_PASS++)) |
| 658 | echo -e $GREEN" PASS"$EGREEN |
| 659 | return 0 |
| 660 | } |
| 661 | |
| 662 | # API Test function: DELETE /ei-producer/v1/eiproducers/{eiProducerId} |
BjornMagnussonXA | f38e1e8 | 2020-10-11 23:05:02 +0200 | [diff] [blame] | 663 | # args: <response-code> <producer-id> |
BjornMagnussonXA | bf3700b | 2020-10-05 08:39:40 +0200 | [diff] [blame] | 664 | # (Function for test scripts) |
| 665 | ecs_api_edp_delete_producer() { |
| 666 | echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD |
| 667 | echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG |
| 668 | ((RES_TEST++)) |
| 669 | |
BjornMagnussonXA | f38e1e8 | 2020-10-11 23:05:02 +0200 | [diff] [blame] | 670 | if [ $# -lt 2 ]; then |
| 671 | __print_err "<response-code> <producer-id>" $@ |
| 672 | return 1 |
| 673 | fi |
| 674 | |
| 675 | query="/ei-producer/v1/eiproducers/$2" |
| 676 | res="$(__do_curl_to_api ECS DELETE $query)" |
| 677 | status=${res:${#res}-3} |
| 678 | |
| 679 | if [ $status -ne $1 ]; then |
| 680 | echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED |
| 681 | ((RES_FAIL++)) |
| 682 | __check_stop_at_error |
BjornMagnussonXA | bf3700b | 2020-10-05 08:39:40 +0200 | [diff] [blame] | 683 | return 1 |
| 684 | fi |
| 685 | |
| 686 | ((RES_PASS++)) |
| 687 | echo -e $GREEN" PASS"$EGREEN |
| 688 | return 0 |
| 689 | } |
| 690 | |
| 691 | # API Test function: PUT /ei-producer/v1/eiproducers/{eiProducerId} |
BjornMagnussonXA | f38e1e8 | 2020-10-11 23:05:02 +0200 | [diff] [blame] | 692 | # args: <response-code> <producer-id> <create-callback> <delete-callback> <supervision-callback> NOTYPE|[<type-id> <schema-file>]+ |
BjornMagnussonXA | bf3700b | 2020-10-05 08:39:40 +0200 | [diff] [blame] | 693 | # (Function for test scripts) |
| 694 | ecs_api_edp_put_producer() { |
| 695 | echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD |
| 696 | echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG |
| 697 | ((RES_TEST++)) |
| 698 | |
BjornMagnussonXA | f38e1e8 | 2020-10-11 23:05:02 +0200 | [diff] [blame] | 699 | #Valid number of parametrer 6,7,9,11, |
| 700 | paramError=1 |
| 701 | if [ $# -eq 6 ] && [ "$6" == "NOTYPE" ]; then |
| 702 | paramError=0 |
| 703 | elif [ $# -gt 6 ] && [ $(($#%2)) -eq 1 ]; then |
| 704 | paramError=0 |
| 705 | fi |
| 706 | if [ $paramError -ne 0 ]; then |
| 707 | __print_err "<response-code> <producer-id> <create-callback> <delete-callback> <supervision-callback> [<type-id> <schema-file>]+" $@ |
| 708 | return 1 |
| 709 | fi |
| 710 | |
| 711 | inputJson="[" |
| 712 | if [ $# -gt 6 ]; then |
| 713 | arr=(${@:6}) |
| 714 | for ((i=0; i<$(($#-6)); i=i+2)); do |
| 715 | if [ "$inputJson" != "[" ]; then |
| 716 | inputJson=$inputJson"," |
| 717 | fi |
| 718 | if [ -f ${arr[$i+1]} ]; then |
| 719 | schema=$(cat ${arr[$i+1]}) |
| 720 | else |
| 721 | echo -e $RED" FAIL. Schema file "${arr[$i+1]}", does not exist"$ERED |
| 722 | ((RES_FAIL++)) |
| 723 | __check_stop_at_error |
| 724 | return 1 |
| 725 | fi |
| 726 | inputJson=$inputJson"{\"ei_type_identity\":\"${arr[$i]}\",\"ei_job_data_schema\":$schema}" |
| 727 | done |
| 728 | fi |
| 729 | inputJson="\"supported_ei_types\":"$inputJson"]" |
| 730 | |
| 731 | inputJson=$inputJson",\"ei_job_creation_callback_url\": \"$3\",\"ei_job_deletion_callback_url\": \"$4\",\"ei_producer_supervision_callback_url\": \"$5\"" |
| 732 | |
| 733 | inputJson="{"$inputJson"}" |
| 734 | |
| 735 | file="./tmp/.p.json" |
| 736 | echo "$inputJson" > $file |
| 737 | query="/ei-producer/v1/eiproducers/$2" |
| 738 | res="$(__do_curl_to_api ECS PUT $query $file)" |
| 739 | status=${res:${#res}-3} |
| 740 | |
| 741 | if [ $status -ne $1 ]; then |
| 742 | echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED |
| 743 | ((RES_FAIL++)) |
| 744 | __check_stop_at_error |
BjornMagnussonXA | bf3700b | 2020-10-05 08:39:40 +0200 | [diff] [blame] | 745 | return 1 |
| 746 | fi |
| 747 | |
| 748 | ((RES_PASS++)) |
| 749 | echo -e $GREEN" PASS"$EGREEN |
| 750 | return 0 |
| 751 | } |
| 752 | |
| 753 | # API Test function: GET /ei-producer/v1/eiproducers/{eiProducerId}/eijobs |
BjornMagnussonXA | f38e1e8 | 2020-10-11 23:05:02 +0200 | [diff] [blame] | 754 | # args: <response-code> <producer-id> (EMPTY | [<job-id> <type-id> <target-url> <template-job-file>]+) |
BjornMagnussonXA | bf3700b | 2020-10-05 08:39:40 +0200 | [diff] [blame] | 755 | # (Function for test scripts) |
| 756 | ecs_api_edp_get_producer_jobs() { |
| 757 | echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD |
| 758 | echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG |
| 759 | ((RES_TEST++)) |
| 760 | |
BjornMagnussonXA | f38e1e8 | 2020-10-11 23:05:02 +0200 | [diff] [blame] | 761 | #Valid number of parameter 2,3,6,10 |
| 762 | paramError=1 |
| 763 | if [ $# -eq 2 ]; then |
| 764 | paramError=0 |
| 765 | fi |
| 766 | if [ $# -eq 3 ] && [ "$3" == "EMPTY" ]; then |
| 767 | paramError=0 |
| 768 | fi |
| 769 | variablecount=$(($#-2)) |
| 770 | if [ $# -gt 3 ] && [ $(($variablecount%4)) -eq 0 ]; then |
| 771 | paramError=0 |
| 772 | fi |
| 773 | if [ $paramError -eq 1 ]; then |
| 774 | __print_err "<response-code> <producer-id> (EMPTY | [<job-id> <type-id> <target-url> <template-job-file>]+)" $@ |
BjornMagnussonXA | bf3700b | 2020-10-05 08:39:40 +0200 | [diff] [blame] | 775 | return 1 |
| 776 | fi |
| 777 | |
BjornMagnussonXA | f38e1e8 | 2020-10-11 23:05:02 +0200 | [diff] [blame] | 778 | query="/ei-producer/v1/eiproducers/$2/eijobs" |
| 779 | res="$(__do_curl_to_api ECS GET $query)" |
| 780 | status=${res:${#res}-3} |
| 781 | if [ $status -ne $1 ]; then |
| 782 | echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED |
| 783 | ((RES_FAIL++)) |
| 784 | __check_stop_at_error |
BjornMagnussonXA | bf3700b | 2020-10-05 08:39:40 +0200 | [diff] [blame] | 785 | return 1 |
| 786 | fi |
BjornMagnussonXA | f38e1e8 | 2020-10-11 23:05:02 +0200 | [diff] [blame] | 787 | if [ $# -gt 2 ]; then |
| 788 | body=${res:0:${#res}-3} |
| 789 | targetJson="[" |
| 790 | if [ $# -gt 3 ]; then |
| 791 | arr=(${@:3}) |
| 792 | for ((i=0; i<$(($#-3)); i=i+4)); do |
| 793 | if [ "$targetJson" != "[" ]; then |
| 794 | targetJson=$targetJson"," |
| 795 | fi |
| 796 | if [ -f ${arr[$i+3]} ]; then |
| 797 | jobfile=$(cat ${arr[$i+3]}) |
| 798 | jobfile=$(echo "$jobfile" | sed "s/XXXX/${arr[$i]}/g") |
| 799 | else |
| 800 | echo -e $RED" FAIL. Job template file "${arr[$i+3]}", does not exist"$ERED |
| 801 | ((RES_FAIL++)) |
| 802 | __check_stop_at_error |
| 803 | return 1 |
| 804 | fi |
| 805 | targetJson=$targetJson"{\"ei_job_identity\":\"${arr[$i]}\",\"ei_type_identity\":\"${arr[$i+1]}\",\"target_uri\":\"${arr[$i+2]}\",\"ei_job_data\":$jobfile}" |
| 806 | done |
| 807 | fi |
| 808 | targetJson=$targetJson"]" |
BjornMagnussonXA | bf3700b | 2020-10-05 08:39:40 +0200 | [diff] [blame] | 809 | |
BjornMagnussonXA | f38e1e8 | 2020-10-11 23:05:02 +0200 | [diff] [blame] | 810 | echo " TARGET JSON: $targetJson" >> $HTTPLOG |
| 811 | res=$(python3 ../common/compare_json.py "$targetJson" "$body") |
BjornMagnussonXA | bf3700b | 2020-10-05 08:39:40 +0200 | [diff] [blame] | 812 | |
BjornMagnussonXA | f38e1e8 | 2020-10-11 23:05:02 +0200 | [diff] [blame] | 813 | if [ $res -ne 0 ]; then |
| 814 | echo -e $RED" FAIL, returned body not correct"$ERED |
| 815 | ((RES_FAIL++)) |
| 816 | __check_stop_at_error |
| 817 | return 1 |
| 818 | fi |
BjornMagnussonXA | bf3700b | 2020-10-05 08:39:40 +0200 | [diff] [blame] | 819 | fi |
| 820 | |
| 821 | ((RES_PASS++)) |
| 822 | echo -e $GREEN" PASS"$EGREEN |
| 823 | return 0 |
| 824 | } |
| 825 | |
| 826 | |
| 827 | ########################################## |
| 828 | #### Service status #### |
| 829 | ########################################## |
| 830 | # Function prefix: ecs_api_service |
| 831 | |
| 832 | # API Test function: GET /status |
| 833 | # args: <response-code> |
| 834 | # (Function for test scripts) |
| 835 | ecs_api_service_status() { |
| 836 | echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD |
| 837 | echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG |
| 838 | ((RES_TEST++)) |
| 839 | |
| 840 | if [ $# -lt 1 ]; then |
| 841 | __print_err "<response-code> [<producer-id>]*|NOID" $@ |
| 842 | return 1 |
| 843 | fi |
| 844 | |
| 845 | ((RES_PASS++)) |
| 846 | echo -e $GREEN" PASS"$EGREEN |
| 847 | return 0 |
| 848 | } |