X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=test%2Fcommon%2Fricsimulator_api_functions.sh;h=f003559260f247b9929ce47df9b2be3daa2e4ac5;hb=5d97a401dc1e26f64ad57daab90f924da9c12c64;hp=f4cbc02e3c8900170f7db5404151a26548e4fbe3;hpb=c488e37b5803ca41d7b8feb4434cb570aae2cd43;p=nonrtric.git diff --git a/test/common/ricsimulator_api_functions.sh b/test/common/ricsimulator_api_functions.sh index f4cbc02e..f0035592 100644 --- a/test/common/ricsimulator_api_functions.sh +++ b/test/common/ricsimulator_api_functions.sh @@ -34,7 +34,7 @@ __execute_curl_to_sim() { retcode=$? if [ $retcode -ne 0 ]; then echo " RETCODE: "$retcode - echo -e $RED" ERROR - fatal error when executing curl."$ERED + echo -e $RED" FAIL - fatal error when executing curl."$ERED return 1 fi status=${res:${#res}-3} @@ -42,7 +42,7 @@ __execute_curl_to_sim() { echo -e $GREEN" OK"$EGREEN return 0 fi - echo -e $RED" ERROR - expected http response: "$1" but got http response: "$status $ERED + echo -e $RED" FAIL - expected http response: "$1" but got http response: "$status $ERED return 1 } @@ -82,6 +82,27 @@ sim_print() { echo -e $BOLD"INFO(${BASH_LINENO[0]}): $app, $2 = $(__do_curl $RIC_SIM_LOCALHOST$port/counter/$2)"$EBOLD } +# Tests if a variable value in the RIC simulator contains the target string and and optional timeout +# Arg: - This test set pass or fail depending on if the variable contains +# the target or not. +# Arg: - This test waits up to the timeout seconds +# before setting pass or fail depending on if the variable value contains the target +# value or not. +# (Function for test scripts) +sim_contains_str() { + + if [ $# -eq 3 ] || [ $# -eq 4 ]; then + app=$1 + port=$(__find_sim_port $app) + __var_test $app "$RIC_SIM_LOCALHOST$port/counter/" $2 "contain_str" $3 $4 + return 0 + else + ((RES_CONF_FAIL++)) + __print_err "needs three or four args: [ timeout ]" + return 1 + fi +} + # Simulator API: Put a policy type in a ric # args: # (Function for test scripts) @@ -193,7 +214,7 @@ sim_post_forcedelay() { app=$2 res=$(__find_sim_port $app) - curlString="curl -X POST -skw %{http_code} $RIC_SIM_LOCALHOST$res/delay" + curlString="curl -X POST -skw %{http_code} $RIC_SIM_LOCALHOST$res/forcedelay" if [ $# -eq 3 ]; then curlString=$curlString"?delay="$3 fi