X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=test%2Fcommon%2Fcr_api_functions.sh;h=4fad4c4e43d88bedc4e9f2c15b8337ae783832c6;hb=b188e12cc1b4be627ae6f8f424f06c38ffb89804;hp=1b82ea02e0c9915186d1f41a331eb12db0013b6d;hpb=51f04f0977f9be139489f05dcfc45b10c461cf9c;p=nonrtric.git diff --git a/test/common/cr_api_functions.sh b/test/common/cr_api_functions.sh index 1b82ea02..4fad4c4e 100644 --- a/test/common/cr_api_functions.sh +++ b/test/common/cr_api_functions.sh @@ -17,7 +17,7 @@ # ============LICENSE_END================================================= # -# This is a script that contains container/service managemnt functions test functions for the Callback Reciver +# This is a script that contains container/service management functions test functions for the Callback Receiver ################ Test engine functions ################ @@ -26,7 +26,7 @@ # arg: (selects staging, snapshot, release etc) # is present only for images with staging, snapshot,release tags __CR_imagesetup() { - __check_and_create_image_var CR "CR_IMAGE" "CR_IMAGE_BASE" "CR_IMAGE_TAG" LOCAL "$CR_DISPLAY_NAME" + __check_and_create_image_var CR "CR_IMAGE" "CR_IMAGE_BASE" "CR_IMAGE_TAG" LOCAL "$CR_DISPLAY_NAME" $IMAGE_TARGET_PLATFORM_IMG_TAG } # Pull image from remote repo or use locally built image @@ -44,7 +44,7 @@ __CR_imagepull() { __CR_imagebuild() { cd ../cr echo " Building CR - $CR_DISPLAY_NAME - image: $CR_IMAGE" - docker build --build-arg NEXUS_PROXY_REPO=$NEXUS_PROXY_REPO -t $CR_IMAGE . &> .dockererr + docker build $IMAGE_TARGET_PLATFORM_CMD_PARAM --build-arg NEXUS_PROXY_REPO=$NEXUS_PROXY_REPO -t $CR_IMAGE . &> .dockererr if [ $? -eq 0 ]; then echo -e $GREEN" Build Ok"$EGREEN __retag_and_push_image CR_IMAGE @@ -78,12 +78,12 @@ __CR_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. __CR_kube_scale_zero_and_wait() { echo -e $RED" CR app is not scaled in this state"$ERED } -# 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. __CR_kube_delete_all() { __kube_delete_all_resources $KUBE_SIM_NAMESPACE autotest CR @@ -91,11 +91,11 @@ __CR_kube_delete_all() { # Store docker logs # This function is called for apps managed by the test script. -# args: +# 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}}) @@ -112,25 +112,27 @@ __CR_initial_setup() { use_cr_http } -# 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: - -__CR_statisics_setup() { +__CR_statistics_setup() { for ((CR_INSTANCE=MAX_CR_APP_COUNT; CR_INSTANCE>0; CR_INSTANCE-- )); do if [ $RUNMODE == "KUBE" ]; then 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 - echo -n " CR_$CR_INSTANCE ${CR_APP_NAME}_cr_$CR_INSTANCE " - else - echo -n " CR_$CR_INSTANCE ${CR_APP_NAME}-cr-$CR_INSTANCE " - fi + echo -n " CR_$CR_INSTANCE ${CR_APP_NAME}-cr-$CR_INSTANCE " fi done } +# Check application requirements, e.g. helm, the the test needs. Exit 1 if req not satisfied +# args: - +__CR_test_requirements() { + : +} + ####################################################### ################ @@ -160,16 +162,12 @@ use_cr_https() { __cr_set_protocoll() { echo -e $BOLD"$CR_DISPLAY_NAME protocol setting"$EBOLD - echo -e " Using $BOLD http $EBOLD towards $CR_DISPLAY_NAME" + echo -e " Using $BOLD $1 $EBOLD towards $CR_DISPLAY_NAME" ## Access to Dmaap adapter 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 - __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 - fi + __CR_SERVICE_PATH=$1"://"$CR_APP_NAME"-cr-"${CR_DOCKER_INSTANCE}":"$2 # docker access, container->container and script->container via proxy if [ $RUNMODE == "KUBE" ]; then __CR_SERVICE_PATH=$1"://"$CR_APP_NAME"-"$CR_INSTANCE.$CR_APP_NAME"."$KUBE_SIM_NAMESPACE":"$3 # kube access, pod->svc and script->svc via proxy fi @@ -208,7 +206,7 @@ __cr_export_vars() { export CR_APP_COUNT } -# Start the Callback reciver in the simulator group +# Start the Callback receiver in the simulator group # args: # (Function for test scripts) start_cr() { @@ -231,7 +229,7 @@ start_cr() { __check_included_image "CR" 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 "CR" retcode_p=$? @@ -293,11 +291,7 @@ start_cr() { app_data="" cntr=1 while [ $cntr -le $CR_APP_COUNT ]; do - if [ $DOCKER_COMPOSE_VERION == "V1" ]; then - app=$CR_APP_NAME"_cr_"$cntr - else - app=$CR_APP_NAME"-cr-"$cntr - fi + app=$CR_APP_NAME"-cr-"$cntr app_data="$app_data $app" let cntr=cntr+1 done @@ -309,11 +303,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 - app=$CR_APP_NAME"_cr_"$cntr - else - app=$CR_APP_NAME"-cr-"$cntr - fi + app=$CR_APP_NAME"-cr-"$cntr __dynvar="CR_SERVICE_PATH_"$cntr2 __check_service_start $app ${!__dynvar}$CR_ALIVE_URL let cntr=cntr+1 @@ -361,6 +351,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 +396,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 +404,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 +438,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 @@ -489,10 +500,10 @@ cr_api_check_all_sync_events() { return 0 } -# CR API: Check the contents of all current status events for one id from ECS +# CR API: Check the contents of all current status events for one id from ICS # [ EMPTY | ( )+ ] # (Function for test scripts) -cr_api_check_all_ecs_events() { +cr_api_check_all_ics_events() { __log_test_start $@ if [ $# -lt 3 ]; then @@ -546,10 +557,10 @@ cr_api_check_all_ecs_events() { return 0 } -# CR API: Check the contents of all current type subscription events for one id from ECS +# CR API: Check the contents of all current type subscription events for one id from ICS # [ EMPTY | ( )+ ] # (Function for test scripts) -cr_api_check_all_ecs_subscription_events() { +cr_api_check_all_ics_subscription_events() { __log_test_start $@ #Valid number of parameter 3,4,8,12 @@ -625,7 +636,7 @@ cr_api_check_all_ecs_subscription_events() { cr_api_reset() { __log_conf_start $@ - if [ $# -ne 0 ]; then + if [ $# -ne 1 ]; then __print_err "" $@ return 1 fi @@ -653,7 +664,7 @@ cr_api_reset() { # CR API: Check the contents of all json events for path # (EMPTY | + ) # (Function for test scripts) -cr_api_check_all_genric_json_events() { +cr_api_check_all_generic_json_events() { __log_test_start $@ if [ $# -lt 4 ]; then @@ -709,7 +720,7 @@ cr_api_check_all_genric_json_events() { # CR API: Check a single (oldest) json event (or none if empty) for path # (EMPTY | ) # (Function for test scripts) -cr_api_check_single_genric_json_event() { +cr_api_check_single_generic_json_event() { __log_test_start $@ if [ $# -ne 4 ]; then @@ -756,7 +767,7 @@ cr_api_check_single_genric_json_event() { # The MD5 will generate different hash if ws is present or not in otherwise equivalent json # arg: (EMPTY | ) # (Function for test scripts) -cr_api_check_single_genric_event_md5() { +cr_api_check_single_generic_event_md5() { __log_test_start $@ if [ $# -ne 4 ]; then @@ -819,7 +830,7 @@ cr_api_check_single_genric_event_md5() { # The MD5 will generate different hash if ws/newlines is present or not in otherwise equivalent json # arg: (EMPTY | ) # (Function for test scripts) -cr_api_check_single_genric_event_md5_file() { +cr_api_check_single_generic_event_md5_file() { __log_test_start $@ if [ $# -ne 4 ]; then