6449a68d0361612aa44c7572b493bfe746e41a06
[nonrtric.git] / test / common / ricmediatorsim_api_functions.sh
1 #!/bin/bash
2
3 #  ============LICENSE_START===============================================
4 #  Copyright (C) 2023 Nordix Foundation. All rights reserved.
5 #  ========================================================================
6 #  Licensed under the Apache License, Version 2.0 (the "License");
7 #  you may not use this file except in compliance with the License.
8 #  You may obtain a copy of the License at
9 #
10 #       http://www.apache.org/licenses/LICENSE-2.0
11 #
12 #  Unless required by applicable law or agreed to in writing, software
13 #  distributed under the License is distributed on an "AS IS" BASIS,
14 #  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 #  See the License for the specific language governing permissions and
16 #  limitations under the License.
17 #  ============LICENSE_END=================================================
18 #
19
20 # This is a script that contains container/service management functions and test functions for RICMEDIATORSIM A1 simulators
21
22 ################ Test engine functions ################
23
24 # Create the image var used during the test
25 # arg: <image-tag-suffix> (selects staging, snapshot, release etc)
26 # <image-tag-suffix> is present only for images with staging, snapshot,release tags
27 __RICMEDIATORSIM_imagesetup() {
28         __check_and_create_image_var RICMEDIATORSIM "RICMEDIATOR_SIM_IMAGE" "RICMEDIATOR_SIM_IMAGE_BASE" "RICMEDIATOR_SIM_IMAGE_TAG" REMOTE_RELEASE_ORAN "$RICMEDIATOR_SIM_DISPLAY_NAME" ""
29         __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" ""
30 }
31
32 # Pull image from remote repo or use locally built image
33 # arg: <pull-policy-override> <pull-policy-original>
34 # <pull-policy-override> Shall be used for images allowing overriding. For example use a local image when test is started to use released images
35 # <pull-policy-original> Shall be used for images that does not allow overriding
36 # Both var may contain: 'remote', 'remote-remove' or 'local'
37 __RICMEDIATORSIM_imagepull() {
38         __check_and_pull_image $1 "$RICMEDIATOR_SIM_DISPLAY_NAME" $RICMEDIATOR_SIM_PREFIX"_"$RICMEDIATOR_SIM_BASE RICMEDIATOR_SIM_IMAGE
39         __check_and_pull_image $1 "$RICMEDIATOR_SIM_DB_DISPLAY_NAME" $RICMEDIATOR_SIM_PREFIX"_"$RICMEDIATOR_SIM_BASE RICMEDIATOR_SIM_DB_IMAGE
40 }
41
42 # Build image (only for simulator or interfaces stubs owned by the test environment)
43 # arg: <image-tag-suffix> (selects staging, snapshot, release etc)
44 # <image-tag-suffix> is present only for images with staging, snapshot,release tags
45 __RICMEDIATORSIM_imagebuild() {
46         echo -e $RED" Image for app RICMEDIATORSIM shall never be built"$ERED
47 }
48
49 # Generate a string for each included image using the app display name and a docker images format string
50 # If a custom image repo is used then also the source image from the local repo is listed
51 # arg: <docker-images-format-string> <file-to-append>
52 __RICMEDIATORSIM_image_data() {
53         echo -e "$RICMEDIATOR_SIM_DISPLAY_NAME\t$(docker images --format $1 $RICMEDIATOR_SIM_IMAGE)" >>   $2
54         if [ ! -z "$RICMEDIATOR_SIM_IMAGE_SOURCE" ]; then
55                 echo -e "-- source image --\t$(docker images --format $1 $RICMEDIATOR_SIM_IMAGE_SOURCE)" >>   $2
56         fi
57         echo -e "$RICMEDIATOR_SIM_DB_DISPLAY_NAME\t$(docker images --format $1 $RICMEDIATOR_SIM_DB_IMAGE)" >>   $2
58         if [ ! -z "$RICMEDIATOR_SIM_DB_IMAGE_SOURCE" ]; then
59                 echo -e "-- source image --\t$(docker images --format $1 $RICMEDIATOR_SIM_DB_IMAGE_SOURCE)" >>   $2
60         fi
61 }
62
63 # Scale kubernetes resources to zero
64 # All resources shall be ordered to be scaled to 0, if relevant. If not relevant to scale, then do no action.
65 # This function is called for apps fully managed by the test script
66 __RICMEDIATORSIM_kube_scale_zero() {
67         __kube_scale_all_resources $KUBE_A1SIM_NAMESPACE autotest RICMEDIATORSIM
68 }
69
70 # Scale kubernetes resources to zero and wait until this has been accomplished, if relevant. If not relevant to scale, then do no action.
71 # This function is called for pre-started apps not managed by the test script.
72 __RICMEDIATORSIM_kube_scale_zero_and_wait() {
73         __kube_scale_and_wait_all_resources $KUBE_A1SIM_NAMESPACE app $KUBE_A1SIM_NAMESPACE"-neara1simulator"
74 }
75
76 # Delete all kube resources for the app
77 # This function is called for apps managed by the test script.
78 __RICMEDIATORSIM_kube_delete_all() {
79         __kube_delete_all_resources $KUBE_A1SIM_NAMESPACE autotest RICMEDIATORSIM
80 }
81
82 # Store docker logs
83 # This function is called for apps managed by the test script.
84 # args: <log-dir> <file-prefix>
85 __RICMEDIATORSIM_store_docker_logs() {
86         if [ $RUNMODE == "KUBE" ]; then
87                 for podname in $(kubectl $KUBECONF get pods -n $KUBE_A1SIM_NAMESPACE -l "autotest=RICMEDIATORSIM" -o custom-columns=":metadata.name"); do
88                         kubectl $KUBECONF logs -n $KUBE_A1SIM_NAMESPACE $podname --tail=-1 > $1$2_$podname.log 2>&1
89                 done
90         else
91
92                 RICMEDIATORs=$(docker ps --filter "name=$RICMEDIATOR_SIM_PREFIX" --filter "network=$DOCKER_SIM_NWNAME" --filter "status=running" --filter "label=orana1sim" --format {{.Names}})
93                 for ric in $rics; do
94                         docker logs $ric > $1$2_$ric.log 2>&1
95                 done
96         fi
97 }
98
99 # Initial setup of protocol, host and ports
100 # This function is called for apps managed by the test script.
101 # args: -
102 __RICMEDIATORSIM_initial_setup() {
103         use_ricmediator_simulator_http
104 }
105
106 # Set app short-name, app name and namespace for logging runtime statistics of kubernetes pods or docker containers
107 # For docker, the namespace shall be excluded
108 # This function is called for apps managed by the test script as well as for pre-started apps.
109 # args: -
110 __RICMEDIATORSIM_statistics_setup() {
111         for ((RICMEDIATOR_SIMINSTANCE=10; RICMEDIATOR_SIMINSTANCE>0; RICMEDIATOR_SIMINSTANCE-- )); do
112                 if [ $RUNMODE == "KUBE" ]; then
113                         RICMEDIATOR_SIMINSTANCE_KUBE=$(($RICMEDIATOR_SIMINSTANCE-1))
114                         echo -n " RICMEDIATOR_SIMG1_$RICMEDIATOR_SIMINSTANCE_KUBE ${RICMEDIATOR_SIM_PREFIX}-g1-$RICMEDIATOR_SIMINSTANCE_KUBE $KUBE_A1SIM_NAMESPACE "
115                         echo -n " RICMEDIATOR_SIMG2_$RICMEDIATOR_SIMINSTANCE_KUBE ${RICMEDIATOR_SIM_PREFIX}-g2-$RICMEDIATOR_SIMINSTANCE_KUBE $KUBE_A1SIM_NAMESPACE "
116                         echo -n " RICMEDIATOR_SIMG3_$RICMEDIATOR_SIMINSTANCE_KUBE ${RICMEDIATOR_SIM_PREFIX}-g3-$RICMEDIATOR_SIMINSTANCE_KUBE $KUBE_A1SIM_NAMESPACE "
117                         echo -n " RICMEDIATOR_SIMG4_$RICMEDIATOR_SIMINSTANCE_KUBE ${RICMEDIATOR_SIM_PREFIX}-g4-$RICMEDIATOR_SIMINSTANCE_KUBE $KUBE_A1SIM_NAMESPACE "
118                 else
119                         if [ $DOCKER_COMPOSE_VERSION == "V1" ]; then
120                                 echo -n " RICMEDIATOR_SIMG1_$RICMEDIATOR_SIMINSTANCE ${RICMEDIATOR_SIM_PREFIX}_g1_$RICMEDIATOR_SIMINSTANCE "
121                                 echo -n " RICMEDIATOR_SIMG2_$RICMEDIATOR_SIMINSTANCE ${RICMEDIATOR_SIM_PREFIX}_g2_$RICMEDIATOR_SIMINSTANCE "
122                                 echo -n " RICMEDIATOR_SIMG3_$RICMEDIATOR_SIMINSTANCE ${RICMEDIATOR_SIM_PREFIX}_g3_$RICMEDIATOR_SIMINSTANCE "
123                                 echo -n " RICMEDIATOR_SIMG4_$RICMEDIATOR_SIMINSTANCE ${RICMEDIATOR_SIM_PREFIX}_g4_$RICMEDIATOR_SIMINSTANCE "
124                         else
125                                 echo -n " RICMEDIATOR_SIMG1_$RICMEDIATOR_SIMINSTANCE ${RICMEDIATOR_SIM_PREFIX}-g1-$RICMEDIATOR_SIMINSTANCE "
126                                 echo -n " RICMEDIATOR_SIMG2_$RICMEDIATOR_SIMINSTANCE ${RICMEDIATOR_SIM_PREFIX}-g2-$RICMEDIATOR_SIMINSTANCE "
127                                 echo -n " RICMEDIATOR_SIMG3_$RICMEDIATOR_SIMINSTANCE ${RICMEDIATOR_SIM_PREFIX}-g3-$RICMEDIATOR_SIMINSTANCE "
128                                 echo -n " RICMEDIATOR_SIMG4_$RICMEDIATOR_SIMINSTANCE ${RICMEDIATOR_SIM_PREFIX}-g4-$RICMEDIATOR_SIMINSTANCE "
129                         fi
130                 fi
131         done
132 }
133
134 # Check application requirements, e.g. helm, the the test needs. Exit 1 if req not satisfied
135 # args: -
136 __RICMEDIATORSIM_test_requirements() {
137         :
138 }
139
140 #######################################################
141
142
143 RICMEDIATOR_SIM_HTTPX="http"
144 RICMEDIATOR_SIM_PORT=$RICMEDIATOR_SIM_INTERNAL_PORT
145
146
147 #Vars for container count
148 G1_COUNT=0
149 G2_COUNT=0
150 G3_COUNT=0
151 G4_COUNT=0
152 G5_COUNT=0
153
154
155 ###########################
156 ### RICMEDIATOR Simulator functions
157 ###########################
158
159 use_ricmediator_simulator_http() {
160         echo -e $BOLD"RICMEDIATORSIM protocol setting"$EBOLD
161         echo -e " Using $BOLD http $EBOLD towards the simulators"
162         RICMEDIATOR_SIM_HTTPX="http"
163         RICMEDIATOR_SIM_PORT=$RICMEDIATOR_SIM_INTERNAL_PORT
164         echo ""
165 }
166
167 use_ricmediator_simulator_https() {
168         __log_test_fail_not_supported
169 }
170
171 # Start one group (ricsim_g1, ricsim_g2 .. ricsim_g5) with a number of RIC Simulators using a given A interface
172 # 'ricsim' may be set on command line to other prefix
173 # args:  ricsim_g1|ricsim_g2|ricsim_g3|ricsim_g4|ricsim_g5 <count> <interface-id>
174 # (Function for test scripts)
175 start_ricmediator_simulators() {
176
177         echo -e $BOLD"Starting $RICMEDIATOR_SIM_DISPLAY_NAME"$EBOLD
178
179         if [ $RUNMODE == "KUBE" ]; then
180
181                 # Check if app shall be fully managed by the test script
182                 __check_included_image "RICMEDIATORSIM"
183                 retcode_i=$?
184
185                 # Check if app shall only be used by the test script
186                 __check_prestarted_image "RICMEDIATORSIM"
187                 retcode_p=$?
188
189                 if [ $retcode_i -ne 0 ] && [ $retcode_p -ne 0 ]; then
190                         echo -e $RED"The $1 app is not included as managed nor prestarted in this test script"$ERED
191                         echo -e $RED"The $1 will not be started"$ERED
192                         exit
193                 fi
194                 if [ $retcode_i -eq 0 ] && [ $retcode_p -eq 0 ]; then
195                         echo -e $RED"The $1 stub app is included both as managed and prestarted in this test script"$ERED
196                         echo -e $RED"The $1 will not be started"$ERED
197                         exit
198                 fi
199
200                 if [ $retcode_p -eq 0 ]; then
201                         echo -e " Using existing $1 statefulset and service"
202                         echo " Using existing simulator deployment and service for statefulset $1"
203                         echo " Setting $1 replicas=$2"
204                         __kube_scale statefulset $1 $KUBE_A1SIM_NAMESPACE $2
205                         echo ""
206                         return
207                 fi
208         fi
209
210         RICMEDIATOR1=$RICMEDIATOR_SIM_PREFIX"_g1"
211         RICMEDIATOR2=$RICMEDIATOR_SIM_PREFIX"_g2"
212         RICMEDIATOR3=$RICMEDIATOR_SIM_PREFIX"_g3"
213         RICMEDIATOR4=$RICMEDIATOR_SIM_PREFIX"_g4"
214         RICMEDIATOR5=$RICMEDIATOR_SIM_PREFIX"_g5"
215
216         if [ $# != 3 ]; then
217                 ((RES_CONF_FAIL++))
218                 __print_err "need three args,  $RICMEDIATOR1|$RICMEDIATOR2|$RICMEDIATOR3|$RICMEDIATOR4|$RICMEDIATOR5 <count> <interface-id>" $@
219                 exit 1
220         fi
221
222         echo " $2 simulators using basename: $1 on interface: $3"
223         #Set env var for simulator count and A1 interface vesion for the given group
224         if [ $1 == "$RICMEDIATOR1" ]; then
225                 G1_COUNT=$2
226         elif [ $1 == "$RICMEDIATOR2" ]; then
227                 G2_COUNT=$2
228         elif [ $1 == "$RICMEDIATOR3" ]; then
229                 G3_COUNT=$2
230         elif [ $1 == "$RICMEDIATOR4" ]; then
231                 G4_COUNT=$2
232         elif [ $1 == "$RICMEDIATOR5" ]; then
233                 G5_COUNT=$2
234         else
235                 ((RES_CONF_FAIL++))
236                 __print_err "need three args, $RICMEDIATOR1|$RICMEDIATOR2|$RICMEDIATOR3|$RICMEDIATOR4|$RICMEDIATOR5 <count> <interface-id>" $@
237                 exit 1
238         fi
239
240         if [ $RUNMODE == "KUBE" ]; then
241
242                 if [ $retcode_i -eq 0 ]; then
243
244                         #export needed env var for statefulset
245                         export RICMEDIATOR_SIM_SET_NAME=$(echo "$1" | tr '_' '-')  #kube does not accept underscore in names
246                         export KUBE_A1SIM_NAMESPACE
247                         export RICMEDIATOR_SIM_IMAGE
248                         export RICMEDIATOR_SIM_DB_IMAGE
249                         #Adding 1 more instance, instance 0 is never used. This is done to keep test scripts compatible
250                         # with docker that starts instance index on 1.....
251                         export RICMEDIATOR_SIM_COUNT=$(($2+1))
252                         export A1_VERSION=$3
253                         export RICMEDIATOR_SIM_INTERNAL_PORT
254                         export RICMEDIATOR_SIM_INTERNAL_SECURE_PORT
255
256                         echo -e " Creating $RICMEDIATOR_SIM_PREFIX app and expose service"
257
258                         #Check if nonrtric namespace exists, if not create it
259                         __kube_create_namespace $KUBE_A1SIM_NAMESPACE
260
261                         # Create service
262                         input_yaml=$SIM_GROUP"/"$RICMEDIATOR_SIM_COMPOSE_DIR"/"svc.yaml
263                         output_yaml=$PWD/tmp/ric_${1}_svc.yaml
264                         __kube_create_instance service $RICMEDIATOR_SIM_SET_NAME $input_yaml $output_yaml
265
266                         # Create app
267                         input_yaml=$SIM_GROUP"/"$RICMEDIATOR_SIM_COMPOSE_DIR"/"app.yaml
268                         output_yaml=$PWD/tmp/ric_${1}_app.yaml
269                         __kube_create_instance app $RICMEDIATOR_SIM_SET_NAME $input_yaml $output_yaml
270
271                         #Using only instance from index 1 to keep compatability with docker
272                         for (( count=1; count<${RICMEDIATOR_SIM_COUNT}; count++ )); do
273                                 host=$(__find_ricmediatorsim_host $RICMEDIATOR_SIM_SET_NAME"-"$count)
274                                 __check_service_start $RICMEDIATOR_SIM_SET_NAME"-"$count $host$RICMEDIATOR_SIM_ALIVE_URL
275                         done
276                 fi
277         else
278                 __check_included_image 'RICMEDIATORSIM'
279                 if [ $? -eq 1 ]; then
280                         echo -e $RED"The Near-RT RICMEDIATOR Simulator app is not included as managed in this test script"$ERED
281                         echo -e $RED"Near-RT RICMEDIATOR Simulator will not be started"$ERED
282                         exit 1
283                 fi
284
285                 # Create .env file to compose project, all ric container will get this prefix
286                 echo "COMPOSE_PROJECT_NAME="$RICMEDIATOR_SIM_PREFIX > $SIM_GROUP/$RICMEDIATOR_SIM_COMPOSE_DIR/.env
287
288                 #extract service name (group), g1, g2, g3, g4 or g5 from var $1
289                 #E.g. ricsim_g1 -> g1 is the service name
290                 TMP_GRP=$1
291                 RICMEDIATOR_SIMCOMPOSE_SERVICE_NAME=$(echo "${TMP_GRP##*_}")
292
293                 export RICMEDIATOR_SIMCOMPOSE_A1_VERSION=$3
294                 export RICMEDIATOR_SIMCOMPOSE_SERVICE_NAME
295                 export RICMEDIATOR_SIM_INTERNAL_PORT
296                 export RICMEDIATOR_SIM_INTERNAL_SECURE_PORT
297                 export RICMEDIATOR_SIM_CERT_MOUNT_DIR
298                 export DOCKER_SIM_NWNAME
299                 export RICMEDIATOR_SIM_DISPLAY_NAME
300
301                 docker_args=" --scale $RICMEDIATOR_SIMCOMPOSE_SERVICE_NAME=$2"
302
303                 #Create a list of container names
304                 #Will be <ricsim-prefix>_<service-name>_<index>
305                 # or
306                 # <ricsim-prefix>-<service-name>-<index>
307                 app_data=""
308                 cntr=1
309                 if [ $DOCKER_COMPOSE_VERSION == "V1" ]; then
310                         app_name_prefix=$RICMEDIATOR_SIM_PREFIX"_"$RICMEDIATOR_SIMCOMPOSE_SERVICE_NAME"_"
311                 else
312                         app_name_prefix=$RICMEDIATOR_SIM_PREFIX"-"$RICMEDIATOR_SIMCOMPOSE_SERVICE_NAME"-"
313                 fi
314                 while [ $cntr -le $2 ]; do
315                         app=$app_name_prefix$cntr
316                         app_data="$app_data $app"
317                         let cntr=cntr+1
318                 done
319
320                 __start_container $RICMEDIATOR_SIM_COMPOSE_DIR "" "$docker_args" $2 $app_data
321
322                 cntr=1
323                 while [ $cntr -le $2 ]; do
324                         if [ $DOCKER_COMPOSE_VERSION == "V1" ]; then
325                                 app=$RICMEDIATOR_SIM_PREFIX"_"$RICMEDIATOR_SIMCOMPOSE_SERVICE_NAME"_"$cntr
326                         else
327                                 app=$RICMEDIATOR_SIM_PREFIX"-"$RICMEDIATOR_SIMCOMPOSE_SERVICE_NAME"-"$cntr
328                         fi
329                         __check_service_start $app $RICMEDIATOR_SIM_HTTPX"://"$app:$RICMEDIATOR_SIM_PORT$RICMEDIATOR_SIM_ALIVE_URL
330                         let cntr=cntr+1
331                 done
332
333         fi
334         echo ""
335         return 0
336 }
337
338 # Translate ric name to kube host name
339 # args: <ric-name>
340 # For test scripts
341 get_kube_ricmediatorsim_host() {
342         name=$(echo "$1" | tr '_' '-')  #kube does not accept underscore in names
343         #example gnb_1_2 -> gnb-1-2
344         set_name=$(echo $name | rev | cut -d- -f2- | rev) # Cut index part of ric name to get the name of statefulset
345         # example gnb-g1-2 -> gnb-g1 where gnb-g1-2 is the ric name and gnb-g1 is the set name
346         echo $name"."$set_name"."$KUBE_A1SIM_NAMESPACE
347 }
348
349 # Helper function to get a the port and host name of a specific ric simulator
350 # args: <ric-id>
351 # (Not for test scripts)
352 __find_ricmediatorsim_host() {
353         if [ $RUNMODE == "KUBE" ]; then
354                 ricname=$(echo "$1" | tr '_' '-') # Kube does not accept underscore in names as docker do
355                 if [ -z "$RICMEDIATOR_SIM_COMMON_SVC_NAME" ]; then
356                         ric_setname="${ricname%-*}"  #Extract the stateful set name
357                 else
358                         ric_setname=$RICMEDIATOR_SIM_COMMON_SVC_NAME # Use the common svc name in the host name of the sims
359                 fi
360                 echo $RICMEDIATOR_SIM_HTTPX"://"$ricname.$ric_setname.$KUBE_A1SIM_NAMESPACE":"$RICMEDIATOR_SIM_PORT
361         else
362                 if [ $DOCKER_COMPOSE_VERSION == "V1" ]; then
363                         echo $RICMEDIATOR_SIM_HTTPX"://"$1":"$RICMEDIATOR_SIM_PORT
364                 else
365                         ricname=$(echo "$1" | tr '_' '-')
366                         echo $RICMEDIATOR_SIM_HTTPX"://"$ricname":"$RICMEDIATOR_SIM_PORT
367                 fi
368
369         fi
370 }
371
372 # Generate a UUID to use as prefix for policy ids
373 nearsim_generate_policy_uuid() {
374         UUID=$(python3 -c 'import sys,uuid; sys.stdout.write(uuid.uuid4().hex)')
375         #Reduce length to make space for serial id, uses 'a' as marker where the serial id is added
376         UUID=${UUID:0:${#UUID}-4}"a"
377 }
378
379 # Execute a curl cmd towards a ricsimulator and check the response code.
380 # args: <expected-response-code> <curl-cmd-string>
381 __execute_curl_to_ricmediatorsim() {
382         echo ${FUNCNAME[1]} "line: "${BASH_LINENO[1]} >> $HTTPLOG
383         proxyflag=""
384         if [ ! -z "$KUBE_PROXY_PATH" ]; then
385                 if [ $KUBE_PROXY_HTTPX == "http" ]; then
386                         proxyflag=" --proxy $KUBE_PROXY_PATH"
387                 else
388                         proxyflag=" --proxy-insecure --proxy $KUBE_PROXY_PATH"
389                 fi
390         fi
391         if [ -z "$KUBE_PROXY_CURL_JWT" ]; then
392                 echo " CMD: $2 $proxyflag" >> $HTTPLOG
393                 res="$($2 $proxyflag)"
394         else
395                 echo " CMD: $2 $proxyflag -H Authorization: Bearer $KUBE_PROXY_CURL_JWT" >> $HTTPLOG
396                 res=$($2 $proxyflag -H 'Authorization: Bearer '$KUBE_PROXY_CURL_JWT)
397         fi
398
399         echo " RESP: $res" >> $HTTPLOG
400         retcode=$?
401     if [ $retcode -ne 0 ]; then
402                 ((RES_CONF_FAIL++))
403                 echo " RETCODE: "$retcode
404         echo -e $RED" FAIL - fatal error when executing curl."$ERED
405         return 1
406     fi
407     status=${res:${#res}-3}
408     if [ $status -eq $1 ]; then
409         echo -e $GREEN" OK"$EGREEN
410         return 0
411     fi
412     echo -e $RED" FAIL - expected http response: "$1" but got http response: "$status $ERED
413         ((RES_CONF_FAIL++))
414     return 1
415 }
416
417 # Tests if a variable value in the ricsimulator is equal to a target value and and optional timeout.
418 # Arg: <ric-id> <variable-name> <target-value> - This test set pass or fail depending on if the variable is
419 # equal to the target or not.
420 # Arg: <ric-id> <variable-name> <target-value> <timeout-in-sec>  - This test waits up to the timeout seconds
421 # before setting pass or fail depending on if the variable value becomes equal to the target
422 # value or not.
423 # (Function for test scripts)
424 ricmediatorsim_equal() {
425         __log_test_fail_not_supported
426 }
427
428 # Print a variable value from the RICMEDIATOR sim.
429 # args: <ric-id> <variable-name>
430 # (Function for test scripts)
431 ricmediatorsim_print() {
432         __log_test_info_not_supported
433 }
434
435 # Tests if a variable value in the RICMEDIATOR simulator contains the target string and and optional timeout
436 # Arg: <ric-id> <variable-name> <target-value> - This test set pass or fail depending on if the variable contains
437 # the target or not.
438 # Arg: <ric-id> <variable-name> <target-value> <timeout-in-sec>  - This test waits up to the timeout seconds
439 # before setting pass or fail depending on if the variable value contains the target
440 # value or not.
441 # (Function for test scripts)
442 ricmediatorsim_contains_str() {
443         __log_test_fail_not_supported
444 }
445
446 # Simulator API: Put a policy type in a ric
447 # args: <response-code> <ric-id> <policy-type-id> <policy-type-file>
448 # (Function for test scripts)
449 ricmediatorsim_put_policy_type() {
450         __log_conf_start $@
451         if [ $# -ne 4 ]; then
452                 __print_err "<response-code> <ric-id> <policy-type-id> <policy-type-file>" $@
453                 return 1
454         fi
455         host=$(__find_ricmediatorsim_host $2)
456     curlString="curl -X PUT -skw %{http_code} "$host"/a1-p/policytypes/"$3" -H Content-Type:application/json --data-binary @"$4
457         __execute_curl_to_ricmediatorsim $1 "$curlString"
458         return $?
459 }
460
461 # Simulator API: Delete a policy type in a ric
462 # <response-code> <ric-id> <policy-type-id>
463 # (Function for test scripts)
464 ricmediatorsim_delete_policy_type() {
465         __log_conf_start $@
466         if [ $# -ne 3 ]; then
467                 __print_err "<response-code> <ric-id> <policy_type_id>" $@
468                 return 1
469         fi
470         host=$(__find_ricmediatorsim_host $2)
471     curlString="curl -X DELETE -skw %{http_code} "$host"/a1-p/policytypes/"$3
472     __execute_curl_to_ricmediatorsim $1 "$curlString"
473         return $?
474 }
475
476 # Simulator API: Delete instances (and status), for one ric
477 # <response-code> <ric-id>
478 # (Function for test scripts)
479 ricmediatorsim_post_delete_instances() {
480         __log_test_fail_not_supported
481 }
482
483 # Simulator API: Delete all (instances/types/statuses/settings), for one ric
484 # <response-code> <ric-id>
485 # (Function for test scripts)
486 ricmediatorsim_post_delete_all() {
487         __log_test_fail_not_supported
488 }
489
490 # Simulator API: Set (or reset) response code for next A1 message, for one ric
491 # <response-code> <ric-id> [<forced_response_code>]
492 # (Function for test scripts)
493 ricmediatorsim_post_forcedresponse() {
494         __log_test_fail_not_supported
495 }
496
497 # Simulator API: Set (or reset) A1 response delay, for one ric
498 # <response-code> <ric-id> [<delay-in-seconds>]
499 # (Function for test scripts)
500 ricmediatorsim_post_forcedelay() {
501         __log_test_fail_not_supported
502 }