Update test env to remove '-' in ric hostnames
[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                         echo -n " RICMEDIATOR_SIMG1_$RICMEDIATOR_SIMINSTANCE ${RICMEDIATOR_SIM_PREFIX}-g1-$RICMEDIATOR_SIMINSTANCE "
120                         echo -n " RICMEDIATOR_SIMG2_$RICMEDIATOR_SIMINSTANCE ${RICMEDIATOR_SIM_PREFIX}-g2-$RICMEDIATOR_SIMINSTANCE "
121                         echo -n " RICMEDIATOR_SIMG3_$RICMEDIATOR_SIMINSTANCE ${RICMEDIATOR_SIM_PREFIX}-g3-$RICMEDIATOR_SIMINSTANCE "
122                         echo -n " RICMEDIATOR_SIMG4_$RICMEDIATOR_SIMINSTANCE ${RICMEDIATOR_SIM_PREFIX}-g4-$RICMEDIATOR_SIMINSTANCE "
123                 fi
124         done
125 }
126
127 # Check application requirements, e.g. helm, the the test needs. Exit 1 if req not satisfied
128 # args: -
129 __RICMEDIATORSIM_test_requirements() {
130         :
131 }
132
133 #######################################################
134
135
136 RICMEDIATOR_SIM_HTTPX="http"
137 RICMEDIATOR_SIM_PORT=$RICMEDIATOR_SIM_INTERNAL_PORT
138
139
140 #Vars for container count
141 G1_COUNT=0
142 G2_COUNT=0
143 G3_COUNT=0
144 G4_COUNT=0
145 G5_COUNT=0
146
147
148 ###########################
149 ### RICMEDIATOR Simulator functions
150 ###########################
151
152 use_ricmediator_simulator_http() {
153         echo -e $BOLD"RICMEDIATORSIM protocol setting"$EBOLD
154         echo -e " Using $BOLD http $EBOLD towards the simulators"
155         RICMEDIATOR_SIM_HTTPX="http"
156         RICMEDIATOR_SIM_PORT=$RICMEDIATOR_SIM_INTERNAL_PORT
157         echo ""
158 }
159
160 use_ricmediator_simulator_https() {
161         __log_test_fail_not_supported
162 }
163
164 # Start one group (ricsim_g1, ricsim_g2 .. ricsim_g5) with a number of RIC Simulators using a given A interface
165 # 'ricsim' may be set on command line to other prefix
166 # args:  ricsim_g1|ricsim_g2|ricsim_g3|ricsim_g4|ricsim_g5 <count> <interface-id>
167 # (Function for test scripts)
168 start_ricmediator_simulators() {
169
170         echo -e $BOLD"Starting $RICMEDIATOR_SIM_DISPLAY_NAME"$EBOLD
171
172         if [ $RUNMODE == "KUBE" ]; then
173
174                 # Check if app shall be fully managed by the test script
175                 __check_included_image "RICMEDIATORSIM"
176                 retcode_i=$?
177
178                 # Check if app shall only be used by the test script
179                 __check_prestarted_image "RICMEDIATORSIM"
180                 retcode_p=$?
181
182                 if [ $retcode_i -ne 0 ] && [ $retcode_p -ne 0 ]; then
183                         echo -e $RED"The $1 app is not included as managed nor prestarted in this test script"$ERED
184                         echo -e $RED"The $1 will not be started"$ERED
185                         exit
186                 fi
187                 if [ $retcode_i -eq 0 ] && [ $retcode_p -eq 0 ]; then
188                         echo -e $RED"The $1 stub app is included both as managed and prestarted in this test script"$ERED
189                         echo -e $RED"The $1 will not be started"$ERED
190                         exit
191                 fi
192
193                 if [ $retcode_p -eq 0 ]; then
194                         echo -e " Using existing $1 statefulset and service"
195                         echo " Using existing simulator deployment and service for statefulset $1"
196                         echo " Setting $1 replicas=$2"
197                         __kube_scale statefulset $1 $KUBE_A1SIM_NAMESPACE $2
198                         echo ""
199                         return
200                 fi
201         fi
202
203         RICMEDIATOR1=$RICMEDIATOR_SIM_PREFIX"_g1"
204         RICMEDIATOR2=$RICMEDIATOR_SIM_PREFIX"_g2"
205         RICMEDIATOR3=$RICMEDIATOR_SIM_PREFIX"_g3"
206         RICMEDIATOR4=$RICMEDIATOR_SIM_PREFIX"_g4"
207         RICMEDIATOR5=$RICMEDIATOR_SIM_PREFIX"_g5"
208
209         if [ $# != 3 ]; then
210                 ((RES_CONF_FAIL++))
211                 __print_err "need three args,  $RICMEDIATOR1|$RICMEDIATOR2|$RICMEDIATOR3|$RICMEDIATOR4|$RICMEDIATOR5 <count> <interface-id>" $@
212                 exit 1
213         fi
214
215         echo " $2 simulators using basename: $1 on interface: $3"
216         #Set env var for simulator count and A1 interface vesion for the given group
217         if [ $1 == "$RICMEDIATOR1" ]; then
218                 G1_COUNT=$2
219         elif [ $1 == "$RICMEDIATOR2" ]; then
220                 G2_COUNT=$2
221         elif [ $1 == "$RICMEDIATOR3" ]; then
222                 G3_COUNT=$2
223         elif [ $1 == "$RICMEDIATOR4" ]; then
224                 G4_COUNT=$2
225         elif [ $1 == "$RICMEDIATOR5" ]; then
226                 G5_COUNT=$2
227         else
228                 ((RES_CONF_FAIL++))
229                 __print_err "need three args, $RICMEDIATOR1|$RICMEDIATOR2|$RICMEDIATOR3|$RICMEDIATOR4|$RICMEDIATOR5 <count> <interface-id>" $@
230                 exit 1
231         fi
232
233         if [ $RUNMODE == "KUBE" ]; then
234
235                 if [ $retcode_i -eq 0 ]; then
236
237                         #export needed env var for statefulset
238                         export RICMEDIATOR_SIM_SET_NAME=$(echo "$1" | tr '_' '-')  #kube does not accept underscore in names
239                         export KUBE_A1SIM_NAMESPACE
240                         export RICMEDIATOR_SIM_IMAGE
241                         export RICMEDIATOR_SIM_DB_IMAGE
242                         #Adding 1 more instance, instance 0 is never used. This is done to keep test scripts compatible
243                         # with docker that starts instance index on 1.....
244                         export RICMEDIATOR_SIM_COUNT=$(($2+1))
245                         export A1_VERSION=$3
246                         export RICMEDIATOR_SIM_INTERNAL_PORT
247                         export RICMEDIATOR_SIM_INTERNAL_SECURE_PORT
248
249                         echo -e " Creating $RICMEDIATOR_SIM_PREFIX app and expose service"
250
251                         #Check if nonrtric namespace exists, if not create it
252                         __kube_create_namespace $KUBE_A1SIM_NAMESPACE
253
254                         # Create service
255                         input_yaml=$SIM_GROUP"/"$RICMEDIATOR_SIM_COMPOSE_DIR"/"svc.yaml
256                         output_yaml=$PWD/tmp/ric_${1}_svc.yaml
257                         __kube_create_instance service $RICMEDIATOR_SIM_SET_NAME $input_yaml $output_yaml
258
259                         # Create app
260                         input_yaml=$SIM_GROUP"/"$RICMEDIATOR_SIM_COMPOSE_DIR"/"app.yaml
261                         output_yaml=$PWD/tmp/ric_${1}_app.yaml
262                         __kube_create_instance app $RICMEDIATOR_SIM_SET_NAME $input_yaml $output_yaml
263
264                         #Using only instance from index 1 to keep compatability with docker
265                         for (( count=1; count<${RICMEDIATOR_SIM_COUNT}; count++ )); do
266                                 host=$(__find_ricmediatorsim_host $RICMEDIATOR_SIM_SET_NAME"-"$count)
267                                 __check_service_start $RICMEDIATOR_SIM_SET_NAME"-"$count $host$RICMEDIATOR_SIM_ALIVE_URL
268                         done
269                 fi
270         else
271                 __check_included_image 'RICMEDIATORSIM'
272                 if [ $? -eq 1 ]; then
273                         echo -e $RED"The Near-RT RICMEDIATOR Simulator app is not included as managed in this test script"$ERED
274                         echo -e $RED"Near-RT RICMEDIATOR Simulator will not be started"$ERED
275                         exit 1
276                 fi
277
278                 # Create .env file to compose project, all ric container will get this prefix
279                 echo "COMPOSE_PROJECT_NAME="$RICMEDIATOR_SIM_PREFIX > $SIM_GROUP/$RICMEDIATOR_SIM_COMPOSE_DIR/.env
280
281                 #extract service name (group), g1, g2, g3, g4 or g5 from var $1
282                 #E.g. ricsim_g1 -> g1 is the service name
283                 TMP_GRP=$1
284                 RICMEDIATOR_SIMCOMPOSE_SERVICE_NAME=$(echo "${TMP_GRP##*_}")
285
286                 export RICMEDIATOR_SIMCOMPOSE_A1_VERSION=$3
287                 export RICMEDIATOR_SIMCOMPOSE_SERVICE_NAME
288                 export RICMEDIATOR_SIM_INTERNAL_PORT
289                 export RICMEDIATOR_SIM_INTERNAL_SECURE_PORT
290                 export RICMEDIATOR_SIM_CERT_MOUNT_DIR
291                 export DOCKER_SIM_NWNAME
292                 export RICMEDIATOR_SIM_DISPLAY_NAME
293
294                 docker_args=" --scale $RICMEDIATOR_SIMCOMPOSE_SERVICE_NAME=$2"
295
296                 #Create a list of container names
297                 #Will be <ricsim-prefix>_<service-name>_<index>
298                 # or
299                 # <ricsim-prefix>-<service-name>-<index>
300                 app_data=""
301                 cntr=1
302                 app_name_prefix=$RICMEDIATOR_SIM_PREFIX"-"$RICMEDIATOR_SIMCOMPOSE_SERVICE_NAME"-"
303                 while [ $cntr -le $2 ]; do
304                         app=$app_name_prefix$cntr
305                         app_data="$app_data $app"
306                         let cntr=cntr+1
307                 done
308
309                 __start_container $RICMEDIATOR_SIM_COMPOSE_DIR "" "$docker_args" $2 $app_data
310
311                 cntr=1
312                 while [ $cntr -le $2 ]; do
313                         app=$RICMEDIATOR_SIM_PREFIX"-"$RICMEDIATOR_SIMCOMPOSE_SERVICE_NAME"-"$cntr
314                         __check_service_start $app $RICMEDIATOR_SIM_HTTPX"://"$app:$RICMEDIATOR_SIM_PORT$RICMEDIATOR_SIM_ALIVE_URL
315                         let cntr=cntr+1
316                 done
317
318         fi
319         echo ""
320         return 0
321 }
322
323 # Translate ric name to kube host name
324 # args: <ric-name>
325 # For test scripts
326 get_kube_ricmediatorsim_host() {
327         name=$(echo "$1" | tr '_' '-')  #kube does not accept underscore in names
328         #example gnb_1_2 -> gnb-1-2
329         set_name=$(echo $name | rev | cut -d- -f2- | rev) # Cut index part of ric name to get the name of statefulset
330         # example gnb-g1-2 -> gnb-g1 where gnb-g1-2 is the ric name and gnb-g1 is the set name
331         echo $name"."$set_name"."$KUBE_A1SIM_NAMESPACE
332 }
333
334 # Helper function to get a the port and host name of a specific ric simulator
335 # args: <ric-id>
336 # (Not for test scripts)
337 __find_ricmediatorsim_host() {
338         if [ $RUNMODE == "KUBE" ]; then
339                 ricname=$(echo "$1" | tr '_' '-') # Kube does not accept underscore in names as docker do
340                 if [ -z "$RICMEDIATOR_SIM_COMMON_SVC_NAME" ]; then
341                         ric_setname="${ricname%-*}"  #Extract the stateful set name
342                 else
343                         ric_setname=$RICMEDIATOR_SIM_COMMON_SVC_NAME # Use the common svc name in the host name of the sims
344                 fi
345                 echo $RICMEDIATOR_SIM_HTTPX"://"$ricname.$ric_setname.$KUBE_A1SIM_NAMESPACE":"$RICMEDIATOR_SIM_PORT
346         else
347                 ricname=$(echo "$1" | tr '_' '-')
348                 echo $RICMEDIATOR_SIM_HTTPX"://"$ricname":"$RICMEDIATOR_SIM_PORT
349         fi
350 }
351
352 # Generate a UUID to use as prefix for policy ids
353 nearsim_generate_policy_uuid() {
354         UUID=$(python3 -c 'import sys,uuid; sys.stdout.write(uuid.uuid4().hex)')
355         #Reduce length to make space for serial id, uses 'a' as marker where the serial id is added
356         UUID=${UUID:0:${#UUID}-4}"a"
357 }
358
359 # Execute a curl cmd towards a ricsimulator and check the response code.
360 # args: <expected-response-code> <curl-cmd-string>
361 __execute_curl_to_ricmediatorsim() {
362         echo ${FUNCNAME[1]} "line: "${BASH_LINENO[1]} >> $HTTPLOG
363         proxyflag=""
364         if [ ! -z "$KUBE_PROXY_PATH" ]; then
365                 if [ $KUBE_PROXY_HTTPX == "http" ]; then
366                         proxyflag=" --proxy $KUBE_PROXY_PATH"
367                 else
368                         proxyflag=" --proxy-insecure --proxy $KUBE_PROXY_PATH"
369                 fi
370         fi
371         if [ -z "$KUBE_PROXY_CURL_JWT" ]; then
372                 echo " CMD: $2 $proxyflag" >> $HTTPLOG
373                 res="$($2 $proxyflag)"
374         else
375                 echo " CMD: $2 $proxyflag -H Authorization: Bearer $KUBE_PROXY_CURL_JWT" >> $HTTPLOG
376                 res=$($2 $proxyflag -H 'Authorization: Bearer '$KUBE_PROXY_CURL_JWT)
377         fi
378
379         echo " RESP: $res" >> $HTTPLOG
380         retcode=$?
381     if [ $retcode -ne 0 ]; then
382                 ((RES_CONF_FAIL++))
383                 echo " RETCODE: "$retcode
384         echo -e $RED" FAIL - fatal error when executing curl."$ERED
385         return 1
386     fi
387     status=${res:${#res}-3}
388     if [ $status -eq $1 ]; then
389         echo -e $GREEN" OK"$EGREEN
390         return 0
391     fi
392     echo -e $RED" FAIL - expected http response: "$1" but got http response: "$status $ERED
393         ((RES_CONF_FAIL++))
394     return 1
395 }
396
397 # Tests if a variable value in the ricsimulator is equal to a target value and and optional timeout.
398 # Arg: <ric-id> <variable-name> <target-value> - This test set pass or fail depending on if the variable is
399 # equal to the target or not.
400 # Arg: <ric-id> <variable-name> <target-value> <timeout-in-sec>  - This test waits up to the timeout seconds
401 # before setting pass or fail depending on if the variable value becomes equal to the target
402 # value or not.
403 # (Function for test scripts)
404 ricmediatorsim_equal() {
405         __log_test_fail_not_supported
406 }
407
408 # Print a variable value from the RICMEDIATOR sim.
409 # args: <ric-id> <variable-name>
410 # (Function for test scripts)
411 ricmediatorsim_print() {
412         __log_test_info_not_supported
413 }
414
415 # Tests if a variable value in the RICMEDIATOR simulator contains the target string and and optional timeout
416 # Arg: <ric-id> <variable-name> <target-value> - This test set pass or fail depending on if the variable contains
417 # the target or not.
418 # Arg: <ric-id> <variable-name> <target-value> <timeout-in-sec>  - This test waits up to the timeout seconds
419 # before setting pass or fail depending on if the variable value contains the target
420 # value or not.
421 # (Function for test scripts)
422 ricmediatorsim_contains_str() {
423         __log_test_fail_not_supported
424 }
425
426 # Simulator API: Put a policy type in a ric
427 # args: <response-code> <ric-id> <policy-type-id> <policy-type-file>
428 # (Function for test scripts)
429 ricmediatorsim_put_policy_type() {
430         __log_conf_start $@
431         if [ $# -ne 4 ]; then
432                 __print_err "<response-code> <ric-id> <policy-type-id> <policy-type-file>" $@
433                 return 1
434         fi
435         host=$(__find_ricmediatorsim_host $2)
436     curlString="curl -X PUT -skw %{http_code} "$host"/a1-p/policytypes/"$3" -H Content-Type:application/json --data-binary @"$4
437         __execute_curl_to_ricmediatorsim $1 "$curlString"
438         return $?
439 }
440
441 # Simulator API: Delete a policy type in a ric
442 # <response-code> <ric-id> <policy-type-id>
443 # (Function for test scripts)
444 ricmediatorsim_delete_policy_type() {
445         __log_conf_start $@
446         if [ $# -ne 3 ]; then
447                 __print_err "<response-code> <ric-id> <policy_type_id>" $@
448                 return 1
449         fi
450         host=$(__find_ricmediatorsim_host $2)
451     curlString="curl -X DELETE -skw %{http_code} "$host"/a1-p/policytypes/"$3
452     __execute_curl_to_ricmediatorsim $1 "$curlString"
453         return $?
454 }
455
456 # Simulator API: Delete instances (and status), for one ric
457 # <response-code> <ric-id>
458 # (Function for test scripts)
459 ricmediatorsim_post_delete_instances() {
460         __log_test_fail_not_supported
461 }
462
463 # Simulator API: Delete all (instances/types/statuses/settings), for one ric
464 # <response-code> <ric-id>
465 # (Function for test scripts)
466 ricmediatorsim_post_delete_all() {
467         __log_test_fail_not_supported
468 }
469
470 # Simulator API: Set (or reset) response code for next A1 message, for one ric
471 # <response-code> <ric-id> [<forced_response_code>]
472 # (Function for test scripts)
473 ricmediatorsim_post_forcedresponse() {
474         __log_test_fail_not_supported
475 }
476
477 # Simulator API: Set (or reset) A1 response delay, for one ric
478 # <response-code> <ric-id> [<delay-in-seconds>]
479 # (Function for test scripts)
480 ricmediatorsim_post_forcedelay() {
481         __log_test_fail_not_supported
482 }