X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=test%2Fcommon%2Fics_api_functions.sh;h=9a80bccb7498f4bd1044c54423b135696e9343d7;hb=9ddce2b0e23655371aa311c94ce9605dcc74f74e;hp=ea4036dad3cc3b2cb6758efbcb5e0bb1b9fcbfe3;hpb=007b64509101d8e3ef881955adee2ad15d062213;p=nonrtric.git diff --git a/test/common/ics_api_functions.sh b/test/common/ics_api_functions.sh index ea4036da..9a80bccb 100644 --- a/test/common/ics_api_functions.sh +++ b/test/common/ics_api_functions.sh @@ -1,7 +1,7 @@ #!/bin/bash # ============LICENSE_START=============================================== -# Copyright (C) 2020 Nordix Foundation. All rights reserved. +# Copyright (C) 2020-2023 Nordix Foundation. All rights reserved. # ======================================================================== # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -25,7 +25,7 @@ # arg: (selects staging, snapshot, release etc) # is present only for images with staging, snapshot,release tags __ICS_imagesetup() { - __check_and_create_image_var ICS "ICS_IMAGE" "ICS_IMAGE_BASE" "ICS_IMAGE_TAG" $1 "$ICS_DISPLAY_NAME" + __check_and_create_image_var ICS "ICS_IMAGE" "ICS_IMAGE_BASE" "ICS_IMAGE_TAG" $1 "$ICS_DISPLAY_NAME" "" } # Pull image from remote repo or use locally built image @@ -62,12 +62,12 @@ __ICS_kube_scale_zero() { } # Scale kubernetes resources to zero and wait until this has been accomplished, if relevant. If not relevant to scale, then do no action. -# This function is called for prestarted apps not managed by the test script. +# This function is called for pre-started apps not managed by the test script. __ICS_kube_scale_zero_and_wait() { __kube_scale_and_wait_all_resources $KUBE_NONRTRIC_NAMESPACE app "$KUBE_NONRTRIC_NAMESPACE"-informationservice } -# Delete all kube resouces for the app +# Delete all kube resources for the app # This function is called for apps managed by the test script. __ICS_kube_delete_all() { __kube_delete_all_resources $KUBE_NONRTRIC_NAMESPACE autotest ICS @@ -75,10 +75,10 @@ __ICS_kube_delete_all() { # Store docker logs # This function is called for apps managed by the test script. -# args: +# args: __ICS_store_docker_logs() { if [ $RUNMODE == "KUBE" ]; then - kubectl logs -l "autotest=ICS" -n $KUBE_NONRTRIC_NAMESPACE --tail=-1 > $1$2_ics.log 2>&1 + kubectl $KUBECONF logs -l "autotest=ICS" -n $KUBE_NONRTRIC_NAMESPACE --tail=-1 > $1$2_ics.log 2>&1 else docker logs $ICS_APP_NAME > $1$2_ics.log 2>&1 fi @@ -89,13 +89,14 @@ __ICS_store_docker_logs() { # args: - __ICS_initial_setup() { use_ics_rest_http + export ICS_SIDECAR_JWT_FILE="" } -# Set app short-name, app name and namespace for logging runtime statistics of kubernets pods or docker containers +# Set app short-name, app name and namespace for logging runtime statistics of kubernetes pods or docker containers # For docker, the namespace shall be excluded -# This function is called for apps managed by the test script as well as for prestarted apps. +# This function is called for apps managed by the test script as well as for pre-started apps. # args: - -__ICS_statisics_setup() { +__ICS_statistics_setup() { if [ $RUNMODE == "KUBE" ]; then echo "ICS $ICS_APP_NAME $KUBE_NONRTRIC_NAMESPACE" else @@ -103,6 +104,12 @@ __ICS_statisics_setup() { fi } +# Check application requirements, e.g. helm, the the test needs. Exit 1 if req not satisfied +# args: - +__ICS_test_requirements() { + : +} + ####################################################### @@ -180,12 +187,13 @@ __ics_export_vars() { export ICS_CONFIG_FILE export DOCKER_SIM_NWNAME export ICS_DISPLAY_NAME - + export ICS_LOGPATH export ICS_DATA_PV_NAME=$ICS_APP_NAME"-pv" export ICS_DATA_PVC_NAME=$ICS_APP_NAME"-pvc" #Create a unique path for the pv each time to prevent a previous volume to be reused export ICS_PV_PATH="icsdata-"$(date +%s) + export HOST_PATH_BASE_DIR if [ $1 == "PROXY" ]; then export ICS_HTTP_PROXY_CONFIG_PORT=$HTTP_PROXY_CONFIG_PORT #Set if proxy is started @@ -216,7 +224,7 @@ start_ics() { __check_included_image "ICS" retcode_i=$? - # Check if app shall only be used by the testscipt + # Check if app shall only be used by the test script __check_prestarted_image "ICS" retcode_p=$? @@ -231,7 +239,6 @@ start_ics() { exit fi - if [ $retcode_p -eq 0 ]; then echo -e " Using existing $ICS_APP_NAME deployment and service" echo " Setting ICS replicas=1" @@ -272,6 +279,10 @@ start_ics() { # Create app input_yaml=$SIM_GROUP"/"$ICS_COMPOSE_DIR"/"app.yaml output_yaml=$PWD/tmp/ics_app.yaml + if [ -z "$ICS_SIDECAR_JWT_FILE" ]; then + cat $input_yaml | sed '/#ICS_JWT_START/,/#ICS_JWT_STOP/d' > $PWD/tmp/ics_app_tmp.yaml + input_yaml=$PWD/tmp/ics_app_tmp.yaml + fi __kube_create_instance app $ICS_APP_NAME $input_yaml $output_yaml fi @@ -280,7 +291,7 @@ start_ics() { # Keep the initial worker node in case the pod need to be "restarted" - must be made to the same node due to a volume mounted on the host if [ $retcode_i -eq 0 ]; then - __ICS_WORKER_NODE=$(kubectl get pod -l "autotest=ICS" -n $KUBE_NONRTRIC_NAMESPACE -o jsonpath='{.items[*].spec.nodeName}') + __ICS_WORKER_NODE=$(kubectl $KUBECONF get pod -l "autotest=ICS" -n $KUBE_NONRTRIC_NAMESPACE -o jsonpath='{.items[*].spec.nodeName}') if [ -z "$__ICS_WORKER_NODE" ]; then echo -e $YELLOW" Cannot find worker node for pod for $ICS_APP_NAME, persistency may not work"$EYELLOW fi @@ -315,6 +326,7 @@ start_ics() { fi else echo " No files in mounted dir or dir does not exists" + mkdir db fi cd $curdir @@ -352,7 +364,7 @@ stop_ics() { __kube_scale_all_resources $KUBE_NONRTRIC_NAMESPACE autotest ICS echo " Deleting the replica set - a new will be started when the app is started" - tmp=$(kubectl delete rs -n $KUBE_NONRTRIC_NAMESPACE -l "autotest=ICS") + tmp=$(kubectl $KUBECONF delete rs -n $KUBE_NONRTRIC_NAMESPACE -l "autotest=ICS") if [ $? -ne 0 ]; then echo -e $RED" Could not delete replica set "$RED ((RES_CONF_FAIL++)) @@ -389,16 +401,16 @@ start_stopped_ics() { return 0 fi - # Tie the PMS to the same worker node it was initially started on - # A PVC of type hostPath is mounted to PMS, for persistent storage, so the PMS must always be on the node which mounted the volume + # Tie the ICS to the same worker node it was initially started on + # A PVC of type hostPath is mounted to A1PMS, for persistent storage, so the A1PMS must always be on the node which mounted the volume if [ -z "$__ICS_WORKER_NODE" ]; then echo -e $RED" No initial worker node found for pod "$RED ((RES_CONF_FAIL++)) return 1 else - echo -e $BOLD" Setting nodeSelector kubernetes.io/hostname=$__ICS_WORKER_NODE to deployment for $ICS_APP_NAME. Pod will always run on this worker node: $__PA_WORKER_NODE"$BOLD + echo -e $BOLD" Setting nodeSelector kubernetes.io/hostname=$__ICS_WORKER_NODE to deployment for $ICS_APP_NAME. Pod will always run on this worker node: $__ICS_WORKER_NODE"$BOLD echo -e $BOLD" The mounted volume is mounted as hostPath and only available on that worker node."$BOLD - tmp=$(kubectl patch deployment $ICS_APP_NAME -n $KUBE_NONRTRIC_NAMESPACE --patch '{"spec": {"template": {"spec": {"nodeSelector": {"kubernetes.io/hostname": "'$__ICS_WORKER_NODE'"}}}}}') + tmp=$(kubectl $KUBECONF patch deployment $ICS_APP_NAME -n $KUBE_NONRTRIC_NAMESPACE --patch '{"spec": {"template": {"spec": {"nodeSelector": {"kubernetes.io/hostname": "'$__ICS_WORKER_NODE'"}}}}}') if [ $? -ne 0 ]; then echo -e $YELLOW" Cannot set nodeSelector to deployment for $ICS_APP_NAME, persistency may not work"$EYELLOW fi @@ -442,7 +454,7 @@ set_ics_debug() { # (Function for test scripts) set_ics_trace() { echo -e $BOLD"Setting ics trace logging"$EBOLD - curlString="$ICS_SERVICE_PATH/actuator/loggers/org.oransc.information -X POST -H Content-Type:application/json -d {\"configuredLevel\":\"trace\"}" + curlString="$ICS_SERVICE_PATH$ICS_ACTUATOR -X POST -H Content-Type:application/json -d {\"configuredLevel\":\"trace\"}" result=$(__do_curl "$curlString") if [ $? -ne 0 ]; then __print_err "Could not set trace mode" $@ @@ -493,43 +505,29 @@ ics_equal() { #Function prefix: ics_api_a1 # API Test function: GET /A1-EI​/v1​/eitypes​/{eiTypeId}​/eijobs -# args: |NOOWNER [ EMPTY | + ] -# args (flat uri structure): |NOTYPE |NOOWNER [ EMPTY | + ] +# args: |NOTYPE |NOOWNER [ EMPTY | + ] # (Function for test scripts) ics_api_a1_get_job_ids() { __log_test_start $@ - if [ -z "$FLAT_A1_EI" ]; then - # Valid number of parameters 4,5,6 etc - if [ $# -lt 3 ]; then - __print_err " |NOOWNER [ EMPTY | + ]" $@ - return 1 - fi - else - echo -e $YELLOW"INTERFACE - FLAT URI STRUCTURE"$EYELLOW - # Valid number of parameters 4,5,6 etc - if [ $# -lt 3 ]; then - __print_err " |NOTYPE |NOOWNER [ EMPTY | + ]" $@ - return 1 - fi + # Valid number of parameters 4,5,6 etc + if [ $# -lt 3 ]; then + __print_err " |NOTYPE |NOOWNER [ EMPTY | + ]" $@ + return 1 fi search="" if [ $3 != "NOWNER" ]; then search="?owner="$3 fi - if [ -z "$FLAT_A1_EI" ]; then - query="/A1-EI/v1/eitypes/$2/eijobs$search" - else - if [ $2 != "NOTYPE" ]; then - if [ -z "$search" ]; then - search="?eiTypeId="$2 - else - search=$search"&eiTypeId="$2 - fi + if [ $2 != "NOTYPE" ]; then + if [ -z "$search" ]; then + search="?eiTypeId="$2 + else + search=$search"&eiTypeId="$2 fi - query="/A1-EI/v1/eijobs$search" fi + query="/A1-EI/v1/eijobs$search" res="$(__do_curl_to_api ICS GET $query)" status=${res:${#res}-3} @@ -593,11 +591,7 @@ ics_api_a1_get_type() { __log_test_fail_general "Schema file "$3", does not exist" return 1 fi - if [ -z "$FLAT_A1_EI" ]; then - targetJson="{\"eiJobParametersSchema\":$schema}" - else - targetJson=$schema - fi + targetJson=$schema echo " TARGET JSON: $targetJson" >> $HTTPLOG res=$(python3 ../common/compare_json.py "$targetJson" "$body") @@ -656,121 +650,81 @@ ics_api_a1_get_type_ids() { } # API Test function: GET ​/A1-EI​/v1​/eitypes​/{eiTypeId}​/eijobs​/{eiJobId}​/status -# args: [] -# args (flat uri structure): [ []] +# args: [ []] # (Function for test scripts) ics_api_a1_get_job_status() { __log_test_start $@ - if [ -z "$FLAT_A1_EI" ]; then - if [ $# -ne 3 ] && [ $# -ne 4 ]; then - __print_err " []" $@ - return 1 - fi + if [ $# -lt 2 ] && [ $# -gt 4 ]; then + __print_err " [ []]" $@ + return 1 + fi - query="/A1-EI/v1/eitypes/$2/eijobs/$3/status" + query="/A1-EI/v1/eijobs/$2/status" + start=$SECONDS + for (( ; ; )); do res="$(__do_curl_to_api ICS GET $query)" status=${res:${#res}-3} + if [ $# -eq 4 ]; then + duration=$((SECONDS-start)) + echo -ne " Response=${status} after ${duration} seconds, waiting for ${3} ${SAMELINE}" + if [ $duration -gt $4 ]; then + echo "" + duration=-1 #Last iteration + fi + else + duration=-1 #single test, no wait + fi + if [ $status -ne $1 ]; then - __log_test_fail_status_code $1 $status - return 1 + if [ $duration -eq -1 ]; then + __log_test_fail_status_code $1 $status + return 1 + fi fi - if [ $# -eq 4 ]; then + if [ $# -ge 3 ] && [ $status -eq $1 ]; then body=${res:0:${#res}-3} - targetJson="{\"operationalState\": \"$4\"}" + targetJson="{\"eiJobStatus\": \"$3\"}" echo " TARGET JSON: $targetJson" >> $HTTPLOG res=$(python3 ../common/compare_json.py "$targetJson" "$body") if [ $res -ne 0 ]; then - __log_test_fail_body - return 1 - fi - fi - else - echo -e $YELLOW"INTERFACE - FLAT URI STRUCTURE"$EYELLOW - if [ $# -lt 2 ] && [ $# -gt 4 ]; then - __print_err " [ []]" $@ - return 1 - fi - - query="/A1-EI/v1/eijobs/$2/status" - - start=$SECONDS - for (( ; ; )); do - res="$(__do_curl_to_api ICS GET $query)" - status=${res:${#res}-3} - - if [ $# -eq 4 ]; then - duration=$((SECONDS-start)) - echo -ne " Response=${status} after ${duration} seconds, waiting for ${3} ${SAMELINE}" - if [ $duration -gt $4 ]; then - echo "" - duration=-1 #Last iteration - fi - else - duration=-1 #single test, no wait - fi - - if [ $status -ne $1 ]; then if [ $duration -eq -1 ]; then - __log_test_fail_status_code $1 $status + __log_test_fail_body return 1 fi - fi - if [ $# -ge 3 ] && [ $status -eq $1 ]; then - body=${res:0:${#res}-3} - targetJson="{\"eiJobStatus\": \"$3\"}" - echo " TARGET JSON: $targetJson" >> $HTTPLOG - res=$(python3 ../common/compare_json.py "$targetJson" "$body") - - if [ $res -ne 0 ]; then - if [ $duration -eq -1 ]; then - __log_test_fail_body - return 1 - fi - else - duration=-1 #Goto pass - fi - fi - if [ $duration -eq -1 ]; then - if [ $# -eq 4 ]; then - echo "" - fi - __log_test_pass - return 0 else - sleep 1 + duration=-1 #Goto pass fi - done - fi + fi + if [ $duration -eq -1 ]; then + if [ $# -eq 4 ]; then + echo "" + fi + __log_test_pass + return 0 + else + sleep 1 + fi + done __log_test_pass return 0 } # API Test function: GET ​/A1-EI​/v1​/eitypes​/{eiTypeId}​/eijobs​/{eiJobId} -# args: [ ] -# args (flat uri structure): [ ] +# args: [ ] # (Function for test scripts) ics_api_a1_get_job() { __log_test_start $@ - if [ -z "$FLAT_A1_EI" ]; then - if [ $# -ne 3 ] && [ $# -ne 6 ]; then - __print_err " [ ]" $@ - return 1 - fi - query="/A1-EI/v1/eitypes/$2/eijobs/$3" - else - echo -e $YELLOW"INTERFACE - FLAT URI STRUCTURE"$EYELLOW - if [ $# -ne 2 ] && [ $# -ne 7 ]; then - __print_err " [ ]" $@ - return 1 - fi - query="/A1-EI/v1/eijobs/$2" + if [ $# -ne 2 ] && [ $# -ne 7 ]; then + __print_err " [ ]" $@ + return 1 fi + query="/A1-EI/v1/eijobs/$2" res="$(__do_curl_to_api ICS GET $query)" status=${res:${#res}-3} @@ -779,45 +733,23 @@ ics_api_a1_get_job() { return 1 fi - if [ -z "$FLAT_A1_EI" ]; then - if [ $# -eq 6 ]; then - body=${res:0:${#res}-3} - - if [ -f $6 ]; then - jobfile=$(cat $6) - jobfile=$(echo "$jobfile" | sed "s/XXXX/$3/g") - else - __log_test_fail_general "Job template file "$6", does not exist" - return 1 - fi - targetJson="{\"targetUri\": \"$4\",\"jobOwner\": \"$5\",\"jobParameters\": $jobfile}" - echo " TARGET JSON: $targetJson" >> $HTTPLOG - res=$(python3 ../common/compare_json.py "$targetJson" "$body") + if [ $# -eq 7 ]; then + body=${res:0:${#res}-3} - if [ $res -ne 0 ]; then - __log_test_fail_body - return 1 - fi + if [ -f $7 ]; then + jobfile=$(cat $7) + jobfile=$(echo "$jobfile" | sed "s/XXXX/$2/g") + else + __log_test_fail_general "Job template file "$6", does not exist" + return 1 fi - else - if [ $# -eq 7 ]; then - body=${res:0:${#res}-3} - - if [ -f $7 ]; then - jobfile=$(cat $7) - jobfile=$(echo "$jobfile" | sed "s/XXXX/$2/g") - else - __log_test_fail_general "Job template file "$6", does not exist" - return 1 - fi - targetJson="{\"eiTypeId\": \"$3\", \"jobResultUri\": \"$4\",\"jobOwner\": \"$5\",\"jobStatusNotificationUri\": \"$6\",\"jobDefinition\": $jobfile}" - echo " TARGET JSON: $targetJson" >> $HTTPLOG - res=$(python3 ../common/compare_json.py "$targetJson" "$body") + targetJson="{\"eiTypeId\": \"$3\", \"jobResultUri\": \"$4\",\"jobOwner\": \"$5\",\"jobStatusNotificationUri\": \"$6\",\"jobDefinition\": $jobfile}" + echo " TARGET JSON: $targetJson" >> $HTTPLOG + res=$(python3 ../common/compare_json.py "$targetJson" "$body") - if [ $res -ne 0 ]; then - __log_test_fail_body - return 1 - fi + if [ $res -ne 0 ]; then + __log_test_fail_body + return 1 fi fi @@ -826,27 +758,16 @@ ics_api_a1_get_job() { } # API Test function: DELETE ​/A1-EI​/v1​/eitypes​/{eiTypeId}​/eijobs​/{eiJobId} -# args: -# args (flat uri structure): +# args: # (Function for test scripts) ics_api_a1_delete_job() { __log_test_start $@ - if [ -z "$FLAT_A1_EI" ]; then - if [ $# -ne 3 ]; then - __print_err " " $@ - return 1 - fi - - query="/A1-EI/v1/eitypes/$2/eijobs/$3" - else - echo -e $YELLOW"INTERFACE - FLAT URI STRUCTURE"$EYELLOW - if [ $# -ne 2 ]; then - __print_err " " $@ - return 1 - fi - query="/A1-EI/v1/eijobs/$2" + if [ $# -ne 2 ]; then + __print_err " " $@ + return 1 fi + query="/A1-EI/v1/eijobs/$2" res="$(__do_curl_to_api ICS DELETE $query)" status=${res:${#res}-3} @@ -860,50 +781,28 @@ ics_api_a1_delete_job() { } # API Test function: PUT ​/A1-EI​/v1​/eitypes​/{eiTypeId}​/eijobs​/{eiJobId} -# args: -# args (flat uri structure): +# args # (Function for test scripts) ics_api_a1_put_job() { __log_test_start $@ - if [ -z "$FLAT_A1_EI" ]; then - if [ $# -lt 6 ]; then - __print_err " " $@ - return 1 - fi - if [ -f $6 ]; then - jobfile=$(cat $6) - jobfile=$(echo "$jobfile" | sed "s/XXXX/$3/g") - else - __log_test_fail_general "Job template file "$6", does not exist" - return 1 - fi - - inputJson="{\"targetUri\": \"$4\",\"jobOwner\": \"$5\",\"jobParameters\": $jobfile}" - file="./tmp/.p.json" - echo "$inputJson" > $file - - query="/A1-EI/v1/eitypes/$2/eijobs/$3" + if [ $# -lt 7 ]; then + __print_err " " $@ + return 1 + fi + if [ -f $7 ]; then + jobfile=$(cat $7) + jobfile=$(echo "$jobfile" | sed "s/XXXX/$2/g") else - echo -e $YELLOW"INTERFACE - FLAT URI STRUCTURE"$EYELLOW - if [ $# -lt 7 ]; then - __print_err " " $@ - return 1 - fi - if [ -f $7 ]; then - jobfile=$(cat $7) - jobfile=$(echo "$jobfile" | sed "s/XXXX/$2/g") - else - __log_test_fail_general "Job template file "$7", does not exist" - return 1 - fi + __log_test_fail_general "Job template file "$7", does not exist" + return 1 + fi - inputJson="{\"eiTypeId\": \"$3\", \"jobResultUri\": \"$4\",\"jobOwner\": \"$5\",\"jobStatusNotificationUri\": \"$6\",\"jobDefinition\": $jobfile}" - file="./tmp/.p.json" - echo "$inputJson" > $file + inputJson="{\"eiTypeId\": \"$3\", \"jobResultUri\": \"$4\",\"jobOwner\": \"$5\",\"jobStatusNotificationUri\": \"$6\",\"jobDefinition\": $jobfile}" + file="./tmp/.p.json" + echo "$inputJson" > $file - query="/A1-EI/v1/eijobs/$2" - fi + query="/A1-EI/v1/eijobs/$2" res="$(__do_curl_to_api ICS PUT $query $file)" status=${res:${#res}-3} @@ -934,11 +833,7 @@ ics_api_edp_get_type_ids() { __print_err " [ EMPTY | +]" $@ return 1 fi - if [[ "$ICS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then - query="/data-producer/v1/info-types" - else - query="/ei-producer/v1/eitypes" - fi + query="/data-producer/v1/info-types" res="$(__do_curl_to_api ICS GET $query)" status=${res:${#res}-3} @@ -983,11 +878,7 @@ ics_api_edp_get_producer_status() { __print_err " [ []]" $@ return 1 fi - if [[ "$ICS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then - query="/data-producer/v1/info-producers/$2/status" - else - query="/ei-producer/v1/eiproducers/$2/status" - fi + query="/data-producer/v1/info-producers/$2/status" start=$SECONDS for (( ; ; )); do res="$(__do_curl_to_api ICS GET $query)" @@ -1096,16 +987,10 @@ ics_api_edp_get_producer_ids_2() { __print_err " [ ( NOTYPE | ) [ EMPTY | +] ]" $@ return 1 fi - if [[ "$ICS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then - query="/data-producer/v1/info-producers" - if [ $# -gt 1 ] && [ $2 != "NOTYPE" ]; then - query=$query"?info_type_id=$2" - fi - else - query="/ei-producer/v1/eiproducers" - if [ $# -gt 1 ] && [ $2 != "NOTYPE" ]; then - query=$query"?ei_type_id=$2" - fi + query="/data-producer/v1/info-producers" + if [ $# -gt 1 ] && [ $2 != "NOTYPE" ]; then + query=$query"?info_type_id=$2&infoTypeId=$2" #info_type_id changed to infoTypeId in F-release. + #Remove info_type_id when F-release is no longer supported fi res="$(__do_curl_to_api ICS GET $query)" status=${res:${#res}-3} @@ -1215,20 +1100,14 @@ ics_api_edp_get_type_2() { if [ $# -eq 3 ]; then paramError=0 fi - if [[ "$ICS_FEATURE_LEVEL" == *"INFO-TYPE-INFO"* ]]; then - if [ $# -eq 4 ]; then - paramError=0 - fi + if [ $# -eq 4 ]; then + paramError=0 fi if [ $paramError -ne 0 ]; then __print_err " [ [ ]]" $@ return 1 fi - if [[ "$ICS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then - query="/data-producer/v1/info-types/$2" - else - query="/ei-producer/v1/eitypes/$2" - fi + query="/data-producer/v1/info-types/$2" res="$(__do_curl_to_api ICS GET $query)" status=${res:${#res}-3} @@ -1256,11 +1135,7 @@ ics_api_edp_get_type_2() { fi info_data=",\"info_type_information\":$info_data" fi - if [[ "$ICS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then - targetJson="{\"info_job_data_schema\":$schema $info_data}" - else - targetJson="{\"ei_job_data_schema\":$schema}" - fi + targetJson="{\"info_job_data_schema\":$schema $info_data}" echo " TARGET JSON: $targetJson" >> $HTTPLOG res=$(python3 ../common/compare_json.py "$targetJson" "$body") @@ -1281,16 +1156,9 @@ ics_api_edp_get_type_2() { ics_api_edp_put_type_2() { __log_test_start $@ - if [[ "$ICS_FEATURE_LEVEL" == *"INFO-TYPE-INFO"* ]]; then - if [ $# -lt 3 ] || [ $# -gt 4 ]; then - __print_err " [ ]" $@ - return 1 - fi - else - if [ $# -ne 3 ]; then - __print_err " " $@ - return 1 - fi + if [ $# -lt 3 ] || [ $# -gt 4 ]; then + __print_err " [ ]" $@ + return 1 fi if [ ! -f $3 ]; then @@ -1309,21 +1177,12 @@ ics_api_edp_put_type_2() { info_data=",\"info_type_information\":$info_data" fi - if [[ "$ICS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then - schema=$(cat $3) - input_json="{\"info_job_data_schema\":$schema $info_data}" - file="./tmp/put_type.json" - echo $input_json > $file - - query="/data-producer/v1/info-types/$2" - else - schema=$(cat $3) - input_json="{\"ei_job_data_schema\":$schema}" - file="./tmp/put_type.json" - echo $input_json > $file + schema=$(cat $3) + input_json="{\"info_job_data_schema\":$schema $info_data}" + file="./tmp/put_type.json" + echo $input_json > $file - query="/ei-producer/v1/eitypes/$2" - fi + query="/data-producer/v1/info-types/$2" res="$(__do_curl_to_api ICS PUT $query $file)" status=${res:${#res}-3} @@ -1348,11 +1207,7 @@ ics_api_edp_delete_type_2() { return 1 fi - if [[ "$ICS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then - query="/data-producer/v1/info-types/$2" - else - query="/ei-producer/v1/eitypes/$2" - fi + query="/data-producer/v1/info-types/$2" res="$(__do_curl_to_api ICS DELETE $query)" status=${res:${#res}-3} @@ -1457,11 +1312,7 @@ ics_api_edp_get_producer_2() { __print_err " [ (EMPTY | +) ]" $@ return 1 fi - if [[ "$ICS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then - query="/data-producer/v1/info-producers/$2" - else - query="/ei-producer/v1/eiproducers/$2" - fi + query="/data-producer/v1/info-producers/$2" res="$(__do_curl_to_api ICS GET $query)" status=${res:${#res}-3} @@ -1484,11 +1335,7 @@ ics_api_edp_get_producer_2() { fi targetJson=$targetJson"]" if [ $# -gt 4 ]; then - if [[ "$ICS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then - targetJson="{\"supported_info_types\":$targetJson,\"info_job_callback_url\": \"$3\",\"info_producer_supervision_callback_url\": \"$4\"}" - else - targetJson="{\"supported_ei_types\":$targetJson,\"ei_job_callback_url\": \"$3\",\"ei_producer_supervision_callback_url\": \"$4\"}" - fi + targetJson="{\"supported_info_types\":$targetJson,\"info_job_callback_url\": \"$3\",\"info_producer_supervision_callback_url\": \"$4\"}" fi echo " TARGET JSON: $targetJson" >> $HTTPLOG res=$(python3 ../common/compare_json.py "$targetJson" "$body") @@ -1514,11 +1361,7 @@ ics_api_edp_delete_producer() { __print_err " " $@ return 1 fi - if [[ "$ICS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then - query="/data-producer/v1/info-producers/$2" - else - query="/ei-producer/v1/eiproducers/$2" - fi + query="/data-producer/v1/info-producers/$2" res="$(__do_curl_to_api ICS DELETE $query)" status=${res:${#res}-3} @@ -1615,27 +1458,15 @@ ics_api_edp_put_producer_2() { inputJson=$inputJson"\""${arr[$i]}"\"" done fi - if [[ "$ICS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then - inputJson="\"supported_info_types\":"$inputJson"]" - - inputJson=$inputJson",\"info_job_callback_url\": \"$3\",\"info_producer_supervision_callback_url\": \"$4\"" - - inputJson="{"$inputJson"}" - - file="./tmp/.p.json" - echo "$inputJson" > $file - query="/data-producer/v1/info-producers/$2" - else - inputJson="\"supported_ei_types\":"$inputJson"]" + inputJson="\"supported_info_types\":"$inputJson"]" - inputJson=$inputJson",\"ei_job_callback_url\": \"$3\",\"ei_producer_supervision_callback_url\": \"$4\"" + inputJson=$inputJson",\"info_job_callback_url\": \"$3\",\"info_producer_supervision_callback_url\": \"$4\"" - inputJson="{"$inputJson"}" + inputJson="{"$inputJson"}" - file="./tmp/.p.json" - echo "$inputJson" > $file - query="/ei-producer/v1/eiproducers/$2" - fi + file="./tmp/.p.json" + echo "$inputJson" > $file + query="/data-producer/v1/info-producers/$2" res="$(__do_curl_to_api ICS PUT $query $file)" status=${res:${#res}-3} @@ -1735,11 +1566,7 @@ ics_api_edp_get_producer_jobs_2() { __print_err " (EMPTY | [ ]+)" $@ return 1 fi - if [[ "$ICS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then - query="/data-producer/v1/info-producers/$2/info-jobs" - else - query="/ei-producer/v1/eiproducers/$2/eijobs" - fi + query="/data-producer/v1/info-producers/$2/info-jobs" res="$(__do_curl_to_api ICS GET $query)" status=${res:${#res}-3} if [ $status -ne $1 ]; then @@ -1762,11 +1589,8 @@ ics_api_edp_get_producer_jobs_2() { __log_test_fail_general "Job template file "${arr[$i+4]}", does not exist" return 1 fi - if [[ "$ICS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then - targetJson=$targetJson"{\"info_job_identity\":\"${arr[$i]}\",\"info_type_identity\":\"${arr[$i+1]}\",\"target_uri\":\"${arr[$i+2]}\",\"owner\":\"${arr[$i+3]}\",\"info_job_data\":$jobfile, \"last_updated\":\"????\"}" - else - targetJson=$targetJson"{\"ei_job_identity\":\"${arr[$i]}\",\"ei_type_identity\":\"${arr[$i+1]}\",\"target_uri\":\"${arr[$i+2]}\",\"owner\":\"${arr[$i+3]}\",\"ei_job_data\":$jobfile, \"last_updated\":\"????\"}" - fi + targetJson=$targetJson"{\"info_job_identity\":\"${arr[$i]}\",\"info_type_identity\":\"${arr[$i+1]}\",\"target_uri\":\"${arr[$i+2]}\",\"owner\":\"${arr[$i+3]}\",\"info_job_data\":$jobfile, \"last_updated\":\"????\"}" + done fi targetJson=$targetJson"]" @@ -2392,11 +2216,7 @@ ics_api_idc_delete_subscription() { ics_api_admin_reset() { __log_test_start $@ - if [ -z "$FLAT_A1_EI" ]; then - query="/A1-EI/v1/eitypes/$2/eijobs" - else - query="/A1-EI/v1/eijobs" - fi + query="/A1-EI/v1/eijobs" res="$(__do_curl_to_api ICS GET $query)" status=${res:${#res}-3} @@ -2413,18 +2233,14 @@ ics_api_admin_reset() { list=$(echo ${list//\"/}) list=$list" " for job in $list; do - if [ -z "$FLAT_A1_EI" ]; then - echo "Not supported for non-flat EI api" - else - query="/A1-EI/v1/eijobs/$job" - res="$(__do_curl_to_api ICS DELETE $query)" - status=${res:${#res}-3} - if [ $status -ne 204 ]; then - __log_test_fail_status_code $1 $status - return 1 - fi - echo " Deleted job: "$job + query="/A1-EI/v1/eijobs/$job" + res="$(__do_curl_to_api ICS DELETE $query)" + status=${res:${#res}-3} + if [ $status -ne 204 ]; then + __log_test_fail_status_code $1 $status + return 1 fi + echo " Deleted job: "$job done __log_test_pass @@ -2444,7 +2260,7 @@ ics_api_admin_reset() { ics_kube_pvc_reset() { __log_test_start $@ - pvc_name=$(kubectl get pvc -n $KUBE_NONRTRIC_NAMESPACE --no-headers -o custom-columns=":metadata.name" | grep information) + pvc_name=$(kubectl $KUBECONF get pvc -n $KUBE_NONRTRIC_NAMESPACE --no-headers -o custom-columns=":metadata.name" | grep information) if [ -z "$pvc_name" ]; then pvc_name=informationservice-pvc fi @@ -2454,4 +2270,17 @@ ics_kube_pvc_reset() { __log_test_pass return 0 +} + +# args: +ics_configure_sec() { + export ICS_CREDS_GRANT_TYPE="client_credentials" + export ICS_CREDS_CLIENT_SECRET=$3 + export ICS_CREDS_CLIENT_ID=$2 + export ICS_AUTH_SERVICE_URL=$KEYCLOAK_SERVICE_PATH$KEYCLOAK_TOKEN_URL_PREFIX/$1/protocol/openid-connect/token + export ICS_SIDECAR_MOUNT="/token-cache" + export ICS_SIDECAR_JWT_FILE=$ICS_SIDECAR_MOUNT"/jwt.txt" + + export AUTHSIDECAR_APP_NAME + export AUTHSIDECAR_DISPLAY_NAME } \ No newline at end of file