From: JohnKeeney Date: Fri, 22 Mar 2024 16:56:46 +0000 (+0000) Subject: Tests: extend FTC850 benchmark test to include GETs X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;h=2f3b268bbbe457a9b5078670dae7e78571bdb265;p=nonrtric.git Tests: extend FTC850 benchmark test to include GETs Change-Id: Id8764c97478e76b686a9bbc36b4a15470cfd39bb Signed-off-by: JohnKeeney Issue-ID: NONRTRIC-995 --- diff --git a/test/auto-test/FTC850.sh b/test/auto-test/FTC850.sh index 0b08417b..d228eee5 100755 --- a/test/auto-test/FTC850.sh +++ b/test/auto-test/FTC850.sh @@ -2,7 +2,7 @@ # ============LICENSE_START=============================================== # Copyright (C) 2020-2023 Nordix Foundation. All rights reserved. -# Copyright (C) 2023 OpenInfra Foundation Europe. All rights reserved. +# Copyright (C) 2023-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. @@ -182,6 +182,21 @@ for __httpx in $TESTED_PROTOCOLS ; do sim_equal ricsim_g1_$i num_instances $NUM_POLICIES_PER_RIC done + + start_timer "GET $((NUM_POLICIES_PER_RIC*$NUM_RICS)) polices over $interface using "$__httpx + + a1pms_api_get_policy_parallel 200 $NUM_RICS $START_ID $NUM_POLICIES_PER_RIC 7 + + print_timer "GET $((NUM_POLICIES_PER_RIC*$NUM_RICS)) polices over $interface using "$__httpx + + INSTANCES=$(($NUM_RICS*$NUM_POLICIES_PER_RIC)) + a1pms_equal json:policies $INSTANCES + + for ((i=1; i<=$NUM_RICS; i++)) + do + sim_equal ricsim_g1_$i num_instances $NUM_POLICIES_PER_RIC + done + start_timer "Delete $((NUM_POLICIES_PER_RIC*$NUM_RICS)) polices over $interface using "$__httpx a1pms_api_delete_policy_parallel 204 $NUM_RICS $START_ID $NUM_POLICIES_PER_RIC 7 diff --git a/test/common/a1pms_api_functions.sh b/test/common/a1pms_api_functions.sh index e0650347..b80bb25e 100644 --- a/test/common/a1pms_api_functions.sh +++ b/test/common/a1pms_api_functions.sh @@ -2,6 +2,7 @@ # ============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. @@ -1403,7 +1404,7 @@ a1pms_api_delete_policy_parallel() { #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 @@ -1463,6 +1464,84 @@ a1pms_api_delete_policy_parallel() { 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: +# (Function for test scripts) +a1pms_api_get_policy_parallel() { + __log_test_start $@ + + if [ $# -ne 5 ]; then + __print_err " " $@ + 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: |NORIC |NOSERVICE |NOTYPE ([" + +import os +import json +import sys +import requests +import traceback + +# disable warning about unverified https requests +from requests.packages import urllib3 + +urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) + +#arg responsecode baseurl num_rics uuid startid count pids pid_id proxy + +try: + if len(sys.argv) != 10: + print("1Expected 9 args, got "+str(len(sys.argv)-1)+ ". Args: responsecode baseurl num_rics uuid startid count pids pid_id proxy") + sys.exit() + + responsecode=int(sys.argv[1]) + baseurl=str(sys.argv[2]) + num_rics=int(sys.argv[3]) + uuid=str(sys.argv[4]) + start=int(sys.argv[5]) + count=int(sys.argv[6]) + pids=int(sys.argv[7]) + pid_id=int(sys.argv[8]) + httpproxy=str(sys.argv[9]) + + proxydict=None + if httpproxy != "NOPROXY": + proxydict = { + "http" : httpproxy, + "https" : httpproxy + } + if uuid == "NOUUID": + uuid="" + + http_retry_count=0 + connect_retry_count=0 + + stop=count*num_rics+start + for i in range(start,stop): + if (i%pids == (pid_id-1)): + connect_ok=False + retry_cnt=5 + while(retry_cnt>0): + if ("/v2/policies/" in baseurl): + url=str(baseurl+uuid+str(i)) + else: + url=str(baseurl+"?id="+uuid+str(i)) + try: + if proxydict is None: + resp=requests.get(url, verify=False, timeout=90) + else: + resp=requests.get(url, verify=False, timeout=90, proxies=proxydict) + cconnect_ok=True + except Exception as e1: + if (retry_cnt > 1): + sleep(0.1) + retry_cnt -= 1 + connect_retry_count += 1 + else: + print("1Get failed for id:"+uuid+str(i)+ ", "+str(e1) + " "+traceback.format_exc()) + sys.exit() + + if (cconnect_ok == True): + if (resp.status_code == None): + print("1Get failed for id:"+uuid+str(i)+ ", expected response code: "+str(responsecode)+", got: None") + sys.exit() + if (resp.status_code != responsecode): + if (resp.status_code >= 500) and (http_retry_count < 600 ) and (retry_cnt > 1): + sleep(0.1) + retry_cnt -= 1 + http_retry_count += 1 + else: + print("1Get failed for id:"+uuid+str(i)+ ", expected response code: "+str(responsecode)+", got: "+str(resp.status_code)+str(resp.raw)) + sys.exit() + else: + retry_cnt=-1 + + print("0 http retries:"+str(http_retry_count) + ", connect retries: "+str(connect_retry_count)) + sys.exit() + +except Exception as e: + print("1"+str(e)) + traceback.print_exc() +sys.exit() \ No newline at end of file