# ============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.
# arg: <image-tag-suffix> (selects staging, snapshot, release etc)
# <image-tag-suffix> 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
}
# 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
# Store docker logs
# This function is called for apps managed by the test script.
-# args: <log-dir> <file-prexix>
+# args: <log-dir> <file-prefix>
__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
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))
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
}
__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=$?
docker_args=" --scale $RICMEDIATOR_SIMCOMPOSE_SERVICE_NAME=$2"
- #Create a list of contsiner names
+ #Create a list of container names
#Will be <ricsim-prefix>_<service-name>_<index>
# or
# <ricsim-prefix>-<service-name>-<index>
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"
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
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
}
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: <expected-response-code> <curl-cmd-string>
__execute_curl_to_ricmediatorsim() {
echo ${FUNCNAME[1]} "line: "${BASH_LINENO[1]} >> $HTTPLOG
# (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: <ric-id> <sim-param> <target-value> [ timeout ]"
- # return 1
- # fi
}
# Print a variable value from the RICMEDIATOR sim.
# (Function for test scripts)
ricmediatorsim_print() {
__log_test_info_not_supported
- # if [ $# != 2 ]; then
- # __print_err "need two args, <ric-id> <sim-param>" $@
- # 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
# (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: <ric-id> <sim-param> <target-value> [ timeout ]"
- # return 1
- # fi
}
# Simulator API: Put a policy type in a ric
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 $?
}
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 $?
}
# (Function for test scripts)
ricmediatorsim_post_delete_instances() {
__log_test_fail_not_supported
- # __log_conf_start $@
- # if [ $# -ne 2 ]; then
- # __print_err "<response-code> <ric-id>" $@
- # 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
# (Function for test scripts)
ricmediatorsim_post_delete_all() {
__log_test_fail_not_supported
- # __log_conf_start $@
- # if [ $# -ne 2 ]; then
- # __print_err "<response-code> <numericic-id>" $@
- # 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
# (Function for test scripts)
ricmediatorsim_post_forcedresponse() {
__log_test_fail_not_supported
- # __log_conf_start $@
- # if [ $# -ne 3 ]; then
- # __print_err "<response-code> <ric-id> <forced_response_code>" $@
- # 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
# (Function for test scripts)
ricmediatorsim_post_forcedelay() {
__log_test_fail_not_supported
- # __log_conf_start $@
- # if [ $# -ne 3 ]; then
- # __print_err "<response-code> <ric-id> [<delay-in-seconds>]" $@
- # 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