Added r-app catalogue to demo test case
[nonrtric.git] / test / common / api_curl.sh
index 2aff131..c7e5c90 100644 (file)
 # one for sending the requests and one for receiving the response
 # but only when using the DMAAP interface
 # REST or DMAAP is controlled of the base url of $ADAPTER
-# arg: (PA|ECS GET|PUT|POST|DELETE|GET_BATCH|PUT_BATCH|POST_BATCH|DELETE_BATCH <url> [<file>]) | (PA|ECS RESPONSE <correlation-id>)
+# arg: (PA|ECS|CR|RC GET|PUT|POST|DELETE|GET_BATCH|PUT_BATCH|POST_BATCH|DELETE_BATCH <url> [<file>]) | (PA|ECS RESPONSE <correlation-id>)
 # (Not for test scripts)
 __do_curl_to_api() {
-    echo "(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
+       TIMESTAMP=$(date "+%Y-%m-%d %H:%M:%S")
+    echo " (${BASH_LINENO[0]}) - ${TIMESTAMP}: ${FUNCNAME[0]}" $@ >> $HTTPLOG
        paramError=0
 
     if [ $# -gt 0 ]; then
@@ -40,6 +41,16 @@ __do_curl_to_api() {
             __RESTBASE=$ECS_RESTBASE
             __RESTBASE_SECURE=$ECS_RESTBASE_SECURE
             __RETRY_CODES=$ECS_RETRY_CODES
+               elif [ $1 == "CR" ]; then
+                   __ADAPTER=$CR_ADAPTER
+            __RESTBASE=$CR_RESTBASE
+            __RESTBASE_SECURE=$CR_RESTBASE_SECURE
+            __RETRY_CODES=""
+               elif [ $1 == "RC" ]; then
+                   __ADAPTER=$RC_ADAPTER
+            __RESTBASE=$RC_RESTBASE
+            __RESTBASE_SECURE=$RC_RESTBASE_SECURE
+            __RETRY_CODES=""
         else
             paramError=1
         fi
@@ -97,7 +108,7 @@ __do_curl_to_api() {
 
     if [ $paramError -eq 1 ]; then
                ((RES_CONF_FAIL++))
-        echo "-Incorrect number of parameters to __do_curl_agent " $@ >> $HTTPLOG
+        echo "-Incorrect number of parameters to __do_curl_to_api " $@ >> $HTTPLOG
         echo "-Expected: (PA|ECS GET|PUT|POST|DELETE|GET_BATCH|PUT_BATCH|POST_BATCH|DELETE_BATCH <url> [<file>]) | (PA|ECS RESPONSE <correlation-id>)" >> $HTTPLOG
         echo "-Returning response 000" >> $HTTPLOG
         echo "-000"
@@ -150,6 +161,8 @@ __do_curl_to_api() {
                                payload="$(cat $4 | tr -d '\n' | tr -d ' ' )"
                                echo "payload: "$payload >> $HTTPLOG
                                file=" --data-binary "$payload
+                       elif [ $# -eq 4 ]; then
+                               echo " FILE: $(cat $4)" >> $HTTPLOG
                        fi
                        #urlencode the request url since it will be carried by send-request url
                        requestUrl=$(python3 -c "from __future__ import print_function; import urllib.parse, sys; print(urllib.parse.quote(sys.argv[1]))"  "$3")