X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=test%2Fcommon%2Fricmediatorsim_api_functions.sh;h=25cb414c81b50b257c11e3e17a2394aa7015a8c1;hb=HEAD;hp=93c2db249e33cb4876f681b19c2db9f0085fdf3e;hpb=7d7cb5f4f6306db8193ebd4e6e110fa0060900fa;p=nonrtric.git diff --git a/test/common/ricmediatorsim_api_functions.sh b/test/common/ricmediatorsim_api_functions.sh index 93c2db24..25cb414c 100644 --- a/test/common/ricmediatorsim_api_functions.sh +++ b/test/common/ricmediatorsim_api_functions.sh @@ -2,6 +2,7 @@ # ============LICENSE_START=============================================== # Copyright (C) 2023 Nordix Foundation. All rights reserved. +# Copyright (C) 2023 OpenInfra Foundation Europe. 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,8 +26,8 @@ # arg: (selects staging, snapshot, release etc) # is present only for images with staging, snapshot,release tags __RICMEDIATORSIM_imagesetup() { - __check_and_create_image_var RICMEDIATORSIM "RICMEDIATOR_SIM_IMAGE" "RICMEDIATOR_SIM_IMAGE_BASE" "RICMEDIATOR_SIM_IMAGE_TAG" REMOTE_RELEASE_ORAN "$RICMEDIATOR_SIM_DISPLAY_NAME" - __check_and_create_image_var RICMEDIATORSIM "RICMEDIATOR_SIM_DB_IMAGE" "RICMEDIATOR_SIM_DB_IMAGE_BASE" "RICMEDIATOR_SIM_DB_IMAGE_TAG" REMOTE_RELEASE_ORAN "$RICMEDIATOR_SIM_DB_DISPLAY_NAME" + __check_and_create_image_var RICMEDIATORSIM "RICMEDIATOR_SIM_IMAGE" "RICMEDIATOR_SIM_IMAGE_BASE" "RICMEDIATOR_SIM_IMAGE_TAG" REMOTE_RELEASE_ORAN "$RICMEDIATOR_SIM_DISPLAY_NAME" "" + __check_and_create_image_var RICMEDIATORSIM "RICMEDIATOR_SIM_DB_IMAGE" "RICMEDIATOR_SIM_DB_IMAGE_BASE" "RICMEDIATOR_SIM_DB_IMAGE_TAG" REMOTE_RELEASE_ORAN "$RICMEDIATOR_SIM_DB_DISPLAY_NAME" "" } # Pull image from remote repo or use locally built image @@ -68,12 +69,12 @@ __RICMEDIATORSIM_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. __RICMEDIATORSIM_kube_scale_zero_and_wait() { __kube_scale_and_wait_all_resources $KUBE_A1SIM_NAMESPACE app $KUBE_A1SIM_NAMESPACE"-neara1simulator" } -# 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. __RICMEDIATORSIM_kube_delete_all() { __kube_delete_all_resources $KUBE_A1SIM_NAMESPACE autotest RICMEDIATORSIM @@ -81,7 +82,7 @@ __RICMEDIATORSIM_kube_delete_all() { # Store docker logs # This function is called for apps managed by the test script. -# args: +# args: __RICMEDIATORSIM_store_docker_logs() { if [ $RUNMODE == "KUBE" ]; then for podname in $(kubectl $KUBECONF get pods -n $KUBE_A1SIM_NAMESPACE -l "autotest=RICMEDIATORSIM" -o custom-columns=":metadata.name"); do @@ -103,11 +104,11 @@ __RICMEDIATORSIM_initial_setup() { use_ricmediator_simulator_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: - -__RICMEDIATORSIM_statisics_setup() { +__RICMEDIATORSIM_statistics_setup() { for ((RICMEDIATOR_SIMINSTANCE=10; RICMEDIATOR_SIMINSTANCE>0; RICMEDIATOR_SIMINSTANCE-- )); do if [ $RUNMODE == "KUBE" ]; then RICMEDIATOR_SIMINSTANCE_KUBE=$(($RICMEDIATOR_SIMINSTANCE-1)) @@ -116,17 +117,10 @@ __RICMEDIATORSIM_statisics_setup() { echo -n " RICMEDIATOR_SIMG3_$RICMEDIATOR_SIMINSTANCE_KUBE ${RICMEDIATOR_SIM_PREFIX}-g3-$RICMEDIATOR_SIMINSTANCE_KUBE $KUBE_A1SIM_NAMESPACE " echo -n " RICMEDIATOR_SIMG4_$RICMEDIATOR_SIMINSTANCE_KUBE ${RICMEDIATOR_SIM_PREFIX}-g4-$RICMEDIATOR_SIMINSTANCE_KUBE $KUBE_A1SIM_NAMESPACE " else - if [ $DOCKER_COMPOSE_VERSION == "V1" ]; then - echo -n " RICMEDIATOR_SIMG1_$RICMEDIATOR_SIMINSTANCE ${RICMEDIATOR_SIM_PREFIX}_g1_$RICMEDIATOR_SIMINSTANCE " - echo -n " RICMEDIATOR_SIMG2_$RICMEDIATOR_SIMINSTANCE ${RICMEDIATOR_SIM_PREFIX}_g2_$RICMEDIATOR_SIMINSTANCE " - echo -n " RICMEDIATOR_SIMG3_$RICMEDIATOR_SIMINSTANCE ${RICMEDIATOR_SIM_PREFIX}_g3_$RICMEDIATOR_SIMINSTANCE " - echo -n " RICMEDIATOR_SIMG4_$RICMEDIATOR_SIMINSTANCE ${RICMEDIATOR_SIM_PREFIX}_g4_$RICMEDIATOR_SIMINSTANCE " - else - echo -n " RICMEDIATOR_SIMG1_$RICMEDIATOR_SIMINSTANCE ${RICMEDIATOR_SIM_PREFIX}-g1-$RICMEDIATOR_SIMINSTANCE " - echo -n " RICMEDIATOR_SIMG2_$RICMEDIATOR_SIMINSTANCE ${RICMEDIATOR_SIM_PREFIX}-g2-$RICMEDIATOR_SIMINSTANCE " - echo -n " RICMEDIATOR_SIMG3_$RICMEDIATOR_SIMINSTANCE ${RICMEDIATOR_SIM_PREFIX}-g3-$RICMEDIATOR_SIMINSTANCE " - echo -n " RICMEDIATOR_SIMG4_$RICMEDIATOR_SIMINSTANCE ${RICMEDIATOR_SIM_PREFIX}-g4-$RICMEDIATOR_SIMINSTANCE " - fi + echo -n " RICMEDIATOR_SIMG1_$RICMEDIATOR_SIMINSTANCE ${RICMEDIATOR_SIM_PREFIX}-g1-$RICMEDIATOR_SIMINSTANCE " + echo -n " RICMEDIATOR_SIMG2_$RICMEDIATOR_SIMINSTANCE ${RICMEDIATOR_SIM_PREFIX}-g2-$RICMEDIATOR_SIMINSTANCE " + echo -n " RICMEDIATOR_SIMG3_$RICMEDIATOR_SIMINSTANCE ${RICMEDIATOR_SIM_PREFIX}-g3-$RICMEDIATOR_SIMINSTANCE " + echo -n " RICMEDIATOR_SIMG4_$RICMEDIATOR_SIMINSTANCE ${RICMEDIATOR_SIM_PREFIX}-g4-$RICMEDIATOR_SIMINSTANCE " fi done } @@ -182,7 +176,7 @@ start_ricmediator_simulators() { __check_included_image "RICMEDIATORSIM" 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 "RICMEDIATORSIM" retcode_p=$? @@ -300,17 +294,13 @@ start_ricmediator_simulators() { docker_args=" --scale $RICMEDIATOR_SIMCOMPOSE_SERVICE_NAME=$2" - #Create a list of contsiner names + #Create a list of container names #Will be __ # or # -- app_data="" cntr=1 - if [ $DOCKER_COMPOSE_VERSION == "V1" ]; then - app_name_prefix=$RICMEDIATOR_SIM_PREFIX"_"$RICMEDIATOR_SIMCOMPOSE_SERVICE_NAME"_" - else - app_name_prefix=$RICMEDIATOR_SIM_PREFIX"-"$RICMEDIATOR_SIMCOMPOSE_SERVICE_NAME"-" - fi + app_name_prefix=$RICMEDIATOR_SIM_PREFIX"-"$RICMEDIATOR_SIMCOMPOSE_SERVICE_NAME"-" while [ $cntr -le $2 ]; do app=$app_name_prefix$cntr app_data="$app_data $app" @@ -321,11 +311,7 @@ start_ricmediator_simulators() { cntr=1 while [ $cntr -le $2 ]; do - if [ $DOCKER_COMPOSE_VERSION == "V1" ]; then - app=$RICMEDIATOR_SIM_PREFIX"_"$RICMEDIATOR_SIMCOMPOSE_SERVICE_NAME"_"$cntr - else - app=$RICMEDIATOR_SIM_PREFIX"-"$RICMEDIATOR_SIMCOMPOSE_SERVICE_NAME"-"$cntr - fi + app=$RICMEDIATOR_SIM_PREFIX"-"$RICMEDIATOR_SIMCOMPOSE_SERVICE_NAME"-"$cntr __check_service_start $app $RICMEDIATOR_SIM_HTTPX"://"$app:$RICMEDIATOR_SIM_PORT$RICMEDIATOR_SIM_ALIVE_URL let cntr=cntr+1 done @@ -359,13 +345,8 @@ __find_ricmediatorsim_host() { fi echo $RICMEDIATOR_SIM_HTTPX"://"$ricname.$ric_setname.$KUBE_A1SIM_NAMESPACE":"$RICMEDIATOR_SIM_PORT else - if [ $DOCKER_COMPOSE_VERSION == "V1" ]; then - echo $RICMEDIATOR_SIM_HTTPX"://"$1":"$RICMEDIATOR_SIM_PORT - else - ricname=$(echo "$1" | tr '_' '-') - echo $RICMEDIATOR_SIM_HTTPX"://"$ricname":"$RICMEDIATOR_SIM_PORT - fi - + ricname=$(echo "$1" | tr '_' '-') + echo $RICMEDIATOR_SIM_HTTPX"://"$ricname":"$RICMEDIATOR_SIM_PORT fi } @@ -376,7 +357,7 @@ nearsim_generate_policy_uuid() { UUID=${UUID:0:${#UUID}-4}"a" } -# Excute a curl cmd towards a ricsimulator and check the response code. +# Execute a curl cmd towards a ricsimulator and check the response code. # args: __execute_curl_to_ricmediatorsim() { echo ${FUNCNAME[1]} "line: "${BASH_LINENO[1]} >> $HTTPLOG @@ -423,14 +404,6 @@ __execute_curl_to_ricmediatorsim() { # (Function for test scripts) ricmediatorsim_equal() { __log_test_fail_not_supported - # if [ $# -eq 3 ] || [ $# -eq 4 ]; then - # host=$(__find_ricmediatorsim_host $1) - # __var_test $1 "$host/counter/" $2 "=" $3 $4 - # return 0 - # else - # __print_err "needs three or four args: [ timeout ]" - # return 1 - # fi } # Print a variable value from the RICMEDIATOR sim. @@ -438,12 +411,6 @@ ricmediatorsim_equal() { # (Function for test scripts) ricmediatorsim_print() { __log_test_info_not_supported - # if [ $# != 2 ]; then - # __print_err "need two args, " $@ - # exit 1 - # fi - # host=$(__find_ricmediatorsim_host $1) - # echo -e $BOLD"INFO(${BASH_LINENO[0]}): $1, $2 = $(__do_curl $host/counter/$2)"$EBOLD } # Tests if a variable value in the RICMEDIATOR simulator contains the target string and and optional timeout @@ -455,14 +422,6 @@ ricmediatorsim_print() { # (Function for test scripts) ricmediatorsim_contains_str() { __log_test_fail_not_supported - # if [ $# -eq 3 ] || [ $# -eq 4 ]; then - # host=$(__find_ricmediatorsim_host $1) - # __var_test $1 "$host/counter/" $2 "contain_str" $3 $4 - # return 0 - # else - # __print_err "needs three or four args: [ timeout ]" - # return 1 - # fi } # Simulator API: Put a policy type in a ric @@ -475,7 +434,7 @@ ricmediatorsim_put_policy_type() { return 1 fi host=$(__find_ricmediatorsim_host $2) - curlString="curl -X PUT -skw %{http_code} "$host"/a1-p/policytypes/"$3" -H Content-Type:application/json --data-binary @"$4 + curlString="curl -X PUT -skw %{http_code} "$host"/A1-P/v2/policytypes/"$3" -H Content-Type:application/json --data-binary @"$4 __execute_curl_to_ricmediatorsim $1 "$curlString" return $? } @@ -490,7 +449,7 @@ ricmediatorsim_delete_policy_type() { return 1 fi host=$(__find_ricmediatorsim_host $2) - curlString="curl -X DELETE -skw %{http_code} "$host"/a1-p/policytypes/"$3 + curlString="curl -X DELETE -skw %{http_code} "$host"/A1-P/v2/policytypes/"$3 __execute_curl_to_ricmediatorsim $1 "$curlString" return $? } @@ -500,15 +459,6 @@ ricmediatorsim_delete_policy_type() { # (Function for test scripts) ricmediatorsim_post_delete_instances() { __log_test_fail_not_supported - # __log_conf_start $@ - # if [ $# -ne 2 ]; then - # __print_err " " $@ - # return 1 - # fi - # host=$(__find_ricmediatorsim_host $2) - # curlString="curl -X POST -skw %{http_code} "$host"/deleteinstances" - # __execute_curl_to_ricmediatorsim $1 "$curlString" - # return $? } # Simulator API: Delete all (instances/types/statuses/settings), for one ric @@ -516,15 +466,6 @@ ricmediatorsim_post_delete_instances() { # (Function for test scripts) ricmediatorsim_post_delete_all() { __log_test_fail_not_supported - # __log_conf_start $@ - # if [ $# -ne 2 ]; then - # __print_err " " $@ - # return 1 - # fi - # host=$(__find_ricmediatorsim_host $2) - # curlString="curl -X POST -skw %{http_code} "$host"/deleteall" - # __execute_curl_to_ricmediatorsim $1 "$curlString" - # return $? } # Simulator API: Set (or reset) response code for next A1 message, for one ric @@ -532,18 +473,6 @@ ricmediatorsim_post_delete_all() { # (Function for test scripts) ricmediatorsim_post_forcedresponse() { __log_test_fail_not_supported - # __log_conf_start $@ - # if [ $# -ne 3 ]; then - # __print_err " " $@ - # return 1 - # fi - # host=$(__find_ricmediatorsim_host $2) - # curlString="curl -X POST -skw %{http_code} "$host"/forceresponse" - # if [ $# -eq 3 ]; then - # curlString=$curlString"?code="$3 - # fi - # __execute_curl_to_ricmediatorsim $1 "$curlString" - # return $? } # Simulator API: Set (or reset) A1 response delay, for one ric @@ -551,16 +480,4 @@ ricmediatorsim_post_forcedresponse() { # (Function for test scripts) ricmediatorsim_post_forcedelay() { __log_test_fail_not_supported - # __log_conf_start $@ - # if [ $# -ne 3 ]; then - # __print_err " []" $@ - # return 1 - # fi - # host=$(__find_ricmediatorsim_host $2) - # curlString="curl -X POST -skw %{http_code} $host/forcedelay" - # if [ $# -eq 3 ]; then - # curlString=$curlString"?delay="$3 - # fi - # __execute_curl_to_ricmediatorsim $1 "$curlString" - # return $? } \ No newline at end of file