X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=test%2Fcommon%2Fcr_api_functions.sh;h=a29d010f8a09cbcc63e3ce17380e5bf9bf01bbef;hb=refs%2Fchanges%2F62%2F8262%2F1;hp=511627375da4100f38132ee043a80ff420e0731c;hpb=534a1fe8136ed8d72615707008bdd6061d1df2fe;p=nonrtric.git diff --git a/test/common/cr_api_functions.sh b/test/common/cr_api_functions.sh index 51162737..a29d010f 100644 --- a/test/common/cr_api_functions.sh +++ b/test/common/cr_api_functions.sh @@ -94,8 +94,8 @@ __CR_kube_delete_all() { # args: __CR_store_docker_logs() { if [ $RUNMODE == "KUBE" ]; then - for podname in $(kubectl get pods -n $KUBE_SIM_NAMESPACE -l "autotest=CR" -o custom-columns=":metadata.name"); do - kubectl logs -n $KUBE_SIM_NAMESPACE $podname --tail=-1 > $1$2_$podname.log 2>&1 + for podname in $(kubectl $KUBECONF get pods -n $KUBE_SIM_NAMESPACE -l "autotest=CR" -o custom-columns=":metadata.name"); do + kubectl $KUBECONF logs -n $KUBE_SIM_NAMESPACE $podname --tail=-1 > $1$2_$podname.log 2>&1 done else crs=$(docker ps --filter "name=$CR_APP_NAME" --filter "network=$DOCKER_SIM_NWNAME" --filter "status=running" --format {{.Names}}) @@ -122,7 +122,7 @@ __CR_statisics_setup() { CR_INSTANCE_KUBE=$(($CR_INSTANCE-1)) echo -n " CR-$CR_INSTANCE_KUBE $CR_APP_NAME-$CR_INSTANCE_KUBE $KUBE_SIM_NAMESPACE " else - if [ $DOCKER_COMPOSE_VERION == "V1" ]; then + if [ $DOCKER_COMPOSE_VERSION == "V1" ]; then echo -n " CR_$CR_INSTANCE ${CR_APP_NAME}_cr_$CR_INSTANCE " else echo -n " CR_$CR_INSTANCE ${CR_APP_NAME}-cr-$CR_INSTANCE " @@ -131,6 +131,12 @@ __CR_statisics_setup() { done } +# Check application requirements, e.g. helm, the the test needs. Exit 1 if req not satisfied +# args: - +__CR_test_requirements() { + : +} + ####################################################### ################ @@ -165,7 +171,7 @@ __cr_set_protocoll() { for ((CR_INSTANCE=0; CR_INSTANCE<$MAX_CR_APP_COUNT; CR_INSTANCE++ )); do CR_DOCKER_INSTANCE=$(($CR_INSTANCE+1)) # CR_SERVICE_PATH is the base path to cr - if [ $DOCKER_COMPOSE_VERION == "V1" ]; then + if [ $DOCKER_COMPOSE_VERSION == "V1" ]; then __CR_SERVICE_PATH=$1"://"$CR_APP_NAME"_cr_"${CR_DOCKER_INSTANCE}":"$2 # docker access, container->container and script->container via proxy else __CR_SERVICE_PATH=$1"://"$CR_APP_NAME"-cr-"${CR_DOCKER_INSTANCE}":"$2 # docker access, container->container and script->container via proxy @@ -293,7 +299,7 @@ start_cr() { app_data="" cntr=1 while [ $cntr -le $CR_APP_COUNT ]; do - if [ $DOCKER_COMPOSE_VERION == "V1" ]; then + if [ $DOCKER_COMPOSE_VERSION == "V1" ]; then app=$CR_APP_NAME"_cr_"$cntr else app=$CR_APP_NAME"-cr-"$cntr @@ -309,7 +315,7 @@ start_cr() { cntr=1 #Counter for docker instance, starts on 1 cntr2=0 #Couter for env var name, starts with 0 to be compablible with kube while [ $cntr -le $CR_APP_COUNT ]; do - if [ $DOCKER_COMPOSE_VERION == "V1" ]; then + if [ $DOCKER_COMPOSE_VERSION == "V1" ]; then app=$CR_APP_NAME"_cr_"$cntr else app=$CR_APP_NAME"-cr-"$cntr @@ -361,6 +367,27 @@ cr_equal() { fi } +# Tests if a variable value in the CR is equal to or greater than the target value and and optional timeout. +# Arg: - This test set pass or fail depending on if the variable is +# equal to the target or not. +# Arg: - This test waits up to the timeout seconds +# before setting pass or fail depending on if the variable value becomes equal to or greater than the target +# value or not. +# (Function for test scripts) +cr_greater_or_equal() { + if [ $# -eq 3 ] || [ $# -eq 4 ]; then + CR_SERVICE_PATH=$(__cr_get_service_path $1) + CR_ADAPTER=$CR_SERVICE_PATH + if [ $? -ne 0 ]; then + __print_err " missing or incorrect" $@ + return 1 + fi + __var_test "CR" "$CR_SERVICE_PATH/counter/" $2 ">=" $3 $4 + else + __print_err "Wrong args to cr_equal, needs three or four args: [ timeout ]" $@ + fi +} + # Tests if a variable value in the CR 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. @@ -385,7 +412,7 @@ cr_contains_str() { fi } -# Read a variable value from CR sim and send to stdout. Arg: +# Read a variable value from CR sim and send to stdout. Arg: cr_read() { CR_SERVICE_PATH=$(__cr_get_service_path $1) CR_ADAPTER=$CR_SERVICE_PATH @@ -393,7 +420,7 @@ cr_read() { __print_err " missing or incorrect" $@ return 1 fi - echo "$(__do_curl $CR_SERVICE_PATH/counter/$1)" + echo "$(__do_curl $CR_SERVICE_PATH/counter/$2)" } # Function to configure write delay on callbacks @@ -427,13 +454,13 @@ cr_delay_callback() { return 0 } -# CR API: Check the contents of all current ric sync events for one id from PMS +# CR API: Check the contents of all current ric sync events for one id from A1PMS # [ EMPTY | ( )+ ] # (Function for test scripts) cr_api_check_all_sync_events() { __log_test_start $@ - if [ "$PMS_VERSION" != "V2" ]; then + if [ "$A1PMS_VERSION" != "V2" ]; then __log_test_fail_not_supported return 1 fi