# ============LICENSE_START===============================================
# Copyright (C) 2021-2023 Nordix Foundation. All rights reserved.
+# Copyright (C) 2024 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.
echo $YELLOW"Warning: No rics found for the configuration"$EYELLOW
fi
else
- rics=$(docker ps --filter "name=$RIC_SIM_PREFIX" --filter "network=$DOCKER_SIM_NWNAME" --filter "label=a1sim" --filter "status=running" --format {{.Names}})
- if [ $? -ne 0 ] || [ -z "$rics" ]; then
- echo -e $RED" FAIL - the names of the running RIC Simulator cannot be retrieved." $ERED
- ((RES_CONF_FAIL++))
- return 1
- fi
+ rics=$(docker ps --filter "name=$RIC_SIM_PREFIX" --filter "network=$DOCKER_SIM_NWNAME" --filter "label=a1sim" --filter "status=running" --format {{.Names}})
oranrics=$(docker ps --filter "name=$RIC_SIM_PREFIX" --filter "network=$DOCKER_SIM_NWNAME" --filter "label=orana1sim" --filter "status=running" --format {{.Names}})
+
+ rics="$rics $oranrics"
+
if [ $? -ne 0 ] || [ -z "$rics" ]; then
- echo -e $RED" FAIL - the names of the running RIC Simulator cannot be retrieved." $ERED
+ echo -e $RED" FAIL - the names of the running RIC Simulator or ORAN RIC cannot be retrieved." $ERED
((RES_CONF_FAIL++))
- return 1
+ exit 1
fi
- rics="$rics $oranrics"
fi
cntr=0
for ric in $rics; do
ric_id=${ric%.*.*} #extract pod id from full hosthame
ric_id=$(echo "$ric_id" | tr '-' '_')
else
- if [ $DOCKER_COMPOSE_VERSION == "V1" ]; then
- ric_id=$ric
- else
- ric_id=$(echo "$ric" | tr '-' '_') #ric id still needs underscore as it is different from the container name
- fi
+ ric_id=$(echo "$ric" | tr '-' '_') #ric var still needs underscore as it is different from the container name
fi
- echo " Found a1 sim: "$ric_id
+ echo " Found a1 sim: "$ric
config_json=$config_json"\n \"name\": \"$ric_id\","
xricfound=0
#if [ $A1PMS_ADAPTER != $RESTBASE ] && [ $A1PMS_ADAPTER != $RESTBASE_SECURE ]; then
if [ $A1PMS_ADAPTER_TYPE != "REST" ]; then
- echo " Info - a1pms_api_delete_policy_parallel uses only the a1pms REST interface - create over dmaap in parallel is not supported"
+ echo " Info - a1pms_api_delete_policy_parallel uses only the a1pms REST interface - delete over dmaap in parallel is not supported"
echo " Info - will execute over a1pms REST"
fi
return 1
}
+# API Test function: GET /policy and V2 GET /v2/policies/{policy_id}, to run in i parallel for a number of rics
+# args: <response-code> <number-of-rics> <policy-start-id> <count-per-ric> <number-of-threads>
+# (Function for test scripts)
+a1pms_api_get_policy_parallel() {
+ __log_test_start $@
+
+ if [ $# -ne 5 ]; then
+ __print_err " <response-code> <ric-id-base> <number-of-rics> <policy-start-id> <count-per-ric> <number-of-threads>" $@
+ return 1
+ fi
+ resp_code=$1; shift;
+ num_rics=$1; shift;
+ start_id=$1; shift;
+ count=$1; shift;
+ pids=$1; shift;
+
+ #if [ $A1PMS_ADAPTER != $RESTBASE ] && [ $A1PMS_ADAPTER != $RESTBASE_SECURE ]; then
+ if [ $A1PMS_ADAPTER_TYPE != "REST" ]; then
+ echo " Info - a1pms_api_get_policy_parallel uses only the a1pms REST interface - GET over dmaap in parallel is not supported"
+ echo " Info - will execute over a1pms REST"
+ fi
+
+ if [ "$A1PMS_VERSION" == "V2" ]; then
+ query="$A1PMS_API_PREFIX/v2/policies/"
+ else
+ query="/policy"
+ fi
+
+ urlbase=${A1PMS_ADAPTER}${query}
+
+ httpproxy="NOPROXY"
+ if [ ! -z "$KUBE_PROXY_PATH" ]; then
+ httpproxy=$KUBE_PROXY_PATH
+ fi
+
+ for ((i=1; i<=$pids; i++))
+ do
+ uuid=$UUID
+ if [ -z "$uuid" ]; then
+ uuid="NOUUID"
+ fi
+ echo "" > "./tmp/.pid${i}.get.res.txt"
+ echo $resp_code $urlbase $num_rics $uuid $start_id $count $pids $i $httpproxy> "./tmp/.pid${i}.get.txt"
+ echo $i
+ done | xargs -n 1 -I{} -P $pids bash -c '{
+ arg=$(echo {})
+ echo " Parallel process $arg started"
+ tmp=$(< "./tmp/.pid${arg}.get.txt")
+ python3 ../common/get_policies_process.py $tmp > ./tmp/.pid${arg}.get.res.txt
+ }'
+ msg=""
+ for ((i=1; i<=$pids; i++))
+ do
+ file="./tmp/.pid${i}.get.res.txt"
+ tmp=$(< $file)
+ if [ -z "$tmp" ]; then
+ echo " Process $i : unknown result (result file empty"
+ msg="failed"
+ else
+ res=${tmp:0:1}
+ if [ $res == "0" ]; then
+ echo " Process $i : OK - "${tmp:1}
+ else
+ echo " Process $i : failed - "${tmp:1}
+ msg="failed"
+ fi
+ fi
+ done
+ if [ -z $msg ]; then
+ __collect_endpoint_stats "A1PMS" 04 "GET" $A1PMS_API_PREFIX"/v2/policies/{policy_id}" $resp_code $(($count*$num_rics))
+ __log_test_pass " $(($count*$num_rics)) policy request(s) executed"
+ return 0
+ fi
+
+ __log_test_fail_general "One of more processes failed to execute"
+ return 1
+}
+
# API Test function: GET /policy_ids and V2 GET /v2/policies
# args: <response-code> <ric-id>|NORIC <service-id>|NOSERVICE <type-id>|NOTYPE ([<policy-instance-id]*|NOID)
# (Function for test scripts)
fi
targetJson=$targetJson"}"
elif [ "$3" == "OSC" ]; then
- targetJson="{\"instance_status\":\"$4\""
- if [ $# -eq 5 ]; then
- targetJson=$targetJson",\"has_been_deleted\":\"$5\""
- fi
- targetJson=$targetJson",\"created_at\":\"????\"}"
+ if [[ $TEST_ENV_PROFILE =~ ^ORAN-[A-H] ]] || [[ $TEST_ENV_PROFILE =~ ^ONAP-[A-L] ]]; then
+ targetJson="{\"instance_status\":\"$4\""
+ if [ $# -eq 5 ]; then
+ targetJson=$targetJson",\"has_been_deleted\":\"$5\""
+ fi
+ targetJson=$targetJson",\"created_at\":\"????\"}"
+ else
+ targetJson="{\"enforceStatus\":\"$4\""
+ if [ $# -eq 5 ]; then
+ targetJson=$targetJson",\"enforceReason\":\"$5\"}"
+ fi
+ fi
else
__print_err "<response-code> (STD <enforce-status> [<reason>])|(OSC <instance-status> <has-been-deleted>)" $@
return 1