From 70e878f1b5a558baaaa5ab5885a039ed96c9f8d5 Mon Sep 17 00:00:00 2001 From: BjornMagnussonXA Date: Mon, 11 May 2020 14:11:30 +0200 Subject: [PATCH] Test env updates for dmaap messages in batch and for running external agent Restructured and consolidated testcases Various minor updates and adjustment to test functions Change-Id: Ie796b04b7a12bbd410b56db19d718e1c5a0510de Issue-ID: NONRTRIC-154 Signed-off-by: BjornMagnussonXA --- test/auto-test/.gitignore | 5 +- test/auto-test/Dockerize_test.sh | 29 -- test/auto-test/FTC1.sh | 218 +++++++++++++++ test/auto-test/FTC10.sh | 37 ++- test/auto-test/FTC100.sh | 208 +++++++++----- test/auto-test/{FTC200.sh => FTC110.sh} | 81 +++--- test/auto-test/FTC150.sh | 96 +++++++ test/auto-test/FTC300.sh | 138 ++++++++-- test/auto-test/FTC301.sh | 6 +- test/auto-test/FTC310.sh | 161 +++-------- test/auto-test/FTC320.sh | 202 -------------- test/auto-test/FTC500.sh | 74 ----- test/auto-test/FTC600.sh | 87 ------ test/auto-test/FTC800.sh | 204 ++++++++++++++ test/auto-test/FTC810.sh | 237 ++++++++++++++++ test/auto-test/FTC900.sh | 116 ++++++++ test/auto-test/FTC_SDNC.sh | 96 ------- test/auto-test/README.md | 14 + test/auto-test/Suite-interfaces.sh | 7 +- test/common/agent_api_functions.sh | 320 +++++++++++++++++----- test/common/controller_api_functions.sh | 3 +- test/common/extract_sdnc_reply.py | 8 +- test/common/ricsimulator_api_functions.sh | 25 +- test/common/test_env.sh | 11 +- test/common/testcase_common.sh | 276 +++++++++++++++---- test/cr/cr.py | 3 +- test/simulator-group/sdnc/docker-compose.yml | 1 + test/simulator-group/sdnc_onap/.gitignore | 1 + test/simulator-group/sdnc_onap/docker-compose.yml | 1 + 29 files changed, 1764 insertions(+), 901 deletions(-) delete mode 100755 test/auto-test/Dockerize_test.sh create mode 100755 test/auto-test/FTC1.sh rename test/auto-test/{FTC200.sh => FTC110.sh} (54%) create mode 100755 test/auto-test/FTC150.sh delete mode 100755 test/auto-test/FTC320.sh delete mode 100755 test/auto-test/FTC500.sh delete mode 100755 test/auto-test/FTC600.sh create mode 100755 test/auto-test/FTC800.sh create mode 100755 test/auto-test/FTC810.sh create mode 100755 test/auto-test/FTC900.sh delete mode 100755 test/auto-test/FTC_SDNC.sh create mode 100644 test/simulator-group/sdnc_onap/.gitignore diff --git a/test/auto-test/.gitignore b/test/auto-test/.gitignore index 7f08b380..fe93abef 100644 --- a/test/auto-test/.gitignore +++ b/test/auto-test/.gitignore @@ -9,5 +9,6 @@ logs .consul* .ext.consul* .dockererr -.sdnc-reply.json -.sndc.payload.json +.output.* +.sdnc* +.timer* diff --git a/test/auto-test/Dockerize_test.sh b/test/auto-test/Dockerize_test.sh deleted file mode 100755 index dec32177..00000000 --- a/test/auto-test/Dockerize_test.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env bash - -TC_ONELINE_DESCR="dockerirze the test, setup docker container for Policy Agent, cbs, consul, Near-RT RIC simulator" - -. ../common/testcase_common.sh $1 $2 $3 - -#### TEST BEGIN #### - -clean_containers - -start_ric_simulator - -prepare_consul_config - -start_simulators - -consul_config_app "../simulator-group/consul_cbs/config.json" - -start_control_panel - -start_sdnc - -start_policy_agent - -check_policy_agent_logs - -#### TEST COMPLETE #### - -store_logs END diff --git a/test/auto-test/FTC1.sh b/test/auto-test/FTC1.sh new file mode 100755 index 00000000..306683b4 --- /dev/null +++ b/test/auto-test/FTC1.sh @@ -0,0 +1,218 @@ +#!/bin/bash + +# ============LICENSE_START=============================================== +# Copyright (C) 2020 Nordix Foundation. 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. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END================================================= +# + + +TC_ONELINE_DESCR="Sanity test, create service and then create,update and delete a policy using http/https and Agent REST/DMAAP with/without SDNC controller" + +. ../common/testcase_common.sh $@ +. ../common/agent_api_functions.sh +. ../common/ricsimulator_api_functions.sh + +#### TEST BEGIN #### + +#Local vars in test script +########################## + +# Path to callback receiver +CR_PATH="http://$CR_APP_NAME:$CR_EXTERNAL_PORT/callbacks" + +# Tested variants of REST/DMAAP/SDNC config +TESTED_VARIANTS="REST DMAAP REST+SDNC DMAAP+SDNC" +#Test agent and simulator protocol versions (others are http only) +TESTED_PROTOCOLS="HTTP HTTPS" +for __httpx in $TESTED_PROTOCOLS ; do + for interface in $TESTED_VARIANTS ; do + + echo "#####################################################################" + echo "#####################################################################" + echo "### Testing agent: $interface using $__httpx" + echo "#####################################################################" + echo "#####################################################################" + + + # Clean container and start all needed containers # + clean_containers + + if [ $__httpx == "HTTPS" ]; then + #"Using secure ports towards simulators" + use_simulator_https + else + #"Using non-secure ports towards simulators" + use_simulator_http + fi + + start_ric_simulators ricsim_g1 1 OSC_2.1.0 + start_ric_simulators ricsim_g2 1 STD_1.1.3 + + start_mr + + if [ $__httpx == "HTTPS" ]; then + + deviation "TR17 - agent cannot use https towards MR - test combo $interface and $__httpx" + #This is the intention + #echo "Using secure ports between agent and MR" + #use_mr_https + + #Work around until it is fixed + #"Using non-secure ports between agent and MR" + use_mr_http + else + #"Using non-secure ports between agent and MR" + use_mr_http + fi + + start_cr + + if [ $interface == "SDNC" ]; then + + start_sdnc + + if [ $__httpx == "HTTPS" ]; then + # "Using secure ports towards SDNC" + use_sdnc_https + else + #"Using non-secure ports towards SDNC" + use_sdnc_http + fi + fi + + start_consul_cbs + + if [ $interface == "REST+SDNC" ] || [ $interface == "DMAAP+SDNC" ]; then + prepare_consul_config SDNC ".consul_config.json" + else + prepare_consul_config NOSDNC ".consul_config.json" + fi + + consul_config_app ".consul_config.json" + + start_control_panel + + if [ $interface == "REST+SDNC" ] || [ $interface == "DMAAP+SDNC" ]; then + start_sdnc + fi + + start_policy_agent + + set_agent_debug + + if [ $interface == "DMAAP" ] || [ $interface == "DMAAP+SDNC" ]; then + use_agent_dmaap + else + if [ $__httpx == "HTTPS" ]; then + echo "Using secure ports towards the agent" + use_agent_rest_https + else + echo "Using non-secure ports towards the agent" + use_agent_rest_http + fi + fi + + + cr_equal received_callbacks 0 + mr_equal requests_submitted 0 + + sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json + + api_equal json:rics 2 60 + + api_equal json:policy_schemas 2 120 + + api_equal json:policy_types 2 + + api_equal json:policies 0 + + api_equal json:policy_ids 0 + + echo "############################################" + echo "############## Health check ################" + echo "############################################" + + api_get_status 200 + + echo "############################################" + echo "##### Service registry and supervision #####" + echo "############################################" + + api_put_service 201 "serv1" 1000 "$CR_PATH/1" + + api_get_service_ids 200 "serv1" + + api_put_services_keepalive 200 "serv1" + + echo "############################################" + echo "############## RIC Repository ##############" + echo "############################################" + + api_get_rics 200 NOTYPE "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1:AVAILABLE ricsim_g2_1:me1_ricsim_g2_1,me2_ricsim_g2_1:EMPTYTYPE:AVAILABLE" + + echo "############################################" + echo "########### A1 Policy Management ###########" + echo "############################################" + + api_put_policy 201 "serv1" ricsim_g1_1 1 5000 testdata/OSC/pi1_template.json + api_put_policy 200 "serv1" ricsim_g1_1 1 5000 testdata/OSC/pi1_template.json + + api_put_policy 201 "serv1" ricsim_g2_1 NOTYPE 5100 testdata/STD/pi1_template.json + api_put_policy 200 "serv1" ricsim_g2_1 NOTYPE 5100 testdata/STD/pi1_template.json + + api_delete_policy 204 5000 + + api_delete_policy 204 5100 + + api_equal json:policies 0 + + api_equal json:policy_ids 0 + + cr_equal received_callbacks 0 + + if [ $interface == "DMAAP" ] || [ $interface == "DMAAP+SDNC" ]; then + VAL=11 # Number of Agent API calls over DMAAP + mr_equal requests_fetched $VAL + mr_equal responses_submitted $VAL + mr_equal responses_fetched $VAL + mr_equal current_requests 0 + mr_equal current_responses 0 + else + mr_equal requests_submitted 0 + fi + + if [ $interface == "REST+SDNC" ] || [ $interface == "DMAAP+SDNC" ]; then + sim_contains_str ricsim_g1_1 remote_hosts "a1-controller" + sim_contains_str ricsim_g2_1 remote_hosts "a1-controller" + else + sim_contains_str ricsim_g1_1 remote_hosts "policy-agent" + sim_contains_str ricsim_g2_1 remote_hosts "policy-agent" + fi + + check_policy_agent_logs + check_control_panel_logs + + store_logs "${__httpx}__${interface}" + + done + +done + +#### TEST COMPLETE #### + + +print_result + +auto_clean_containers diff --git a/test/auto-test/FTC10.sh b/test/auto-test/FTC10.sh index 58128b78..ae4dc43a 100755 --- a/test/auto-test/FTC10.sh +++ b/test/auto-test/FTC10.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/bin/bash # ============LICENSE_START=============================================== # Copyright (C) 2020 Nordix Foundation. All rights reserved. @@ -17,7 +17,7 @@ # ============LICENSE_END================================================= # -TC_ONELINE_DESCR="Basic use case, register rapp, create/update policy, delete policy, de-register rapp using both STD and OSC interface over REST and Dmaap" +TC_ONELINE_DESCR="Basic use case, register service, create/update policy, delete policy, de-register service using both STD and OSC interface while mixing REST and Dmaap" . ../common/testcase_common.sh $@ . ../common/agent_api_functions.sh @@ -67,30 +67,30 @@ api_equal json:policy_types 2 60 # Create policies use_agent_rest_http -api_put_service 201 "rapp1" 3600 "$CR_PATH/1" +api_put_service 201 "service1" 3600 "$CR_PATH/1" -api_put_policy 201 "rapp1" ricsim_g1_1 1 2000 testdata/OSC/pi1_template.json 1 +api_put_policy 201 "service1" ricsim_g1_1 1 2000 testdata/OSC/pi1_template.json 1 sim_equal ricsim_g1_1 num_instances 1 use_agent_dmaap -api_put_policy 201 "rapp1" ricsim_g1_1 1 3000 testdata/OSC/pi1_template.json 1 +api_put_policy 201 "service1" ricsim_g1_1 1 3000 testdata/OSC/pi1_template.json 1 sim_equal ricsim_g1_1 num_instances 2 use_agent_rest_http -api_put_policy 201 "rapp1" ricsim_g2_1 NOTYPE 2100 testdata/STD/pi1_template.json 1 +api_put_policy 201 "service1" ricsim_g2_1 NOTYPE 2100 testdata/STD/pi1_template.json 1 sim_equal ricsim_g2_1 num_instances 1 use_agent_dmaap -api_put_policy 201 "rapp1" ricsim_g2_1 NOTYPE 3100 testdata/STD/pi1_template.json 1 +api_put_policy 201 "service1" ricsim_g2_1 NOTYPE 3100 testdata/STD/pi1_template.json 1 sim_equal ricsim_g2_1 num_instances 2 @@ -98,16 +98,16 @@ sim_equal ricsim_g2_1 num_instances 2 #Update policies use_agent_rest_http -api_put_service 200 "rapp1" 3600 "$CR_PATH/callbacks/1" +api_put_service 200 "service1" 3600 "$CR_PATH/callbacks/1" -api_put_policy 200 "rapp1" ricsim_g1_1 1 2000 testdata/OSC/pi1_template.json 1 +api_put_policy 200 "service1" ricsim_g1_1 1 2000 testdata/OSC/pi1_template.json 1 sim_equal ricsim_g1_1 num_instances 2 use_agent_dmaap -api_put_policy 200 "rapp1" ricsim_g1_1 1 3000 testdata/OSC/pi1_template.json 1 +api_put_policy 200 "service1" ricsim_g1_1 1 3000 testdata/OSC/pi1_template.json 1 sim_equal ricsim_g1_1 num_instances 2 @@ -115,14 +115,14 @@ sim_equal ricsim_g1_1 num_instances 2 use_agent_rest_http -api_put_policy 200 "rapp1" ricsim_g2_1 NOTYPE 2100 testdata/STD/pi1_template.json 1 +api_put_policy 200 "service1" ricsim_g2_1 NOTYPE 2100 testdata/STD/pi1_template.json 1 sim_equal ricsim_g2_1 num_instances 2 use_agent_dmaap -api_put_policy 200 "rapp1" ricsim_g2_1 NOTYPE 3100 testdata/STD/pi1_template.json 1 +api_put_policy 200 "service1" ricsim_g2_1 NOTYPE 3100 testdata/STD/pi1_template.json 1 sim_equal ricsim_g2_1 num_instances 2 @@ -146,6 +146,11 @@ api_delete_policy 204 3100 sim_equal ricsim_g1_1 num_instances 0 sim_equal ricsim_g2_1 num_instances 0 +# Check remote host access to simulator + +sim_contains_ste ricsim_g1_1 hosts "policy-agent" +sim_contains_ste ricsim_g2_1 hosts "policy-agent" + # Check policy removal use_agent_rest_http api_get_policy 404 2000 @@ -155,9 +160,9 @@ api_get_policy 404 3100 # Remove the service use_agent_dmaap -api_delete_services 204 "rapp1" +api_delete_services 204 "service1" -api_get_services 404 "rapp1" +api_get_services 404 "service1" @@ -167,4 +172,6 @@ check_policy_agent_logs store_logs END -print_result \ No newline at end of file +print_result + +auto_clean_containers \ No newline at end of file diff --git a/test/auto-test/FTC100.sh b/test/auto-test/FTC100.sh index 42c86768..da5962f0 100755 --- a/test/auto-test/FTC100.sh +++ b/test/auto-test/FTC100.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/bin/bash # ============LICENSE_START=============================================== # Copyright (C) 2020 Nordix Foundation. All rights reserved. @@ -23,7 +23,6 @@ TC_ONELINE_DESCR="Full agent API walk through using agent REST/DMAAP and with/wi . ../common/testcase_common.sh $@ . ../common/agent_api_functions.sh . ../common/ricsimulator_api_functions.sh -. ../common/controller_api_functions.sh #### TEST BEGIN #### @@ -35,16 +34,14 @@ CR_PATH="http://$CR_APP_NAME:$CR_EXTERNAL_PORT/callbacks" # Tested variants of REST/DMAAP/SDNC config TESTED_VARIANTS="REST DMAAP REST+SDNC DMAAP+SDNC" - #Test agent and simulator protocol versions (others are http only) TESTED_PROTOCOLS="HTTP HTTPS" - for __httpx in $TESTED_PROTOCOLS ; do for interface in $TESTED_VARIANTS ; do echo "#####################################################################" echo "#####################################################################" - echo "### Testing agent: "$interface + echo "### Testing agent: $interface using $__httpx" echo "#####################################################################" echo "#####################################################################" @@ -53,10 +50,10 @@ for __httpx in $TESTED_PROTOCOLS ; do clean_containers if [ $__httpx == "HTTPS" ]; then - echo "Using secure ports towards simulators" + #"Using secure ports towards simulators" use_simulator_https else - echo "Using non-secure ports towards simulators" + #"Using non-secure ports towards simulators" use_simulator_http fi @@ -65,8 +62,36 @@ for __httpx in $TESTED_PROTOCOLS ; do start_mr + if [ $__httpx == "HTTPS" ]; then + + deviation "TR17 - agent cannot use https towards MR - test combo $interface and $__httpx" + #This is the intention + #echo "Using secure ports between agent and MR" + #use_mr_https + + #Work around until it is fixed + #"Using non-secure ports between agent and MR" + use_mr_http + else + #"Using non-secure ports between agent and MR" + use_mr_http + fi + start_cr + if [ $interface == "REST+SDNC" ] || [ $interface == "DMAAP+SDNC" ]; then + + start_sdnc + + if [ $__httpx == "HTTPS" ]; then + # "Using secure ports towards SDNC" + use_sdnc_https + else + #"Using non-secure ports towards SDNC" + use_sdnc_http + fi + fi + start_consul_cbs if [ $interface == "REST+SDNC" ] || [ $interface == "DMAAP+SDNC" ]; then @@ -79,20 +104,18 @@ for __httpx in $TESTED_PROTOCOLS ; do start_control_panel - if [ $interface == "REST+SDNC" ] || [ $interface == "DMAAP+SDNC" ]; then - start_sdnc - fi - start_policy_agent + set_agent_debug + if [ $interface == "DMAAP" ] || [ $interface == "DMAAP+SDNC" ]; then use_agent_dmaap else if [ $__httpx == "HTTPS" ]; then - echo "Using secure ports towards the agent" + #"Using secure ports towards the agent" use_agent_rest_https else - echo "Using non-secure ports towards the agent" + #"Using non-secure ports towards the agent" use_agent_rest_http fi fi @@ -127,69 +150,76 @@ for __httpx in $TESTED_PROTOCOLS ; do echo "##### Service registry and supervision #####" echo "############################################" - api_get_services 404 "rapp1" + api_get_services 404 "service1" - api_put_service 201 "rapp1" 1000 "$CR_PATH/1" + api_put_service 201 "service1" 1000 "$CR_PATH/1" - api_put_service 200 "rapp1" 2000 "$CR_PATH/1" + api_put_service 200 "service1" 2000 "$CR_PATH/1" - api_put_service 400 "rapp2" -1 "$CR_PATH/2" + api_put_service 400 "service2" -1 "$CR_PATH/2" - api_put_service 400 "rapp2" "wrong" "$CR_PATH/2" + api_put_service 400 "service2" "wrong" "$CR_PATH/2" - api_put_service 400 "rapp2" 100 "/test" + api_put_service 400 "service2" 100 "/test" - api_put_service 400 "rapp2" 100 "test-path" + api_put_service 400 "service2" 100 "test-path" - api_put_service 201 "rapp2" 300 "ftp://localhost:80/test" + api_put_service 201 "service2" 300 "ftp://localhost:80/test" - api_get_services 200 "rapp1" "rapp1" 2000 "$CR_PATH/1" + api_get_services 200 "service1" "service1" 2000 "$CR_PATH/1" - api_get_service_ids 200 "rapp1" "rapp2" + api_get_service_ids 200 "service1" "service2" - api_put_service 201 "rapp3" 5000 "$CR_PATH/3" + api_put_service 201 "service3" 5000 "$CR_PATH/3" - api_get_service_ids 200 "rapp1" "rapp2" "rapp3" + api_get_service_ids 200 "service1" "service2" "service3" - api_get_services 200 "rapp1" "rapp1" 2000 "$CR_PATH/1" + api_get_services 200 "service1" "service1" 2000 "$CR_PATH/1" - api_get_services 200 NOSERVICE "rapp1" 2000 "$CR_PATH/1" "rapp2" 300 "ftp://localhost:80/test" "rapp3" 5000 "$CR_PATH/3" + api_get_services 200 NOSERVICE "service1" 2000 "$CR_PATH/1" "service2" 300 "ftp://localhost:80/test" "service3" 5000 "$CR_PATH/3" api_get_services 200 - echo -e $YELLOW"TR2"$EYELLOW - api_put_services_keepalive 201 "rapp1" - echo -e $YELLOW"TR2"$EYELLOW - api_put_services_keepalive 201 "rapp3" + deviation "TR2 - Keep alive shall return 200/201 according to doc, only 200 works - test combo $interface and $__httpx" + #The below should work, keept here until fixed or other decision made + #api_put_services_keepalive 201 "service1" + #Using the below until decision + api_put_services_keepalive 200 "service1" + + deviation "TR2 - Keep alive shall return 200/201 according to doc, only 200 works - test combo $interface and $__httpx" + #The below should work, keept here until fixed or other decision made + #api_put_services_keepalive 201 "service3" + #Using the below until decision + api_put_services_keepalive 200 "service3" - api_put_services_keepalive 200 "rapp1" + api_put_services_keepalive 200 "service1" - api_put_services_keepalive 200 "rapp3" + api_put_services_keepalive 200 "service3" - api_put_services_keepalive 404 "rapp5" + api_put_services_keepalive 404 "service5" - api_get_service_ids 200 "rapp1" "rapp2" "rapp3" + api_get_service_ids 200 "service1" "service2" "service3" - api_delete_services 204 "rapp1" + api_delete_services 204 "service1" - api_get_service_ids 200 "rapp2" "rapp3" + api_get_service_ids 200 "service2" "service3" - api_put_service 201 "rapp1" 50 "$CR_PATH/1" + api_put_service 201 "service1" 50 "$CR_PATH/1" - api_get_service_ids 200 "rapp1" "rapp2" "rapp3" + api_get_service_ids 200 "service1" "service2" "service3" - api_delete_services 204 "rapp1" - api_delete_services 204 "rapp3" + api_delete_services 204 "service1" + api_delete_services 204 "service3" api_equal json:services 1 - api_delete_services 204 "rapp2" + api_delete_services 204 "service2" api_equal json:services 0 @@ -221,15 +251,19 @@ for __httpx in $TESTED_PROTOCOLS ; do echo "############################################" echo "########### A1 Policy Management ###########" echo "############################################" - echo -e $YELLOW"TR9"$EYELLOW + deviation "TR9 - agent modify the type with type id - test combo $interface and $__httpx" + #Behaviour accepted for now api_get_policy_schema 200 1 testdata/OSC/1-agent-modified.json - echo -e $YELLOW"TR9"$EYELLOW + deviation "TR9 - agent modify the type with type id - test combo $interface and $__httpx" + #Behaviour accepted for now api_get_policy_schema 200 2 testdata/OSC/2-agent-modified.json api_get_policy_schema 404 3 - echo -e $YELLOW"TR9"$EYELLOW + deviation "TR9 - agent modify the type with type id - test combo $interface and $__httpx" + #Behaviour accepted for now api_get_policy_schemas 200 NORIC testdata/OSC/1-agent-modified.json testdata/OSC/2-agent-modified.json NOFILE - echo -e $YELLOW"TR9"$EYELLOW + deviation "TR9 - agent modify the type with type id - test combo $interface and $__httpx" + #Behaviour accepted for now api_get_policy_schemas 200 ricsim_g1_1 testdata/OSC/1-agent-modified.json testdata/OSC/2-agent-modified.json api_get_policy_schemas 200 ricsim_g2_1 NOFILE @@ -248,36 +282,60 @@ for __httpx in $TESTED_PROTOCOLS ; do - api_put_service 201 "rapp10" 3600 "$CR_PATH/1" - echo -e $YELLOW"TR10"$EYELLOW - api_put_policy 400 "unregistered-r-app" ricsim_g1_1 1 2000 testdata/OSC/pi1_template.json + api_put_service 201 "service10" 3600 "$CR_PATH/1" - api_put_policy 201 "rapp10" ricsim_g1_1 1 5000 testdata/OSC/pi1_template.json - api_put_policy 200 "rapp10" ricsim_g1_1 1 5000 testdata/OSC/pi1_template.json + deviation "TR10 - agent allows policy creation on unregistered service (orig problem) - test combo $interface and $__httpx" + #Kept until decison + #api_put_policy 400 "unregistered-service" ricsim_g1_1 1 2000 testdata/OSC/pi1_template.json + #Allow 201 for now + api_put_policy 201 "unregistered-service" ricsim_g1_1 1 2000 testdata/OSC/pi1_template.json - api_put_policy 201 "rapp10" ricsim_g2_1 NOTYPE 5100 testdata/STD/pi1_template.json - api_put_policy 200 "rapp10" ricsim_g2_1 NOTYPE 5100 testdata/STD/pi1_template.json + api_put_policy 201 "service10" ricsim_g1_1 1 5000 testdata/OSC/pi1_template.json + api_put_policy 200 "service10" ricsim_g1_1 1 5000 testdata/OSC/pi1_template.json + + api_put_policy 201 "service10" ricsim_g2_1 NOTYPE 5100 testdata/STD/pi1_template.json + api_put_policy 200 "service10" ricsim_g2_1 NOTYPE 5100 testdata/STD/pi1_template.json VAL='NOT IN EFFECT' api_get_policy_status 200 5000 OSC "$VAL" "false" api_get_policy_status 200 5100 STD "UNDEFINED" - echo -e $YELLOW"TR10"$EYELLOW - api_equal json:policies 2 - echo -e $YELLOW"TR10"$EYELLOW - api_equal json:policy_ids 2 - echo -e $YELLOW"TR10"$EYELLOW - api_get_policy_ids 200 NORIC NOSERVICE NOTYPE 5000 5100 - echo -e $YELLOW"TR10"$EYELLOW - api_get_policy_ids 200 ricsim_g1_1 NOSERVICE NOTYPE 5000 + deviation "TR10 - agent allows policy creation on unregistered service (side effect of orig. problem)- test combo $interface and $__httpx" + #kept until decision + #api_equal json:policies 2 + #Allow 3 for now + api_equal json:policies 3 + + deviation "TR10 - agent allows policy creation on unregistered service (side effect of orig. problem)- test combo $interface and $__httpx" + #kept until decision + #api_equal json:policy_ids 2 + #Allow 3 for now + api_equal json:policy_ids 3 + + deviation "TR10 - agent allows policy creation on unregistered service (side effect of orig. problem)- test combo $interface and $__httpx" + #kept until decision + #api_get_policy_ids 200 NORIC NOSERVICE NOTYPE 5000 5100 + #Allow policy create with unregistered service for now + api_get_policy_ids 200 NORIC NOSERVICE NOTYPE 5000 5100 2000 + + + deviation "TR10 - agent allows policy creation on unregistered service (side effect of orig. problem)- test combo $interface and $__httpx" + #kept until decision + #api_get_policy_ids 200 ricsim_g1_1 NOSERVICE NOTYPE 5000 + #Allow policy create with unregistered service for now + api_get_policy_ids 200 ricsim_g1_1 NOSERVICE NOTYPE 5000 2000 api_get_policy_ids 200 ricsim_g2_1 NOSERVICE NOTYPE 5100 - api_get_policy_ids 200 NORIC "rapp10" NOTYPE 5000 5100 - echo -e $YELLOW"TR10"$EYELLOW - api_get_policy_ids 200 NORIC NOSERVICE 1 5000 + api_get_policy_ids 200 NORIC "service10" NOTYPE 5000 5100 + + deviation "TR10 - agent allows policy creation on unregistered service (side effect of orig. problem)- test combo $interface and $__httpx" + #kept until decision + #api_get_policy_ids 200 NORIC NOSERVICE 1 5000 + #Allow policy create with unregistered service for now + api_get_policy_ids 200 NORIC NOSERVICE 1 5000 2000 api_get_policy_ids 200 NORIC NOSERVICE 2 NOID @@ -289,14 +347,14 @@ for __httpx in $TESTED_PROTOCOLS ; do api_get_policy 200 5100 testdata/STD/pi1_template.json - - api_get_policies 200 ricsim_g1_1 "rapp10" 1 5000 ricsim_g1_1 "rapp10" 1 testdata/OSC/pi1_template.json - - + api_get_policies 200 ricsim_g1_1 "service10" 1 5000 ricsim_g1_1 "service10" 1 testdata/OSC/pi1_template.json - echo -e $YELLOW"TR10"$EYELLOW - api_delete_policy 404 2000 + deviation "TR10 - agent allows policy creation on unregistered service (side effect of orig. problem)- test combo $interface and $__httpx" + #kept until decision + #api_delete_policy 404 2000 + #Allow policy create with unregistered service for now + api_delete_policy 204 2000 api_delete_policy 404 1500 @@ -326,10 +384,18 @@ for __httpx in $TESTED_PROTOCOLS ; do mr_equal requests_submitted 0 fi + if [ $interface == "REST+SDNC" ] || [ $interface == "DMAAP+SDNC" ]; then + sim_contains_str ricsim_g1_1 remote_hosts "a1-controller" + sim_contains_str ricsim_g2_1 remote_hosts "a1-controller" + else + sim_contains_str ricsim_g1_1 remote_hosts "policy-agent" + sim_contains_str ricsim_g2_1 remote_hosts "policy-agent" + fi + check_policy_agent_logs check_control_panel_logs - store_logs $interface + store_logs "${__httpx}__${interface}" done diff --git a/test/auto-test/FTC200.sh b/test/auto-test/FTC110.sh similarity index 54% rename from test/auto-test/FTC200.sh rename to test/auto-test/FTC110.sh index b53ae4e1..b4fc8851 100755 --- a/test/auto-test/FTC200.sh +++ b/test/auto-test/FTC110.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/bin/bash # ============LICENSE_START=============================================== # Copyright (C) 2020 Nordix Foundation. All rights reserved. @@ -50,6 +50,8 @@ start_control_panel start_policy_agent +set_agent_debug + use_agent_rest_http #Verify no callbacks or dmaap messages has been sent @@ -62,85 +64,84 @@ api_get_status 200 #Print simulator interface version sim_print ricsim_g1_1 interface -api_put_service 201 "rapp1" 15 "$CR_PATH/rapp1" +api_put_service 201 "service1" 15 "$CR_PATH/service1" -api_get_services 200 "rapp1" 15 "$CR_PATH/rapp1" +api_get_services 200 "service1" "service1" 15 "$CR_PATH/service1" -api_put_service 201 "rapp2" 120 "$CR_PATH/rapp2" +api_put_service 201 "service2" 120 "$CR_PATH/service2" -api_get_services 200 "rapp2" 120 "$CR_PATH/rapp2" +api_get_services 200 "service2" "service2" 120 "$CR_PATH/service2" -api_put_service 200 "rapp1" 50 "$CR_PATH/rapp1" -api_put_service 200 "rapp2" 180 "$CR_PATH/rapp2" +api_put_service 200 "service1" 50 "$CR_PATH/service1" +api_put_service 200 "service2" 180 "$CR_PATH/service2" -api_get_services 200 "rapp1" 50 "$CR_PATH/rapp1" -api_get_services 200 "rapp2" 180 "$CR_PATH/rapp2" +api_get_services 200 "service1" "service1" 50 "$CR_PATH/service1" +api_get_services 200 "service2" "service2" 180 "$CR_PATH/service2" -api_get_service_ids 200 "rapp1" "rapp2" +api_get_service_ids 200 "service1" "service2" sleep_wait 30 "Waiting for keep alive timeout" -api_get_services 200 "rapp1" 50 "$CR_PATH/rapp1" -api_get_services 200 "rapp2" 180 "$CR_PATH/rapp2" +api_get_services 200 "service1" "service1" 50 "$CR_PATH/service1" +api_get_services 200 "service2" "service2" 180 "$CR_PATH/service2" sleep_wait 100 "Waiting for keep alive timeout" -api_get_services 404 "rapp1" -api_get_services 200 "rapp2" 180 "$CR_PATH/rapp2" +api_get_services 404 "service1" +api_get_services 200 "service2" "service2" 180 "$CR_PATH/service2" -api_delete_services 204 "rapp2" +api_delete_services 204 "service2" -api_get_services 404 "rapp1" -api_get_services 404 "rapp2" +api_get_services 404 "service1" +api_get_services 404 "service2" -api_put_service 201 "rapp3" 60 "$CR_PATH/rapp3" +api_put_service 201 "service3" 60 "$CR_PATH/service3" -api_get_services 200 "rapp3" 60 "$CR_PATH/rapp3" +api_get_services 200 "service3" "service3" 60 "$CR_PATH/service3" sleep_wait 30 "Waiting for keep alive timeout" -api_put_service 200 "rapp3" 60 "$CR_PATH/rapp3" +api_put_service 200 "service3" 60 "$CR_PATH/service3" sleep_wait 100 "Waiting for keep alive timeout" -api_get_services 404 "rapp3" +api_get_services 404 "service3" -api_put_service 201 "rapp4" 120 "$CR_PATH/rapp4" +api_put_service 201 "service4" 120 "$CR_PATH/service4" sleep_wait 60 "Waiting for keep alive timeout" -api_get_services 200 "rapp4" 120 "$CR_PATH/rapp4" +api_get_services 200 "service4" "service4" 120 "$CR_PATH/service4" -api_put_services_keepalive 200 "rapp4" +api_put_services_keepalive 200 "service4" sleep_wait 90 "Waiting for keep alive timeout" -api_get_services 200 "rapp4" 120 "$CR_PATH/rapp4" +api_get_services 200 "service4" "service4" 120 "$CR_PATH/service4" -api_delete_services 204 "rapp4" +api_delete_services 204 "service4" -api_get_services 404 "rapp4" +api_get_services 404 "service4" -api_get_services 404 "rapp1" -api_get_services 404 "rapp2" -api_get_services 404 "rapp3" +api_get_services 404 "service1" +api_get_services 404 "service2" +api_get_services 404 "service3" api_get_service_ids 200 -api_delete_services 404 "rapp1" -api_delete_services 404 "rapp2" -api_delete_services 404 "rapp3" -api_delete_services 404 "rapp4" +api_delete_services 404 "service1" +api_delete_services 404 "service2" +api_delete_services 404 "service3" +api_delete_services 404 "service4" -api_put_services_keepalive 404 "rapp1" -api_put_services_keepalive 404 "rapp2" -api_put_services_keepalive 404 "rapp3" -api_put_services_keepalive 404 "rapp4" +api_put_services_keepalive 404 "service1" +api_put_services_keepalive 404 "service2" +api_put_services_keepalive 404 "service3" +api_put_services_keepalive 404 "service4" api_get_service_ids 200 - - +deviation "TR18 Agents sends callback with empty body" cr_equal received_callbacks 0 mr_equal requests_submitted 0 diff --git a/test/auto-test/FTC150.sh b/test/auto-test/FTC150.sh new file mode 100755 index 00000000..e1388c47 --- /dev/null +++ b/test/auto-test/FTC150.sh @@ -0,0 +1,96 @@ +#!/bin/bash + +# ============LICENSE_START=============================================== +# Copyright (C) 2020 Nordix Foundation. 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. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END================================================= +# + + +TC_ONELINE_DESCR="Sample tests of the SDNC A1 controller restconf API using http/https (no agent)" + +. ../common/testcase_common.sh $@ +. ../common/controller_api_functions.sh +. ../common/ricsimulator_api_functions.sh + +#### TEST BEGIN #### + +#Test agent and simulator protocol versions (others are http only) +TESTED_PROTOCOLS="HTTP HTTPS" + +for __httpx in $TESTED_PROTOCOLS ; do + + echo "#####################################################################" + echo "#####################################################################" + echo "### Testing SDNC using: $__httpx" + echo "#####################################################################" + echo "#####################################################################" + + + # Clean container and start all needed containers # + clean_containers + + start_ric_simulators ricsim_g1 1 OSC_2.1.0 + start_ric_simulators ricsim_g2 1 STD_1.1.3 + + start_sdnc + + if [ $__httpx == "HTTPS" ]; then + # "Using secure ports towards SDNC" + use_sdnc_https + else + #"Using non-secure ports towards SDNC" + use_sdnc_http + fi + + # API tests + + controller_api_get_A1_policy_type 404 OSC ricsim_g1_1 1 + + sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json + + + controller_api_get_A1_policy_ids 200 OSC ricsim_g1_1 1 + controller_api_get_A1_policy_ids 200 STD ricsim_g2_1 + + controller_api_get_A1_policy_type 200 OSC ricsim_g1_1 1 + controller_api_get_A1_policy_type 200 OSC ricsim_g1_1 1 testdata/OSC/sim_1.json + controller_api_get_A1_policy_type 404 OSC ricsim_g1_1 99 + + controller_api_put_A1_policy 202 OSC ricsim_g1_1 1 4000 testdata/OSC/pi1_template.json + controller_api_put_A1_policy 404 OSC ricsim_g1_1 5 1001 testdata/OSC/pi1_template.json + controller_api_put_A1_policy 201 STD ricsim_g2_1 5000 testdata/STD/pi1_template.json + + controller_api_get_A1_policy_ids 200 OSC ricsim_g1_1 1 4000 + controller_api_get_A1_policy_ids 200 STD ricsim_g2_1 5000 + + controller_api_get_A1_policy_status 200 OSC ricsim_g1_1 1 4000 + controller_api_get_A1_policy_status 200 STD ricsim_g2_1 5000 + + VAL='NOT IN EFFECT' + controller_api_get_A1_policy_status 200 OSC ricsim_g1_1 1 4000 "$VAL" "false" + controller_api_get_A1_policy_status 200 STD ricsim_g2_1 5000 "UNDEFINED" + + controller_api_delete_A1_policy 202 OSC ricsim_g1_1 1 4000 + controller_api_delete_A1_policy 204 STD ricsim_g2_1 5000 + + store_logs $__httpx + +done + +#### TEST COMPLETE #### + +print_result + +auto_clean_containers \ No newline at end of file diff --git a/test/auto-test/FTC300.sh b/test/auto-test/FTC300.sh index a004292d..e3181bd2 100755 --- a/test/auto-test/FTC300.sh +++ b/test/auto-test/FTC300.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/bin/bash # ============LICENSE_START=============================================== # Copyright (C) 2020 Nordix Foundation. All rights reserved. @@ -30,55 +30,137 @@ TC_ONELINE_DESCR="Resync 10000 policies using OSC interface over REST" # Path to callback receiver CR_PATH="http://$CR_APP_NAME:$CR_EXTERNAL_PORT/callbacks" -clean_containers +# Tested variants of REST/DMAAP/SDNC config +TESTED_VARIANTS="REST DMAAP REST+SDNC DMAAP+SDNC DMAAP_BATCH DMAAP_BATCH+SDNC" +#Test agent and simulator protocol versions (others are http only) +TESTED_PROTOCOLS="HTTP HTTPS" +for __httpx in $TESTED_PROTOCOLS ; do + for interface in $TESTED_VARIANTS ; do -start_ric_simulators ricsim_g1 4 OSC_2.1.0 + echo "#####################################################################" + echo "#####################################################################" + echo "### Testing agent: "$interface" and "$__httpx + echo "#####################################################################" + echo "#####################################################################" -start_mr -start_cr + # Clean container and start all needed containers # + clean_containers -start_consul_cbs + if [ $__httpx == "HTTPS" ]; then + echo "Using secure ports towards simulators" + use_simulator_https + else + echo "Using non-secure ports towards simulators" + use_simulator_http + fi -prepare_consul_config NOSDNC ".consul_config.json" -consul_config_app ".consul_config.json" + start_ric_simulators ricsim_g1 4 OSC_2.1.0 -start_control_panel + start_ric_simulators ricsim_g2 4 STD_1.1.3 + start_mr -start_policy_agent + start_cr -use_agent_rest_http + start_consul_cbs -api_get_status 200 + if [[ $interface = *"SDNC"* ]]; then + start_sdnc + prepare_consul_config SDNC ".consul_config.json" + else + prepare_consul_config NOSDNC ".consul_config.json" + fi -sim_print ricsim_g1_1 interface + consul_config_app ".consul_config.json" -sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json + start_control_panel -api_equal json:policy_types 1 120 #Wait for the agent to refresh types from the simulator + start_policy_agent -api_put_service 201 "rapp1" 3600 "$CR_PATH/callbacks/1" + set_agent_debug -api_put_policy 201 "rapp1" ricsim_g1_1 1 2000 testdata/OSC/pi1_template.json 10000 + if [[ $interface == *"DMAAP"* ]]; then + use_agent_dmaap + else + if [ $__httpx == "HTTPS" ]; then + echo "Using secure ports towards the agent" + use_agent_rest_https + else + echo "Using non-secure ports towards the agent" + use_agent_rest_http + fi + fi -sim_equal ricsim_g1_1 num_instances 10000 + api_get_status 200 -sim_post_delete_instances 200 ricsim_g1_1 + sim_print ricsim_g1_1 interface -sim_equal ricsim_g1_1 num_instances 0 + sim_print ricsim_g2_1 interface -sim_equal ricsim_g1_1 num_instances 10000 300 + sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json -api_delete_policy 204 2435 + api_equal json:policy_types 2 120 #Wait for the agent to refresh types from the simulator -api_delete_policy 204 8693 + api_put_service 201 "rapp1" 3600 "$CR_PATH/callbacks/1" -sim_post_delete_instances 200 ricsim_g1_1 + START_ID=2000 + NUM_POLICIES=10000 -sim_post_delete_instances 200 ricsim_g1_1 + if [[ $interface == *"BATCH"* ]]; then + api_put_policy_batch 201 "rapp1" ricsim_g1_1 1 $START_ID testdata/OSC/pi1_template.json $NUM_POLICIES + else + api_put_policy 201 "rapp1" ricsim_g1_1 1 $START_ID testdata/OSC/pi1_template.json $NUM_POLICIES + fi -sim_equal ricsim_g1_1 num_instances 9998 300 + sim_equal ricsim_g1_1 num_instances 10000 + + sim_post_delete_instances 200 ricsim_g1_1 + + sim_equal ricsim_g1_1 num_instances 0 + + sim_equal ricsim_g1_1 num_instances 10000 300 + + START_ID=$(($START_ID+$NUM_POLICIES)) + + if [[ $interface == *"BATCH"* ]]; then + api_put_policy_batch 201 "rapp1" ricsim_g2_1 NOTYPE $START_ID testdata/STD/pi1_template.json $NUM_POLICIES + else + api_put_policy 201 "rapp1" ricsim_g2_1 NOTYPE $START_ID testdata/STD/pi1_template.json $NUM_POLICIES + fi + sim_equal ricsim_g2_1 num_instances 10000 + + sim_post_delete_instances 200 ricsim_g2_1 + + sim_equal ricsim_g2_1 num_instances 0 + + sim_equal ricsim_g2_1 num_instances 10000 300 + + api_delete_policy 204 2435 + + api_delete_policy 204 8693 + + sim_post_delete_instances 200 ricsim_g1_1 + + sim_equal ricsim_g1_1 num_instances 9998 300 + + api_delete_policy 204 12435 + + api_delete_policy 204 18693 + + api_delete_policy 204 18697 + + sim_post_delete_instances 200 ricsim_g2_1 + + sim_equal ricsim_g1_1 num_instances 9998 300 + + sim_equal ricsim_g2_1 num_instances 9997 300 + + api_equal json:policies 19995 + + done + +done check_policy_agent_logs @@ -87,4 +169,6 @@ check_policy_agent_logs store_logs END -print_result \ No newline at end of file +print_result + +auto_clean_containers \ No newline at end of file diff --git a/test/auto-test/FTC301.sh b/test/auto-test/FTC301.sh index fc5aba8b..5d182bf4 100755 --- a/test/auto-test/FTC301.sh +++ b/test/auto-test/FTC301.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/bin/bash # ============LICENSE_START=============================================== # Copyright (C) 2020 Nordix Foundation. All rights reserved. @@ -89,4 +89,6 @@ check_policy_agent_logs store_logs END -print_result \ No newline at end of file +print_result + +auto_clean_containers \ No newline at end of file diff --git a/test/auto-test/FTC310.sh b/test/auto-test/FTC310.sh index 9600f4ad..b7611cbc 100755 --- a/test/auto-test/FTC310.sh +++ b/test/auto-test/FTC310.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/bin/bash # ============LICENSE_START=============================================== # Copyright (C) 2020 Nordix Foundation. All rights reserved. @@ -17,28 +17,23 @@ # ============LICENSE_END================================================= # -TC_ONELINE_DESCR="Repeatedly create and delete 10000 policies in each RICs for 24h. Via agent REST" + +TC_ONELINE_DESCR="Resync of RIC via changes in the consul config" . ../common/testcase_common.sh $@ . ../common/agent_api_functions.sh . ../common/ricsimulator_api_functions.sh +. ../common/controller_api_functions.sh #### TEST BEGIN #### -#Local vars in test script -########################## -# Path to callback receiver -CR_PATH="http://$CR_APP_NAME:$CR_EXTERNAL_PORT/callbacks" -# Number of RICs per interface type (OSC and STD) -NUM_RICS=4 -# Number of policy instances per RIC -NUM_INSTANCES=10000 +# Clean container and start all needed containers # clean_containers -start_ric_simulators ricsim_g1 4 OSC_2.1.0 - -start_ric_simulators ricsim_g2 4 STD_1.1.3 +# Start one RIC of each type +start_ric_simulators ricsim_g1 1 OSC_2.1.0 +start_ric_simulators ricsim_g2 1 STD_1.1.3 start_mr @@ -47,126 +42,46 @@ start_cr start_consul_cbs prepare_consul_config NOSDNC ".consul_config.json" + consul_config_app ".consul_config.json" start_control_panel start_policy_agent -use_agent_rest_http - -api_get_status 200 - -echo "Print the interface for group 1 simulators, shall be OSC" -for ((i=1; i<=$NUM_RICS; i++)) -do - sim_print ricsim_g1_$i interface -done - -echo "Print the interface for group 2 simulators, shall be STD" -for ((i=1; i<=$NUM_RICS; i++)) -do - sim_print ricsim_g2_$i interface -done - -echo "Load policy type in group 1 simulators" -for ((i=1; i<=$NUM_RICS; i++)) -do - sim_put_policy_type 201 ricsim_g1_$i 1 testdata/OSC/sim_1.json -done - -echo "Check the number of instances in group 1 simulators, shall be 0" -for ((i=1; i<=$NUM_RICS; i++)) -do - sim_equal ricsim_g1_$i num_instances 0 -done - -echo "Check the number of instances in group 2 simulators, shall be 0" -for ((i=1; i<=$NUM_RICS; i++)) -do - sim_equal ricsim_g2_$i num_instances 0 -done - -echo "Wait for the agent to refresh types from the simulator" -api_equal json:policy_types 2 120 - -echo "Check the number of types in the agent for each ric is 1" -for ((i=1; i<=$NUM_RICS; i++)) -do - api_equal json:policy_types?ric=ricsim_g1_$i 1 120 -done - -echo "Register a service" -api_put_service 201 "rapp1" 0 "$CR_PATH/1" - -TEST_DURATION=$((24*3600)) -TEST_START=$SECONDS - -while [ $(($SECONDS-$TEST_START)) -lt $TEST_DURATION ]; do - - echo "" - echo "#########################################################################################################" - echo -e $BOLD"INFO: Test executed for: "$(($SECONDS-$TEST_START)) "seconds. Target is: "$TEST_DURATION" seconds (24h)."$EBOLD - echo "#########################################################################################################" - echo "" - - - echo "Create 10000 instances in each OSC RIC" - INSTANCE_ID=200000 - INSTANCES=0 - for ((i=1; i<=$NUM_RICS; i++)) - do - api_put_policy 201 "rapp1" ricsim_g1_$i 1 $INSTANCE_ID testdata/OSC/pi1_template.json $NUM_INSTANCES - sim_equal ricsim_g1_$i num_instances $NUM_INSTANCES - INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES)) - INSTANCES=$(($INSTANCES+$NUM_INSTANCES)) - done - - api_equal json:policy_ids $INSTANCES - - echo "Create 10000 instances in each OSC RIC" - for ((i=1; i<=$NUM_RICS; i++)) - do - api_put_policy 201 "rapp1" ricsim_g2_$i NOTYPE $INSTANCE_ID testdata/STD/pi1_template.json $NUM_INSTANCES - sim_equal ricsim_g2_$i num_instances $NUM_INSTANCES - INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES)) - INSTANCES=$(($INSTANCES+$NUM_INSTANCES)) - done - - api_equal json:policy_ids $INSTANCES - - - echo "Delete all instances in each OSC RIC" - - INSTANCE_ID=200000 - for ((i=1; i<=$NUM_RICS; i++)) - do - api_delete_policy 204 $INSTANCE_ID $NUM_INSTANCES - INSTANCES=$(($INSTANCES-$NUM_INSTANCES)) - sim_equal ricsim_g1_$i num_instances $NUM_INSTANCES - INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES)) - done - - api_equal json:policy_ids $INSTANCES - - echo "Delete all instances in each STD RIC" - INSTANCE_ID=200000 - for ((i=1; i<=$NUM_RICS; i++)) - do - api_delete_policy 204 $INSTANCE_ID $NUM_INSTANCES - INSTANCES=$(($INSTANCES-$NUM_INSTANCES)) - sim_equal ricsim_g2_$i num_instances $NUM_INSTANCES - INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES)) - done - - api_equal json:policy_ids 0 -done +api_equal json:rics 2 120 +# Add an OSC RIC and check +start_ric_simulators ricsim_g2 2 STD_1.1.3 + +prepare_consul_config NOSDNC ".consul_config.json" + +consul_config_app ".consul_config.json" + +api_equal json:rics 3 120 + check_policy_agent_logs +check_control_panel_logs -#### TEST COMPLETE #### +# Remove one OSC RIC and check +start_ric_simulators ricsim_g2 1 STD_1.1.3 + +prepare_consul_config NOSDNC ".consul_config.json" + +consul_config_app ".consul_config.json" + +api_equal json:rics 2 120 + +check_policy_agent_logs +check_control_panel_logs store_logs END -print_result \ No newline at end of file + +#### TEST COMPLETE #### + + +print_result + +auto_clean_containers diff --git a/test/auto-test/FTC320.sh b/test/auto-test/FTC320.sh deleted file mode 100755 index 067cd876..00000000 --- a/test/auto-test/FTC320.sh +++ /dev/null @@ -1,202 +0,0 @@ -#!/usr/bin/env bash - -# ============LICENSE_START=============================================== -# Copyright (C) 2020 Nordix Foundation. 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============LICENSE_END================================================= -# - -TC_ONELINE_DESCR="Create and delete 50 policies in each 50 RICs, 25 STD version, 25 OSC version. Via agent REST" - -. ../common/testcase_common.sh $@ -. ../common/agent_api_functions.sh -. ../common/ricsimulator_api_functions.sh - -#### TEST BEGIN #### - -#Local vars in test script -########################## -# Path to callback receiver -CR_PATH="http://$CR_APP_NAME:$CR_EXTERNAL_PORT/callbacks" -# Number of RICs -NUM_RICS=25 -# Number of instances per RIC -NUM_INST=50 - -# Clean and start all containers -clean_containers - -start_ric_simulators ricsim_g1 $NUM_RICS OSC_2.1.0 - -start_ric_simulators ricsim_g2 $NUM_RICS STD_1.1.3 - -start_mr - -start_cr - -start_consul_cbs - -prepare_consul_config NOSDNC ".consul_config.json" -consul_config_app ".consul_config.json" - -start_control_panel - -start_policy_agent - -use_agent_rest_http - -set_agent_debug - -# Main tests - -echo "Checking agent is alive" -api_get_status 200 - - -echo "Print the interface for group 1 simulators, shall be OSC" -for ((i=1; i<=$NUM_RICS; i++)) -do - sim_print ricsim_g1_$i interface -done - -echo "Print the interface for group 2 simulators, shall be STD" -for ((i=1; i<=$NUM_RICS; i++)) -do - sim_print ricsim_g2_$i interface -done - -echo "Checking the number of policy instances in each group 1 simulator, shall be 0" -for ((i=1; i<=$NUM_RICS; i++)) -do - sim_equal ricsim_g1_$i num_instances 0 -done - -echo "Checking the number of policy instances in each group 2 simulator, shall be 0" -for ((i=1; i<=$NUM_RICS; i++)) -do - sim_equal ricsim_g1_$i num_instances 0 -done - -echo "Load policy type 1 in each group 1 simulator" -for ((i=1; i<=$NUM_RICS; i++)) -do - sim_put_policy_type 201 ricsim_g1_$i 1 testdata/OSC/sim_1.json -done - -echo "Checking the number of policy types in each group 1 simulator, shall be 1" -for ((i=1; i<=$NUM_RICS; i++)) -do - sim_equal ricsim_g1_$i num_types 1 -done - -echo "Checking the number of policy types in each group 2 simulator, shall be 0" -for ((i=1; i<=$NUM_RICS; i++)) -do - sim_equal ricsim_g2_$i num_types 0 -done - -echo "Check the number of rics, shall be the configured number: ""$(($NUM_RICS*2))" -api_equal json:rics "$(($NUM_RICS*2))" 120 - -api_equal json:policy_types 2 120 #Wait for the agent to refresh types from the simulator - -sleep_wait 120 "Wait for the agent to refresh the types from all rics" - -echo "Check the number of types in the agent for each group 1 rics, shall be 1" -for ((i=1; i<=$NUM_RICS; i++)) -do - api_equal json:policy_types?ric=ricsim_g1_$i 1 -done - -echo "Check the number of types in the agent for each group 2 rics, shall be 1" -for ((i=1; i<=$NUM_RICS; i++)) -do - api_equal json:policy_types?ric=ricsim_g2_$i 1 -done - -echo "Register the service" -api_put_service 201 "rapp1" 0 "$CR_PATH/1" - -echo "Loading "$NUM_INST" policies in each group 1 ric" -for ((i=1; i<=$NUM_RICS; i++)) -do - inst=$((1000000+$i*$NUM_INST)) - api_put_policy 201 "rapp1" ricsim_g1_$i 1 $inst testdata/OSC/pi1_template.json $NUM_INST -done - -echo "Loading "$NUM_INST" policies in each group 2 ric" -for ((i=1; i<=$NUM_RICS; i++)) -do - inst=$((2000000+$i*$NUM_INST)) - api_put_policy 201 "rapp1" ricsim_g2_$i NOTYPE $inst testdata/STD/pi1_template.json $NUM_INST -done - -echo "Check the number of types in the agent for each group 1 rics, shall be 1" -for ((i=1; i<=$NUM_RICS; i++)) -do - api_equal json:policy_types?ric=ricsim_g1_$i 1 -done - -echo "Check the number of types in the agent for each group 2 rics, shall be 1" -for ((i=1; i<=$NUM_RICS; i++)) -do - api_equal json:policy_types?ric=ricsim_g2_$i 1 -done - -echo "Checking the number of policy instances in each group 1 simulator, shall be "$NUM_INST -for ((i=1; i<=$NUM_RICS; i++)) -do - sim_equal ricsim_g1_$i num_instances 50 -done - -echo "Checking the number of policy instances in each group 2 simulator, shall be "$NUM_INST -for ((i=1; i<=$NUM_RICS; i++)) -do - sim_equal ricsim_g2_$i num_instances 50 -done - -echo "Deleting "$NUM_INST" policies in each group 1 ric" -for ((i=1; i<=$NUM_RICS; i++)) -do - inst=$((1000000+$i*$NUM_INST)) - api_delete_policy 201 $NUM_INST -done - -echo "Deleting "$NUM_INST" policies in each group 2 ric" -for ((i=1; i<=$NUM_RICS; i++)) -do - inst=$((2000000+$i*$NUM_INST)) - api_delete_policy 201 $NUM_INST -done - -echo "Checking the number of policy instances in each group 1 simulator, shall be 0" -for ((i=1; i<=$NUM_RICS; i++)) -do - sim_equal ricsim_g1_$i num_instances 50 -done - -echo "Checking the number of policy instances in each group 1 simulator, shall be 0" -for ((i=1; i<=$NUM_RICS; i++)) -do - sim_equal ricsim_g2_$i num_instances 50 -done - - -check_policy_agent_logs - -#### TEST COMPLETE #### - -store_logs END - -print_result \ No newline at end of file diff --git a/test/auto-test/FTC500.sh b/test/auto-test/FTC500.sh deleted file mode 100755 index 41c08244..00000000 --- a/test/auto-test/FTC500.sh +++ /dev/null @@ -1,74 +0,0 @@ -#!/usr/bin/env bash - -# ============LICENSE_START=============================================== -# Copyright (C) 2020 Nordix Foundation. 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============LICENSE_END================================================= -# - - -TC_ONELINE_DESCR="Sample tests of the SDNC A1 controller restconf API" - -. ../common/testcase_common.sh $@ -. ../common/controller_api_functions.sh -. ../common/ricsimulator_api_functions.sh - -#### TEST BEGIN #### - -# Clean container and start all needed containers # -clean_containers - -start_ric_simulators ricsim_g1 1 OSC_2.1.0 -start_ric_simulators ricsim_g2 1 STD_1.1.3 - -start_sdnc - -# API tests -echo -e $YELLOW"TR13"$EYELLOW -controller_api_get_A1_policy_type 404 OSC ricsim_g1_1 1 - -sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json - - -controller_api_get_A1_policy_ids 200 OSC ricsim_g1_1 1 -controller_api_get_A1_policy_ids 200 STD ricsim_g2_1 - -controller_api_get_A1_policy_type 200 OSC ricsim_g1_1 1 -controller_api_get_A1_policy_type 200 OSC ricsim_g1_1 1 testdata/OSC/sim_1.json - -controller_api_put_A1_policy 202 OSC ricsim_g1_1 1 4000 testdata/OSC/pi1_template.json -controller_api_put_A1_policy 201 STD ricsim_g2_1 5000 testdata/STD/pi1_template.json - -controller_api_get_A1_policy_ids 200 OSC ricsim_g1_1 1 4000 -controller_api_get_A1_policy_ids 200 STD ricsim_g2_1 5000 - -controller_api_get_A1_policy_status 200 OSC ricsim_g1_1 1 4000 -controller_api_get_A1_policy_status 200 STD ricsim_g2_1 5000 - -VAL='NOT IN EFFECT' -controller_api_get_A1_policy_status 200 OSC ricsim_g1_1 1 4000 "$VAL" "false" -controller_api_get_A1_policy_status 200 STD ricsim_g2_1 5000 "UNDEFINED" - -controller_api_delete_A1_policy 202 OSC ricsim_g1_1 1 4000 -controller_api_delete_A1_policy 204 STD ricsim_g2_1 5000 - - - -store_logs END - -#### TEST COMPLETE #### - -print_result - -auto_clean_containers \ No newline at end of file diff --git a/test/auto-test/FTC600.sh b/test/auto-test/FTC600.sh deleted file mode 100755 index 4afe3768..00000000 --- a/test/auto-test/FTC600.sh +++ /dev/null @@ -1,87 +0,0 @@ -#!/usr/bin/env bash - -# ============LICENSE_START=============================================== -# Copyright (C) 2020 Nordix Foundation. 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============LICENSE_END================================================= -# - - -TC_ONELINE_DESCR="Resync of RIC via changes in the consul config" - -. ../common/testcase_common.sh $@ -. ../common/agent_api_functions.sh -. ../common/ricsimulator_api_functions.sh -. ../common/controller_api_functions.sh - -#### TEST BEGIN #### - - -# Clean container and start all needed containers # -clean_containers - -# Start one RIC of each type -start_ric_simulators ricsim_g1 1 OSC_2.1.0 -start_ric_simulators ricsim_g2 1 STD_1.1.3 - -start_mr - -start_cr - -start_consul_cbs - -prepare_consul_config NOSDNC ".consul_config.json" - -consul_config_app ".consul_config.json" - -start_control_panel - -start_policy_agent - -api_equal json:rics 2 120 - - -# Add an OSC RIC and check -start_ric_simulators ricsim_g2 2 STD_1.1.3 - -prepare_consul_config NOSDNC ".consul_config.json" - -consul_config_app ".consul_config.json" - -api_equal json:rics 3 120 - -check_policy_agent_logs -check_control_panel_logs - -# Remove one OSC RIC and check -start_ric_simulators ricsim_g2 1 STD_1.1.3 - -prepare_consul_config NOSDNC ".consul_config.json" - -consul_config_app ".consul_config.json" - -api_equal json:rics 2 120 - -check_policy_agent_logs -check_control_panel_logs - -store_logs END - - -#### TEST COMPLETE #### - - -print_result - -auto_clean_containers diff --git a/test/auto-test/FTC800.sh b/test/auto-test/FTC800.sh new file mode 100755 index 00000000..d948e372 --- /dev/null +++ b/test/auto-test/FTC800.sh @@ -0,0 +1,204 @@ +#!/bin/bash + +# ============LICENSE_START=============================================== +# Copyright (C) 2020 Nordix Foundation. 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. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END================================================= +# + +TC_ONELINE_DESCR="Create 10000 policies in sequence using http/https and Agent REST/DMAAP with/without SDNC controller" + +. ../common/testcase_common.sh $@ +. ../common/agent_api_functions.sh +. ../common/ricsimulator_api_functions.sh + +#### TEST BEGIN #### + +#Local vars in test script +########################## +# Path to callback receiver +CR_PATH="http://$CR_APP_NAME:$CR_EXTERNAL_PORT/callbacks" +# Number of policies in each sequence +NUM_POLICIES=10000 + +# Tested variants of REST/DMAAP/SDNC config +TESTED_VARIANTS="NOSDNC SDNC" + +#Test agent and simulator protocol versions (others are http only) +TESTED_PROTOCOLS="HTTP HTTPS" +for __httpx in $TESTED_PROTOCOLS ; do + for interface in $TESTED_VARIANTS ; do + + echo "#####################################################################" + echo "#####################################################################" + echo "### Testing agent via $interface using $__httpx" + echo "#####################################################################" + echo "#####################################################################" + + # Policy instance start id + START_ID=1 + + clean_containers + + if [ $__httpx == "HTTPS" ]; then + #"Using secure ports towards simulators" + use_simulator_https + else + #"Using non-secure ports towards simulators" + use_simulator_http + fi + + start_ric_simulators ricsim_g1 1 OSC_2.1.0 + start_ric_simulators ricsim_g2 1 STD_1.1.3 + + start_mr + + if [ $__httpx == "HTTPS" ]; then + + deviation "TR17 - agent cannot use https towards MR - test combo $interface and $__httpx" + #This is the intention + #echo "Using secure ports between agent and MR" + #use_mr_https + + #Work around until it is fixed + #"Using non-secure ports between agent and MR" + use_mr_http + else + #"Using non-secure ports between agent and MR" + use_mr_http + fi + + start_cr + + if [ $interface == "SDNC" ]; then + + start_sdnc + + if [ $__httpx == "HTTPS" ]; then + # "Using secure ports towards SDNC" + use_sdnc_https + else + #"Using non-secure ports towards SDNC" + use_sdnc_http + fi + fi + + start_consul_cbs + + if [ $interface == "SDNC" ]; then + prepare_consul_config SDNC ".consul_config.json" + else + prepare_consul_config NOSDNC ".consul_config.json" + fi + + consul_config_app ".consul_config.json" + + start_control_panel + + start_policy_agent + + set_agent_debug + + if [ $__httpx == "HTTPS" ]; then + # "Using secure ports towards the agent" + use_agent_rest_https + else + # "Using non-secure ports towards the agent" + use_agent_rest_http + fi + + + cr_equal received_callbacks 0 + mr_equal requests_submitted 0 + + + api_get_status 200 + + sim_print ricsim_g1_1 interface + sim_print ricsim_g2_1 interface + + sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json + + + api_equal json:policy_types 2 120 #Wait for the agent to refresh types from the simulators + + api_put_service 201 "rapp1" 3600 "$CR_PATH/callbacks/1" + + start_timer "Create polices in OSC via agent REST and $interface using "$__httpx + api_put_policy 201 "rapp1" ricsim_g1_1 1 $START_ID testdata/OSC/pi1_template.json $NUM_POLICIES + print_timer "Create polices in OSC via agent REST and $interface using "$__httpx + + sim_equal ricsim_g1_1 num_instances $NUM_POLICIES + + START_ID=$(($START_ID+$NUM_POLICIES)) + + start_timer "Create polices in STD via agent REST and $interface using "$__httpx + api_put_policy 201 "rapp1" ricsim_g2_1 NOTYPE $START_ID testdata/STD/pi1_template.json $NUM_POLICIES + print_timer "Create polices in STD via agent REST and $interface using "$__httpx + + sim_equal ricsim_g2_1 num_instances $NUM_POLICIES + + use_agent_dmaap + + START_ID=$(($START_ID+$NUM_POLICIES)) + + start_timer "Create polices in OSC via agent DMAAP, one by one, and $interface using "$__httpx + api_put_policy 201 "rapp1" ricsim_g1_1 1 $START_ID testdata/OSC/pi1_template.json $NUM_POLICIES + print_timer "Create polices in OSC via agent DMAAP, one by one, and $interface using "$__httpx + + sim_equal ricsim_g1_1 num_instances $((2*$NUM_POLICIES)) + + START_ID=$(($START_ID+$NUM_POLICIES)) + + start_timer "Create polices in STD via agent DMAAP, one by one, and $interface using "$__httpx + api_put_policy 201 "rapp1" ricsim_g2_1 NOTYPE $START_ID testdata/STD/pi1_template.json $NUM_POLICIES + print_timer "Create polices in STD via agent DMAAP, one by one, and $interface using "$__httpx + + sim_equal ricsim_g2_1 num_instances $((2*$NUM_POLICIES)) + + START_ID=$(($START_ID+$NUM_POLICIES)) + + start_timer "Create polices in OSC via agent DMAAP in batch and $interface using "$__httpx + api_put_policy_batch 201 "rapp1" ricsim_g1_1 1 $START_ID testdata/OSC/pi1_template.json $NUM_POLICIES + print_timer "Create polices in OSC via agent DMAAP in batch and $interface using "$__httpx + + sim_equal ricsim_g1_1 num_instances $((3*$NUM_POLICIES)) + + START_ID=$(($START_ID+$NUM_POLICIES)) + + start_timer "Create polices in STD via agent DMAAP in batch and $interface using "$__httpx + api_put_policy_batch 201 "rapp1" ricsim_g2_1 NOTYPE $START_ID testdata/STD/pi1_template.json $NUM_POLICIES + print_timer "Create polices in STD via agent DMAAP in batch and $interface using "$__httpx + + sim_equal ricsim_g2_1 num_instances $((3*$NUM_POLICIES)) + + if [ $interface == "SDNC" ]; then + sim_contains_str ricsim_g1_1 remote_hosts "a1-controller" + sim_contains_str ricsim_g2_1 remote_hosts "a1-controller" + else + sim_contains_str ricsim_g1_1 remote_hosts "policy-agent" + sim_contains_str ricsim_g2_1 remote_hosts "policy-agent" + fi + + check_policy_agent_logs + + store_logs "${__httpx}__${interface}" + done +done + +#### TEST COMPLETE #### + +print_result + +auto_clean_containers \ No newline at end of file diff --git a/test/auto-test/FTC810.sh b/test/auto-test/FTC810.sh new file mode 100755 index 00000000..2631a163 --- /dev/null +++ b/test/auto-test/FTC810.sh @@ -0,0 +1,237 @@ +#!/bin/bash + +# ============LICENSE_START=============================================== +# Copyright (C) 2020 Nordix Foundation. 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. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END================================================= +# + +TC_ONELINE_DESCR="Repeatedly create and delete policies in each RICs for 24h. Via agent REST/DMAAP/DMAAP_BATCH and SDNC using http" + +. ../common/testcase_common.sh $@ +. ../common/agent_api_functions.sh +. ../common/ricsimulator_api_functions.sh + +#### TEST BEGIN #### + +#Local vars in test script +########################## +# Path to callback receiver +CR_PATH="http://$CR_APP_NAME:$CR_EXTERNAL_PORT/callbacks" +# Number of RICs per interface type (OSC and STD) +NUM_RICS=30 +# Number of policy instances per RIC +NUM_INSTANCES=5 + +clean_containers + +start_ric_simulators ricsim_g1 $NUM_RICS OSC_2.1.0 + +start_ric_simulators ricsim_g2 $NUM_RICS STD_1.1.3 + +start_mr + +start_cr + +start_consul_cbs + +prepare_consul_config SDNC ".consul_config.json" +consul_config_app ".consul_config.json" + +start_sdnc + +start_control_panel + +start_policy_agent + +use_agent_rest_http + +api_get_status 200 + +echo "Print the interface for group 1 simulators, shall be OSC" +for ((i=1; i<=$NUM_RICS; i++)) +do + sim_print ricsim_g1_$i interface +done + +echo "Print the interface for group 2 simulators, shall be STD" +for ((i=1; i<=$NUM_RICS; i++)) +do + sim_print ricsim_g2_$i interface +done + +echo "Load policy type in group 1 simulators" +for ((i=1; i<=$NUM_RICS; i++)) +do + sim_put_policy_type 201 ricsim_g1_$i 1 testdata/OSC/sim_1.json +done + +echo "Check the number of instances in group 1 simulators, shall be 0" +for ((i=1; i<=$NUM_RICS; i++)) +do + sim_equal ricsim_g1_$i num_instances 0 +done + +echo "Check the number of instances in group 2 simulators, shall be 0" +for ((i=1; i<=$NUM_RICS; i++)) +do + sim_equal ricsim_g2_$i num_instances 0 +done + +echo "Wait for the agent to refresh types from the simulator" +api_equal json:policy_types 2 120 + +echo "Check the number of types in the agent for each ric is 1" +for ((i=1; i<=$NUM_RICS; i++)) +do + api_equal json:policy_types?ric=ricsim_g1_$i 1 120 +done + +echo "Register a service" +api_put_service 201 "serv1" 0 "$CR_PATH/1" + +TEST_DURATION=$((24*3600)) +TEST_START=$SECONDS + +AGENT_INTERFACES="REST DMAAP DMAAP-BATCH" + +MR_MESSAGES=0 + +while [ $(($SECONDS-$TEST_START)) -lt $TEST_DURATION ]; do + + echo "" + echo "#########################################################################################################" + echo -e $BOLD"INFO: Test executed for: "$(($SECONDS-$TEST_START)) "seconds. Target is: "$TEST_DURATION" seconds."$EBOLD + echo "#########################################################################################################" + echo "" + + for interface in $AGENT_INTERFACES ; do + + echo "############################################" + echo "## Testing using agent interface: $interface ##" + echo "############################################" + + if [ $interface == "REST" ]; then + use_agent_rest_http + else + use_agent_dmaap + fi + + echo "Create $NUM_INSTANCES instances in each OSC RIC" + INSTANCE_ID=200000 + INSTANCES=0 + for ((i=1; i<=$NUM_RICS; i++)) + do + if [ $interface == "DMAAP-BATCH" ]; then + api_put_policy_batch 201 "serv1" ricsim_g1_$i 1 $INSTANCE_ID testdata/OSC/pi1_template.json $NUM_INSTANCES + else + api_put_policy 201 "serv1" ricsim_g1_$i 1 $INSTANCE_ID testdata/OSC/pi1_template.json $NUM_INSTANCES + fi + if [ $interface != "REST" ]; then + MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES)) + fi + sim_equal ricsim_g1_$i num_instances $NUM_INSTANCES + INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES)) + INSTANCES=$(($INSTANCES+$NUM_INSTANCES)) + done + + api_equal json:policy_ids $INSTANCES + + echo "Create $NUM_INSTANCES instances in each STD RIC" + for ((i=1; i<=$NUM_RICS; i++)) + do + if [ $interface == "DMAAP-BATCH" ]; then + api_put_policy_batch 201 "serv1" ricsim_g2_$i NOTYPE $INSTANCE_ID testdata/STD/pi1_template.json $NUM_INSTANCES + else + api_put_policy 201 "serv1" ricsim_g2_$i NOTYPE $INSTANCE_ID testdata/STD/pi1_template.json $NUM_INSTANCES + fi + if [ $interface != "REST" ]; then + MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES)) + fi + sim_equal ricsim_g2_$i num_instances $NUM_INSTANCES + INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES)) + INSTANCES=$(($INSTANCES+$NUM_INSTANCES)) + done + + api_equal json:policy_ids $INSTANCES + + + echo "Delete all instances in each OSC RIC" + + INSTANCE_ID=200000 + for ((i=1; i<=$NUM_RICS; i++)) + do + if [ $interface == "DMAAP-BATCH" ]; then + api_delete_policy_batch 204 $INSTANCE_ID $NUM_INSTANCES + else + api_delete_policy 204 $INSTANCE_ID $NUM_INSTANCES + fi + if [ $interface != "REST" ]; then + MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES)) + fi + INSTANCES=$(($INSTANCES-$NUM_INSTANCES)) + sim_equal ricsim_g1_$i num_instances 0 + INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES)) + done + + api_equal json:policy_ids $INSTANCES + + echo "Delete all instances in each STD RIC" + + for ((i=1; i<=$NUM_RICS; i++)) + do + if [ $interface == "DMAAP-BATCH" ]; then + api_delete_policy_batch 204 $INSTANCE_ID $NUM_INSTANCES + else + api_delete_policy 204 $INSTANCE_ID $NUM_INSTANCES + fi + if [ $interface != "REST" ]; then + MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES)) + fi + INSTANCES=$(($INSTANCES-$NUM_INSTANCES)) + sim_equal ricsim_g2_$i num_instances 0 + INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES)) + done + + api_equal json:policy_ids 0 + + cr_equal received_callbacks 0 + + mr_equal requests_submitted $MR_MESSAGES + mr_equal requests_fetched $MR_MESSAGES + mr_equal responses_submitted $MR_MESSAGES + mr_equal responses_fetched $MR_MESSAGES + mr_equal current_requests 0 + mr_equal current_responses 0 + + + for ((i=1; i<=$NUM_RICS; i++)) + do + sim_contains_str ricsim_g1_$i remote_hosts "a1-controller" + sim_contains_str ricsim_g2_$i remote_hosts "a1-controller" + done + + done + +done + +check_policy_agent_logs + +#### TEST COMPLETE #### + +store_logs END + +print_result + +auto_clean_containers \ No newline at end of file diff --git a/test/auto-test/FTC900.sh b/test/auto-test/FTC900.sh new file mode 100755 index 00000000..13a9af06 --- /dev/null +++ b/test/auto-test/FTC900.sh @@ -0,0 +1,116 @@ +#!/usr/bin/env bash + +# ============LICENSE_START=============================================== +# Copyright (C) 2020 Nordix Foundation. 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. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END================================================= +# + +TC_ONELINE_DESCR="Testing of the health check app" + +. ../common/testcase_common.sh $@ +. ../common/agent_api_functions.sh +. ../common/ricsimulator_api_functions.sh + +#### TEST BEGIN #### + +#Local vars in test script +########################## +# Path to callback receiver +CR_PATH="http://$CR_APP_NAME:$CR_EXTERNAL_PORT/callbacks" + +clean_containers + +start_ric_simulators ricsim_g1 6 OSC_2.1.0 + +start_ric_simulators ricsim_g2 5 STD_1.1.3 + + + +start_consul_cbs + +prepare_consul_config NOSDNC ".consul_config.json" +consul_config_app ".consul_config.json" + + +start_policy_agent + + +use_agent_rest_http + +api_get_status 200 + +sim_print ricsim_g1_1 interface +sim_print ricsim_g1_2 interface +sim_print ricsim_g1_3 interface +sim_print ricsim_g1_4 interface +sim_print ricsim_g1_5 interface +sim_print ricsim_g1_6 interface + +sim_print ricsim_g2_1 interface +sim_print ricsim_g2_2 interface +sim_print ricsim_g2_3 interface +sim_print ricsim_g2_4 interface +sim_print ricsim_g2_5 interface + +sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json +sim_put_policy_type 201 ricsim_g1_2 1 testdata/OSC/sim_1.json +sim_put_policy_type 201 ricsim_g1_3 1 testdata/OSC/sim_1.json +sim_put_policy_type 201 ricsim_g1_4 1 testdata/OSC/sim_1.json +sim_put_policy_type 201 ricsim_g1_5 1 testdata/OSC/sim_1.json +sim_put_policy_type 201 ricsim_g1_6 1 testdata/OSC/sim_1.json + +api_equal json:policy_types 2 120 + +sleep_wait 30 "Give the agent some extra time...." + +# Create policies +use_agent_rest_http + +api_put_service 201 "rapp1" 3600 "$CR_PATH/1" + +api_put_policy 201 "rapp1" ricsim_g1_1 1 2010 testdata/OSC/pi1_template.json 1 +api_put_policy 201 "rapp1" ricsim_g1_2 1 2020 testdata/OSC/pi1_template.json 1 +api_put_policy 201 "rapp1" ricsim_g1_3 1 2030 testdata/OSC/pi1_template.json 1 +api_put_policy 201 "rapp1" ricsim_g1_4 1 2040 testdata/OSC/pi1_template.json 1 +api_put_policy 201 "rapp1" ricsim_g1_5 1 2050 testdata/OSC/pi1_template.json 1 +api_put_policy 201 "rapp1" ricsim_g1_6 1 2060 testdata/OSC/pi1_template.json 1 + +sim_equal ricsim_g1_1 num_instances 1 +sim_equal ricsim_g1_2 num_instances 1 +sim_equal ricsim_g1_3 num_instances 1 +sim_equal ricsim_g1_4 num_instances 1 +sim_equal ricsim_g1_5 num_instances 1 +sim_equal ricsim_g1_6 num_instances 1 + +api_put_policy 201 "rapp1" ricsim_g2_1 NOTYPE 2110 testdata/STD/pi1_template.json 1 +api_put_policy 201 "rapp1" ricsim_g2_2 NOTYPE 2120 testdata/STD/pi1_template.json 1 +api_put_policy 201 "rapp1" ricsim_g2_3 NOTYPE 2130 testdata/STD/pi1_template.json 1 +api_put_policy 201 "rapp1" ricsim_g2_4 NOTYPE 2140 testdata/STD/pi1_template.json 1 +api_put_policy 201 "rapp1" ricsim_g2_5 NOTYPE 2150 testdata/STD/pi1_template.json 1 + +sim_equal ricsim_g2_1 num_instances 1 +sim_equal ricsim_g2_2 num_instances 1 +sim_equal ricsim_g2_3 num_instances 1 +sim_equal ricsim_g2_4 num_instances 1 +sim_equal ricsim_g2_5 num_instances 1 + + +check_policy_agent_logs + +#### TEST COMPLETE #### + +store_logs END + +print_result \ No newline at end of file diff --git a/test/auto-test/FTC_SDNC.sh b/test/auto-test/FTC_SDNC.sh deleted file mode 100755 index 71faf7ae..00000000 --- a/test/auto-test/FTC_SDNC.sh +++ /dev/null @@ -1,96 +0,0 @@ -#!/usr/bin/env bash - -# ============LICENSE_START=============================================== -# Copyright (C) 2020 Nordix Foundation. 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============LICENSE_END================================================= -# - -TC_ONELINE_DESCR="Create 1 policy with SDNC and 1 policy without SDNC over agent REST" - -. ../common/testcase_common.sh $@ -. ../common/agent_api_functions.sh -. ../common/ricsimulator_api_functions.sh -. ../common/controller_api_functions.sh - -#### TEST BEGIN #### - -VARIANTS="NOSDNC SDNC" - -for TEST in $VARIANTS ; do - - - clean_containers - - start_ric_simulators ricsim_g1 1 OSC_2.1.0 - start_ric_simulators ricsim_g2 1 STD_1.1.3 - - start_mr - - start_cr - - start_consul_cbs - - prepare_consul_config $TEST ".consul_config.json" - consul_config_app ".consul_config.json" - - start_control_panel - - if [ $TEST == "SDNC" ]; then - start_sdnc - fi - - start_policy_agent - - - set_agent_debug - - use_agent_rest_http - - echo "Using: "$TEST - - api_get_status 200 - - sim_print ricsim_g1_1 interface - sim_print ricsim_g2_1 interface - - sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json - - api_equal json:policy_types 2 120 #Wait for the agent to refresh types from the simulator - - api_put_service 201 "rapp1" 3600 "http://callback-receiver:8090/callbacks/1" - - api_put_policy 201 "rapp1" ricsim_g1_1 1 2000 testdata/OSC/pi1_template.json 10 - - api_put_policy 201 "rapp1" ricsim_g2_1 NOTYPE 3000 testdata/STD/pi1_template.json 10 - - sim_equal ricsim_g1_1 num_instances 10 - sim_equal ricsim_g2_1 num_instances 10 - - - check_policy_agent_logs - check_control_panel_logs - - store_logs $TEST - - echo "" - echo -e $BOLD"Test complete for variant: "$TEST $EBOLD - echo "" - -done - -#### TEST COMPLETE #### - -print_result - diff --git a/test/auto-test/README.md b/test/auto-test/README.md index 9aac651e..6f96355e 100644 --- a/test/auto-test/README.md +++ b/test/auto-test/README.md @@ -34,8 +34,22 @@ Test case command: Discription: local: test image: POLICY_AGENT_LOCAL_IMAGE=o-ran-sc/nonrtric-policy-agent remote: test image: nexus3.o-ran-sc.org:10004/o-ran-sc/nonrtric-policy-agent + ``` +### Test case categories +1-99 - Basic sanity tests + +100-199 - API tests + +300-399 - Config changes and sync + +800-899 - Stability and capacity test + +900-999 - Misc test + +Suites + ### Test case file A test case file contains a number of steps to verify a certain functionality. A description of the test case should be given to the ``TC_ONELINE_DESCR`` var. The description will be printed in diff --git a/test/auto-test/Suite-interfaces.sh b/test/auto-test/Suite-interfaces.sh index 38eb83af..d57133d1 100755 --- a/test/auto-test/Suite-interfaces.sh +++ b/test/auto-test/Suite-interfaces.sh @@ -1,6 +1,6 @@ #!/bin/bash -TS_ONELINE_DESCR="Test suite - interface testing. Agent REST and SNDC controller resconf" +TS_ONELINE_DESCR="Test suite - interface testing. Agent REST, DMAAP and SNDC controller resconf" . ../common/testsuite_common.sh @@ -8,8 +8,9 @@ suite_setup ############# TEST CASES ################# -./FTC10.sh $1 -./FTC500.sh $1 +./FTC100.sh $1 +./FTC110.sh $1 +./FTC150.sh $1 ########################################## diff --git a/test/common/agent_api_functions.sh b/test/common/agent_api_functions.sh index 46026c19..08c8f961 100644 --- a/test/common/agent_api_functions.sh +++ b/test/common/agent_api_functions.sh @@ -23,8 +23,11 @@ # Generic function to query the agent via the REST or DMAAP interface. # Used by all other agent api test functions +# If operation prefix is '_BATCH' the the send and get response is split in two sequences, +# one for sending the requests and one for receiving the response +# but only when using the DMAAP interface # REST or DMAAP is controlled of the base url of $ADAPTER -# arg: GET|PUT|POST|DELETE [] +# arg: (GET|PUT|POST|DELETE|GET_BATCH|PUT_BATCH|POST_BATCH|DELETE_BATCH []) | (RESPONSE ) # (Not for test scripts) __do_curl_to_agent() { echo "(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG @@ -39,30 +42,41 @@ __do_curl_to_agent() { httpcode=" -sw %{http_code}" accept='' content='' - + batch=0 + if [[ $1 == *"_BATCH" ]]; then + batch=1 + fi if [ $# -gt 2 ]; then content=" -H Content-Type:application/json" fi - if [ $1 == "GET" ]; then + if [ $1 == "GET" ] || [ $1 == "GET_BATCH" ]; then oper="GET" - if [ $# -ne 2 ];then + if [ $# -ne 2 ]; then paramError=1 fi - elif [ $1 == "PUT" ]; then + elif [ $1 == "PUT" ] || [ $1 == "PUT_BATCH" ]; then oper="PUT" if [ $# -eq 3 ]; then file=" --data-binary @$3" fi accept=" -H accept:application/json" - elif [ $1 == "POST" ]; then + elif [ $1 == "POST" ] || [ $1 == "POST_BATCH" ]; then oper="POST" accept=" -H accept:*/*" - if [ $# -ne 2 ];then + if [ $# -ne 2 ]; then paramError=1 fi - elif [ $1 == "DELETE" ]; then + elif [ $1 == "DELETE" ] || [ $1 == "DELETE_BATCH" ]; then oper="DELETE" - if [ $# -ne 2 ];then + if [ $# -ne 2 ]; then + paramError=1 + fi + elif [ $1 == "RESPONSE" ]; then + oper="RESPONSE" + if [ $# -ne 2 ]; then + paramError=1 + fi + if ! [ $ADAPTER == $DMAAPBASE ]; then paramError=1 fi else @@ -73,7 +87,7 @@ __do_curl_to_agent() { if [ $paramError -eq 1 ]; then ((RES_CONF_FAIL++)) echo "-Incorrect number of parameters to __do_curl_agent " $@ >> $HTTPLOG - echo "-Expected: GET|PUT|POST|DELETE []" >> $HTTPLOG + echo "-Expected: (GET|PUT|POST|DELETE|GET_BATCH|PUT_BATCH|POST_BATCH|DELETE_BATCH []) | (RESPONSE ) []" >> $HTTPLOG echo "-Returning response 000" >> $HTTPLOG echo "-000" return 1 @@ -119,70 +133,81 @@ __do_curl_to_agent() { echo $res return 0 else - requestUrl=$2 - if [ $1 == "PUT" ] && [ $# -eq 3 ]; then - payload="$(cat $3 | tr -d '\n' | tr -d ' ' )" - echo "payload: "$payload >> $HTTPLOG - file=" --data-binary "$payload - fi - #urlencode the request url since it will be carried by send-request url - requestUrl=$(python3 -c "from __future__ import print_function; import urllib.parse, sys; print(urllib.parse.quote(sys.argv[1]))" "$2") - url=" "${ADAPTER}"/send-request?url="${requestUrl}"&operation="${oper} - curlString="curl -X POST${timeout}${httpcode}${content}${url}${file}" - echo " CMD: "$curlString >> $HTTPLOG - res=$($curlString) - retcode=$? - if [ $retcode -ne 0 ]; then - echo " RETCODE: "$retcode >> $HTTPLOG - echo "000" - return 1 - fi - echo " RESP: "$res >> $HTTPLOG - status=${res:${#res}-3} - if [ $status -ne 200 ]; then - echo "000" - return 1 - fi - cid=${res:0:${#res}-3} - url=" "${ADAPTER}"/receive-response?correlationid="${cid} - curlString="curl -X GET"${timeout}${httpcode}${url} - echo " CMD: "$curlString >> $HTTPLOG - res=$($curlString) - retcode=$? - if [ $retcode -ne 0 ]; then - echo " RETCODE: "$retcode >> $HTTPLOG - echo "000" - return 1 - fi - echo " RESP: "$res >> $HTTPLOG - status=${res:${#res}-3} - TS=$SECONDS - # wait of the reply from the agent... - while [ $status -eq 204 ]; do - if [ $(($SECONDS - $TS)) -gt 90 ]; then - echo " RETCODE: (timeout after 90s)" >> $HTTPLOG - echo "000" - return 1 + if [ $oper != "RESPONSE" ]; then + requestUrl=$2 + if [ $1 == "PUT" ] && [ $# -eq 3 ]; then + payload="$(cat $3 | tr -d '\n' | tr -d ' ' )" + echo "payload: "$payload >> $HTTPLOG + file=" --data-binary "$payload fi - sleep 1 - echo " CMD: "$curlString >> $HTTPLOG - res=$($curlString) - if [ $retcode -ne 0 ]; then - echo " RETCODE: "$retcode >> $HTTPLOG - echo "000" - return 1 - fi - echo " RESP: "$res >> $HTTPLOG - status=${res:${#res}-3} - done - if [ $status -eq 200 ]; then - body=${res:0:${#res}-3} - echo $body - return 0 - fi - echo "Status not 200, returning response 000" >> $HTTPLOG - echo "0000" - return 1 + #urlencode the request url since it will be carried by send-request url + requestUrl=$(python3 -c "from __future__ import print_function; import urllib.parse, sys; print(urllib.parse.quote(sys.argv[1]))" "$2") + url=" "${ADAPTER}"/send-request?url="${requestUrl}"&operation="${oper} + curlString="curl -X POST${timeout}${httpcode}${content}${url}${file}" + echo " CMD: "$curlString >> $HTTPLOG + res=$($curlString) + retcode=$? + if [ $retcode -ne 0 ]; then + echo " RETCODE: "$retcode >> $HTTPLOG + echo "000" + return 1 + fi + echo " RESP: "$res >> $HTTPLOG + status=${res:${#res}-3} + if [ $status -ne 200 ]; then + echo "000" + return 1 + fi + cid=${res:0:${#res}-3} + if [[ $batch -eq 1 ]]; then + echo $cid"200" + return 0 + fi + fi + if [ $oper == "RESPONSE" ] || [ $batch -eq 0 ]; then + if [ $oper == "RESPONSE" ]; then + cid=$2 + fi + url=" "${ADAPTER}"/receive-response?correlationid="${cid} + curlString="curl -X GET"${timeout}${httpcode}${url} + echo " CMD: "$curlString >> $HTTPLOG + res=$($curlString) + retcode=$? + if [ $retcode -ne 0 ]; then + echo " RETCODE: "$retcode >> $HTTPLOG + echo "000" + return 1 + fi + echo " RESP: "$res >> $HTTPLOG + status=${res:${#res}-3} + TS=$SECONDS + # wait of the reply from the agent... + while [ $status -eq 204 ]; do + if [ $(($SECONDS - $TS)) -gt 90 ]; then + echo " RETCODE: (timeout after 90s)" >> $HTTPLOG + echo "000" + return 1 + fi + sleep 0.01 + echo " CMD: "$curlString >> $HTTPLOG + res=$($curlString) + if [ $retcode -ne 0 ]; then + echo " RETCODE: "$retcode >> $HTTPLOG + echo "000" + return 1 + fi + echo " RESP: "$res >> $HTTPLOG + status=${res:${#res}-3} + done + if [ $status -eq 200 ]; then + body=${res:0:${#res}-3} + echo $body + return 0 + fi + echo "Status not 200, returning response 000" >> $HTTPLOG + echo "0000" + return 1 + fi fi } @@ -402,6 +427,86 @@ api_put_policy() { return 0 } +# API Test function: PUT /policy to run in batch +# args: [] +# (Function for test scripts) +api_put_policy_batch() { + echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD + echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG + ((RES_TEST++)) + + if [ $# -lt 6 ] || [ $# -gt 7 ]; then + __print_err " []" $@ + return 1 + fi + + ric=$3 + count=0 + max=1 + + if [ $# -eq 7 ]; then + max=$7 + fi + + pid=$5 + file=$6 + ARR="" + while [ $count -lt $max ]; do + query="/policy?id=$pid&ric=$ric&service=$2" + + if [ $4 == "NOTYPE" ]; then + query="/policy?id=$pid&ric=$ric&service=$2" + else + query="/policy?id=$pid&ric=$ric&service=$2&type=$4" + fi + + file=".p.json" + sed 's/XXX/'${pid}'/g' $6 > $file + res="$(__do_curl_to_agent PUT_BATCH $query $file)" + status=${res:${#res}-3} + echo -ne " Requested(batch) "$count"("$max")${SAMELINE}" + + if [ $status -ne 200 ]; then + let pid=$pid+1 + echo " Requested(batch) "$count"?("$max")" + echo -e $RED" FAIL. Exepected status 200 (in request), got "$status $ERED + ((RES_FAIL++)) + return 1 + fi + cid=${res:0:${#res}-3} + ARR=$ARR" "$cid + let pid=$pid+1 + let count=$count+1 + echo -ne " Requested(batch) "$count"("$max")${SAMELINE}" + done + + echo "" + count=0 + for cid in $ARR; do + + res="$(__do_curl_to_agent RESPONSE $cid)" + status=${res:${#res}-3} + echo -ne " Created(batch) "$count"("$max")${SAMELINE}" + + if [ $status -ne $1 ]; then + let pid=$pid+1 + echo " Created(batch) "$count"?("$max")" + echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED + ((RES_FAIL++)) + return 1 + fi + + let count=$count+1 + echo -ne " Created(batch) "$count"("$max")${SAMELINE}" + done + + echo "" + + ((RES_PASS++)) + echo -e $GREEN" PASS"$EGREEN + return 0 +} + # API Test function: DELETE /policy # args: [count] @@ -448,6 +553,74 @@ api_delete_policy() { return 0 } +# API Test function: DELETE /policy to run in batch +# args: [count] +# (Function for test scripts) +api_delete_policy_batch() { + echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD + echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG + ((RES_TEST++)) + + if [ $# -lt 2 ] || [ $# -gt 3 ]; then + __print_err " [count]" $@ + return 1 + fi + + count=0 + max=1 + + if [ $# -eq 3 ]; then + max=$3 + fi + + pid=$2 + ARR="" + while [ $count -lt $max ]; do + query="/policy?id="$pid + res="$(__do_curl_to_agent DELETE_BATCH $query)" + status=${res:${#res}-3} + echo -ne " Requested(batch) "$count"("$max")${SAMELINE}" + + if [ $status -ne 200 ]; then + let pid=$pid+1 + echo " Requested(batch) "$count"?("$max")" + echo -e $RED" FAIL. Exepected status 200 (in request), got "$status $ERED + ((RES_FAIL++)) + return 1 + fi + cid=${res:0:${#res}-3} + ARR=$ARR" "$cid + let pid=$pid+1 + let count=$count+1 + echo -ne " Requested(batch) "$count"("$max")${SAMELINE}" + done + + echo "" + + count=0 + for cid in $ARR; do + + res="$(__do_curl_to_agent RESPONSE $cid)" + status=${res:${#res}-3} + echo -ne " Deleted(batch) "$count"("$max")${SAMELINE}" + + if [ $status -ne $1 ]; then + let pid=$pid+1 + echo " Deleted(batch) "$count"?("$max")" + echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED + ((RES_FAIL++)) + return 1 + fi + + let count=$count+1 + echo -ne " Deleted(batch) "$count"("$max")${SAMELINE}" + done + + ((RES_PASS++)) + echo -e $GREEN" PASS"$EGREEN + return 0 +} + # API Test function: GET /policy_ids # args: |NORIC |NOSERVICE |NOTYPE ([> $HTTPLOG ((RES_TEST++)) - #Number of accepted parameters: 1, 2, 4, 7, 10, 13,... paramError=1 if [ $# -eq 1 ]; then diff --git a/test/common/controller_api_functions.sh b/test/common/controller_api_functions.sh index 25de2a95..37d1b40c 100644 --- a/test/common/controller_api_functions.sh +++ b/test/common/controller_api_functions.sh @@ -43,7 +43,7 @@ __do_curl_to_controller() { fi echo "$json" > .sndc.payload.json echo " FILE: $json" >> $HTTPLOG - curlString="curl -sw %{http_code} -X POST http://$SDNC_USER:$SDNC_PWD@localhost:$SDNC_EXTERNAL_PORT$SDNC_API_URL$1 -H accept:application/json -H Content-Type:application/json --data-binary @.sndc.payload.json" + curlString="curl -skw %{http_code} -X POST $SDNC_HTTPX://$SDNC_USER:$SDNC_PWD@localhost:$SDNC_LOCAL_PORT$SDNC_API_URL$1 -H accept:application/json -H Content-Type:application/json --data-binary @.sndc.payload.json" echo " CMD: "$curlString >> $HTTPLOG res=$($curlString) retcode=$? @@ -61,6 +61,7 @@ __do_curl_to_controller() { return 1 fi body=${res:0:${#res}-3} + echo " JSON: "$body >> $HTTPLOG echo "$body" > .sdnc-reply.json res=$(python3 ../common/extract_sdnc_reply.py .sdnc-reply.json) echo " EXTRACED BODY+CODE: "$res >> $HTTPLOG diff --git a/test/common/extract_sdnc_reply.py b/test/common/extract_sdnc_reply.py index cb80e5e2..9158edcb 100644 --- a/test/common/extract_sdnc_reply.py +++ b/test/common/extract_sdnc_reply.py @@ -32,8 +32,12 @@ try: resp=status if ( 'body' in output.keys()): body=str(output['body']) - bodyJson=json.loads(body) - resp=str(json.dumps(bodyJson))+str(status) + try: + bodyJson=json.loads(body) + resp=str(json.dumps(bodyJson))+str(status) + except Exception as e1: + resp=body+str(status) + print(resp) except Exception as e: diff --git a/test/common/ricsimulator_api_functions.sh b/test/common/ricsimulator_api_functions.sh index f4cbc02e..c30af1ad 100644 --- a/test/common/ricsimulator_api_functions.sh +++ b/test/common/ricsimulator_api_functions.sh @@ -34,7 +34,7 @@ __execute_curl_to_sim() { retcode=$? if [ $retcode -ne 0 ]; then echo " RETCODE: "$retcode - echo -e $RED" ERROR - fatal error when executing curl."$ERED + echo -e $RED" FAIL - fatal error when executing curl."$ERED return 1 fi status=${res:${#res}-3} @@ -42,7 +42,7 @@ __execute_curl_to_sim() { echo -e $GREEN" OK"$EGREEN return 0 fi - echo -e $RED" ERROR - expected http response: "$1" but got http response: "$status $ERED + echo -e $RED" FAIL - expected http response: "$1" but got http response: "$status $ERED return 1 } @@ -82,6 +82,27 @@ sim_print() { echo -e $BOLD"INFO(${BASH_LINENO[0]}): $app, $2 = $(__do_curl $RIC_SIM_LOCALHOST$port/counter/$2)"$EBOLD } +# Tests if a variable value in the RIC simulator contains the target string and and optional timeout +# Arg: - This test set pass or fail depending on if the variable contains +# the target or not. +# Arg: - This test waits up to the timeout seconds +# before setting pass or fail depending on if the variable value contains the target +# value or not. +# (Function for test scripts) +sim_contains_str() { + + if [ $# -eq 3 ] || [ $# -eq 4 ]; then + app=$1 + port=$(__find_sim_port $app) + __var_test $app "$RIC_SIM_LOCALHOST$port/counter/" $2 "contain_str" $3 $4 + return 0 + else + ((RES_CONF_FAIL++)) + __print_err "needs three or four args: [ timeout ]" + return 1 + fi +} + # Simulator API: Put a policy type in a ric # args: # (Function for test scripts) diff --git a/test/common/test_env.sh b/test/common/test_env.sh index 38839865..24a9561e 100755 --- a/test/common/test_env.sh +++ b/test/common/test_env.sh @@ -71,9 +71,6 @@ RIC_SIM_LOCAL_IMAGE_TAG="latest" RIC_SIM_REMOTE_IMAGE="nexus3.o-ran-sc.org:10004/o-ran-sc/a1-simulator" RIC_SIM_REMOTE_IMAGE_TAG="1.0.1" -RIC_SIM_REMOTE_IMAGE="a1test" -RIC_SIM_REMOTE_IMAGE_TAG="latest" - #Consul remote image and tag CONSUL_REMOTE_IMAGE="consul" @@ -115,6 +112,8 @@ export MR_INTERNAL_PORT=3905 # MR stub contai export MR_EXTERNAL_SECURE_PORT=3906 # MR stub container external secure port (host -> container) export MR_INTERNAL_SECURE_PORT=3906 # MR stub container internal secure port (container -> container) export MR_APP_NAME="message-router" # Name for the MR +export MR_READ_URL="/events/A1-POLICY-AGENT-READ/users/policy-agent" # Path to read messages from MR +export MR_WRITE_URL="/events/A1-POLICY-AGENT-WRITE" # Path write messages to MR export CR_EXTERNAL_PORT=8090 # Callback receiver container external port (host -> container) export CR_INTERNAL_PORT=8090 # Callback receiver container internal port (container -> container) @@ -141,19 +140,25 @@ export RIC_SIM_INTERNAL_SECURE_PORT=8185 # RIC Simulator export SDNC_APP_NAME="a1-controller" # Name of the SNDC A1 Controller container export SDNC_EXTERNAL_PORT=8282 # SNDC A1 Controller container external port (host -> container) export SDNC_INTERNAL_PORT=8181 # SNDC A1 Controller container internal port (container -> container) +export SDNC_EXTERNAL_SECURE_PORT=8443 # SNDC A1 Controller container external securee port (host -> container) +export SDNC_INTERNAL_SECURE_PORT=8443 # SNDC A1 Controller container internal secure port (container -> container) export SDNC_DB_APP_NAME="sdnc-db" # Name of the SDNC DB container SDNC_USER="admin" # SDNC username SDNC_PWD="Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U" # SNDC PWD SDNC_API_URL="/restconf/operations/A1-ADAPTER-API:" # Base url path for SNDC API +SDNC_ALIVE_URL="/apidoc/explorer/" # Base url path for SNDC API docs (for alive check) SDNC_KARAF_LOG="/opt/opendaylight/data/log/karaf.log" # Path to karaf log export SDNC_ONAP_APP_NAME="a1-adapter" # Name of the ONAP A1 Adapter container export SDNC_ONAP_EXTERNAL_PORT=8282 # ONAP A1 Adapter container external port (host -> container) export SDNC_ONAP_INTERNAL_PORT=8181 # ONAP A1 Adapter container internal port (container -> container) +export SDNC_ONAP_EXTERNAL_SECURE_PORT=8443 # SNDC A1 Adapter container external securee port (host -> container) +export SDNC_ONAP_INTERNAL_SECURE_PORT=8343 # SNDC A1 Adapter container internal secure port (container -> container) export SDNC_ONAP_DB_APP_NAME="sdnc-onap-db" # Name of the ONAP A1 Adapter DB container SDNC_ONAP_USER="admin" # ONAP A1 Adapter username SDNC_ONAP_PWD="Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U" # ONAP A1 Adapter PWD SDNC_ONAP_API_URL="/restconf/operations/A1-ADAPTER-API:" # Base url path for ONAP A1 Adapter API +SDNC_ONAP_ALIVE_URL="/apidoc/explorer/" # Base url path for ONAP A1 Adapter API docs (for alive check) SDNC_ONAP_PROPERTIES_FILE="/opt/onap/ccsdk/data/properties/a1-adapter-api-dg.properties" SDNC_ONAP_KARAF_LOG="/opt/opendaylight/data/log/karaf.log" # Path to karaf log diff --git a/test/common/testcase_common.sh b/test/common/testcase_common.sh index 830ee733..28c65d26 100755 --- a/test/common/testcase_common.sh +++ b/test/common/testcase_common.sh @@ -44,7 +44,7 @@ if [ $? -ne 0 ] || [ -z tmp ]; then fi # Just resetting any previous echo formatting... -echo -ne $EBOLD$ERED$EGREEN +echo -ne $EBOLD # source test environment variables . ../common/test_env.sh @@ -59,18 +59,29 @@ G1_COUNT=0 G2_COUNT=0 G3_COUNT=0 -# Var to switch between http and https. Extra curl flag needed for https +# Vars to switch between http and https. Extra curl flag needed for https export RIC_SIM_HTTPX="http" export RIC_SIM_LOCALHOST=$RIC_SIM_HTTPX"://localhost:" export RIC_SIM_PORT=$RIC_SIM_INTERNAL_PORT export RIC_SIM_CERT_MOUNT_DIR="./fakedir" #Fake dir so that the sim container does not find any cert +export MR_HTTPX="http" +export MR_PORT=$MR_INTERNAL_PORT +export MR_LOCAL_PORT=$MR_EXTERNAL_PORT #When agent is running outside the docker net + +export SDNC_HTTPX="http" +export SDNC_PORT=$SDNC_INTERNAL_PORT +export SDNC_LOCAL_PORT=$SDNC_EXTERNAL_PORT #When agent is running outside the docker net + #Localhost constant LOCALHOST="http://localhost:" # Make curl retries for http response codes set in this env var, space separated list of codes AGENT_RETRY_CODES="" +# Var to contol if the agent runs in a container (normal = 0) or as application on the local machine ( = 1) +AGENT_STAND_ALONE=0 + # Var to hold 'auto' in case containers shall be stopped when test case ends AUTO_CLEAN="" @@ -118,10 +129,20 @@ RES_TEST=0 RES_PASS=0 RES_FAIL=0 RES_CONF_FAIL=0 +RES_DEVIATION=0 + +#File to keep deviation messages +DEVIATION_FILE=".tmp_deviations" +rm $DEVIATION_FILE &> /dev/null #Var for measuring execution time TCTEST_START=$SECONDS +#File to save timer measurement results +TIMER_MEASUREMENTS=".timer_measurement.txt" +echo -e "Activity \t Duration" > $TIMER_MEASUREMENTS + + echo "-------------------------------------------------------------------------------------------------" echo "----------------------------------- Test case: "$ATC echo "----------------------------------- Started: "$(date) @@ -356,8 +377,10 @@ app="Near-RT RIC Simulator"; __check_and_pull_image $1 "$app" $RIC_SIM_PREFIX app="Consul"; __check_and_pull_image $1 "$app" $CONSUL_APP_NAME $CONSUL_IMAGE app="CBS"; __check_and_pull_image $1 "$app" $CBS_APP_NAME $CBS_IMAGE app="SDNC DB"; __check_and_pull_image $1 "$app" $SDNC_APP_NAME $SDNC_DB_IMAGE -app="SDNC ONAP A1 Adapter"; __check_and_pull_image $1 "$app" $SDNC_ONAP_APP_NAME $SDNC_ONAP_A1_ADAPTER_IMAGE -app="SDNC ONAP DB"; __check_and_pull_image $1 "$app" $SDNC_ONAP_APP_NAME $SDNC_ONAP_DB_IMAGE + +echo -e $YELLOW"SDNC ONAP image is skipped"$EYELLOW +#app="SDNC ONAP A1 Adapter"; __check_and_pull_image $1 "$app" $SDNC_ONAP_APP_NAME $SDNC_ONAP_A1_ADAPTER_IMAGE +#app="SDNC ONAP DB"; __check_and_pull_image $1 "$app" $SDNC_ONAP_APP_NAME $SDNC_ONAP_DB_IMAGE # MR stub image not checked, will be built by this script - only local image # CR stub image not checked, will be built by this script - only local image @@ -505,11 +528,25 @@ print_result() { fi fi + if [ $RES_DEVIATION -gt 0 ]; then + echo "Test case deviations" + echo "====================================" + cat $DEVIATION_FILE + fi + echo "" + echo "Timer measurement in the test script" + echo "====================================" + column -t -s $'\t' $TIMER_MEASUREMENTS + echo "" + echo "++++ Number of tests: "$RES_TEST echo "++++ Number of passed tests: "$RES_PASS echo "++++ Number of failed tests: "$RES_FAIL echo "" echo "++++ Number of failed configs: "$RES_CONF_FAIL + echo "" + echo "++++ Number of test case deviations: "$RES_DEVIATION + echo "" echo "------------------------------------- Test case complete ---------------------------------" echo "-------------------------------------------------------------------------------------------------" echo "" @@ -519,6 +556,73 @@ print_result() { ###### Functions for start, configuring, stoping, cleaning etc ###### ##################################################################### +# Start timer for time measurement +# args - (any args will be printed though) +start_timer() { + echo -e $BOLD"INFO(${BASH_LINENO[0]}): "${FUNCNAME[0]}"," $@ $EBOLD + TC_TIMER=$SECONDS + echo " Timer started" +} + +# Print the value of the time (in seconds) +# args - - timer value and message will be printed both on screen +# and in the timer measurement report +print_timer() { + echo -e $BOLD"INFO(${BASH_LINENO[0]}): "${FUNCNAME[0]}"," $@ $EBOLD + if [ $# -lt 1 ]; then + ((RES_CONF_FAIL++)) + __print_err "need 1 or more args, " $@ + exit 1 + fi + duration=$(($SECONDS-$TC_TIMER)) + if [ $duration -eq 0 ]; then + duration="<1 second" + else + duration=$duration" seconds" + fi + echo " Timer duration :" $duration + + echo -e "${@:1} \t $duration" >> $TIMER_MEASUREMENTS +} + +# Print the value of the time (in seconds) and reset the timer +# args - - timer value and message will be printed both on screen +# and in the timer measurement report +print_and_reset_timer() { + echo -e $BOLD"INFO(${BASH_LINENO[0]}): "${FUNCNAME[0]}"," $@ $EBOLD + if [ $# -lt 1 ]; then + ((RES_CONF_FAIL++)) + __print_err "need 1 or more args, " $@ + exit 1 + fi + duration=$(($SECONDS-$TC_TIMER))" seconds" + if [ $duration -eq 0 ]; then + duration="<1 second" + else + duration=$duration" seconds" + fi + echo " Timer duration :" $duration + TC_TIMER=$SECONDS + echo " Timer reset" + + echo -e "${@:1} \t $duration" >> $TIMER_MEASUREMENTS + +} +# Print info about a deviations from intended tests +# Each deviation counted is also printed in the testreport +# args +deviation() { + echo -e $BOLD"DEVIATION(${BASH_LINENO[0]}): "${FUNCNAME[0]} $EBOLD + if [ $# -lt 1 ]; then + ((RES_CONF_FAIL++)) + __print_err "need 1 or more args, " $@ + exit 1 + fi + ((RES_DEVIATION++)) + echo -e $BOLD$YELLOW" Test case deviation: ${@:1}"$EYELLOW$EBOLD + echo "Line: ${BASH_LINENO[0]} - ${@:1}" >> $DEVIATION_FILE + echo "" +} # Stop and remove all containers # args: - @@ -612,6 +716,8 @@ __print_err() { __find_sim_port() { name=$1" " #Space appended to prevent matching 10 if 1 is desired.... cmdstr="docker ps --filter name=${name} --format \"{{.Names}} {{.Ports}}\" | grep '${name}' | sed s/0.0.0.0:// | cut -f 2 -d ' ' | cut -f 1 -d '-'" + cmdstr="docker ps --filter name=${name} --format \"{{.Names}} {{.Ports}}\" | grep '${name}' | cut -f 3 -d ',' | sed s/0.0.0.0:// | cut -f 2 -d ' ' | cut -f 1 -d '-'" + res=$(eval $cmdstr) if [[ "$res" =~ ^[0-9]+$ ]]; then echo $res @@ -659,31 +765,33 @@ __check_container_start() { appname=$1 localport=$2 url=$3 - app_started=0 - for i in {1..10}; do - if [ "$(docker inspect --format '{{ .State.Running }}' $appname)" == "true" ]; then - echo -e " Container $BOLD$1$EBOLD$GREEN running$EGREEN on$BOLD image $(docker inspect --format '{{ .Config.Image }}' ${appname}) $EBOLD" - app_started=1 - break - else - sleep $i - fi - done - if [ $app_started -eq 0 ]; then - ((RES_CONF_FAIL++)) - echo "" - echo -e $RED" Container $BOLD${appname}$EBOLD could not be started"$ERED - return 1 - fi - if [ $localport -eq 0 ]; then - while [ $localport -eq 0 ]; do - echo -ne " Waiting for container ${appname} to publish its ports...${SAMELINE}" - localport=$(__find_sim_port $appname) - sleep 1 - echo -ne " Waiting for container ${appname} to publish its ports...retrying....${SAMELINE}" + if [[ $appname != "STANDALONE_"* ]] ; then + app_started=0 + for i in {1..10}; do + if [ "$(docker inspect --format '{{ .State.Running }}' $appname)" == "true" ]; then + echo -e " Container $BOLD$1$EBOLD$GREEN running$EGREEN on$BOLD image $(docker inspect --format '{{ .Config.Image }}' ${appname}) $EBOLD" + app_started=1 + break + else + sleep $i + fi done - echo -ne " Waiting for container ${appname} to publish its ports...retrying....$GREEN OK $EGREEN" - echo "" + if [ $app_started -eq 0 ]; then + ((RES_CONF_FAIL++)) + echo "" + echo -e $RED" Container $BOLD${appname}$EBOLD could not be started"$ERED + return 1 + fi + if [ $localport -eq 0 ]; then + while [ $localport -eq 0 ]; do + echo -ne " Waiting for container ${appname} to publish its ports...${SAMELINE}" + localport=$(__find_sim_port $appname) + sleep 1 + echo -ne " Waiting for container ${appname} to publish its ports...retrying....${SAMELINE}" + done + echo -ne " Waiting for container ${appname} to publish its ports...retrying....$GREEN OK $EGREEN" + echo "" + fi fi pa_st=false @@ -744,6 +852,8 @@ __start_container() { echo -e $RED"Problem to launch container(s) with docker-compose"$ERED cat .dockererr fi + elif [ "$2" == "STANDALONE" ]; then + echo "Skipping docker-compose" else docker-compose up -d $2 &> .dockererr if [ $? -ne 0 ]; then @@ -751,11 +861,14 @@ __start_container() { cat .dockererr fi fi - + app_prefix="" + if [ "$2" == "STANDALONE" ]; then + app_prefix="STANDALONE_" + fi shift; shift; cntr=0 while [ $cntr -lt $variableArgCount ]; do - app=$1; shift; + app=$app_prefix$1; shift; port=$1; shift; url=$1; shift; httpx=$1; shift; @@ -795,6 +908,7 @@ consul_config_app() { return 1 fi body="$(__do_curl $LOCALHOST$CBS_EXTERNAL_PORT/service_component_all/$POLICY_AGENT_APP_NAME)" + echo $body > ".output"$1 if [ $? -ne 0 ]; then echo -e $RED" FAIL - json config could not be loaded from consul/cbs, contents cannot be checked." $ERED @@ -849,7 +963,11 @@ prepare_consul_config() { config_json=$config_json"\n \"controller\": [" config_json=$config_json"\n {" config_json=$config_json"\n \"name\": \"$SDNC_APP_NAME\"," - config_json=$config_json"\n \"baseUrl\": \"http://$SDNC_APP_NAME:$SDNC_INTERNAL_PORT\"," + if [ $AGENT_STAND_ALONE -eq 0 ]; then + config_json=$config_json"\n \"baseUrl\": \"$SDNC_HTTPX://$SDNC_APP_NAME:$SDNC_PORT\"," + else + config_json=$config_json"\n \"baseUrl\": \"$SDNC_HTTPX://localhost:$SDNC_LOCAL_PORT\"," + fi config_json=$config_json"\n \"userName\": \"$SDNC_USER\"," config_json=$config_json"\n \"password\": \"$SDNC_PWD\"" config_json=$config_json"\n }" @@ -859,7 +977,11 @@ prepare_consul_config() { config_json=$config_json"\n \"controller\": [" config_json=$config_json"\n {" config_json=$config_json"\n \"name\": \"$SDNC_ONAP_APP_NAME\"," - config_json=$config_json"\n \"baseUrl\": \"http://$SDNC_ONAP_APP_NAME:$SDNC_ONAP_INTERNAL_PORT\"," + if [ $AGENT_STAND_ALONE -eq 0 ]; then + config_json=$config_json"\n \"baseUrl\": \"http://$SDNC_ONAP_APP_NAME:$SDNC_ONAP_INTERNAL_PORT\"," + else + config_json=$config_json"\n \"baseUrl\": \"http://localhost:$SDNC_ONAP_EXTERNAL_PORT\"," + fi config_json=$config_json"\n \"userName\": \"$SDNC_ONAP_USER\"," config_json=$config_json"\n \"password\": \"$SDNC_ONAP_PWD\"" config_json=$config_json"\n }" @@ -871,7 +993,11 @@ prepare_consul_config() { config_json=$config_json"\n \"dmaap_publisher\": {" config_json=$config_json"\n \"type\": \"$MR_APP_NAME\"," config_json=$config_json"\n \"dmaap_info\": {" - config_json=$config_json"\n \"topic_url\": \"http://$MR_APP_NAME:$MR_INTERNAL_PORT/events/A1-POLICY-AGENT-WRITE\"" + if [ $AGENT_STAND_ALONE -eq 0 ]; then + config_json=$config_json"\n \"topic_url\": \"$MR_HTTPX://$MR_APP_NAME:$MR_PORT$MR_WRITE_URL\"" + else + config_json=$config_json"\n \"topic_url\": \"$MR_HTTPX://localhost:$MR_LOCAL_PORT$MR_WRITE_URL\"" + fi config_json=$config_json"\n }" config_json=$config_json"\n }" config_json=$config_json"\n }," @@ -879,7 +1005,11 @@ prepare_consul_config() { config_json=$config_json"\n \"dmaap_subscriber\": {" config_json=$config_json"\n \"type\": \"$MR_APP_NAME\"," config_json=$config_json"\n \"dmaap_info\": {" - config_json=$config_json"\n \"topic_url\": \"http://$MR_APP_NAME:$MR_INTERNAL_PORT/events/A1-POLICY-AGENT-READ/users/policy-agent\"" + if [ $AGENT_STAND_ALONE -eq 0 ]; then + config_json=$config_json"\n \"topic_url\": \"$MR_HTTPX://$MR_APP_NAME:$MR_PORT$MR_READ_URL\"" + else + config_json=$config_json"\n \"topic_url\": \"$MR_HTTPX://localhost:$MR_LOCAL_PORT$MR_READ_URL\"" + fi config_json=$config_json"\n }" config_json=$config_json"\n }" config_json=$config_json"\n }," @@ -901,7 +1031,11 @@ prepare_consul_config() { fi config_json=$config_json"\n {" config_json=$config_json"\n \"name\": \"$ric\"," - config_json=$config_json"\n \"baseUrl\": \"$RIC_SIM_HTTPX://$ric:$RIC_SIM_PORT\"," + if [ $AGENT_STAND_ALONE -eq 0 ]; then + config_json=$config_json"\n \"baseUrl\": \"$RIC_SIM_HTTPX://$ric:$RIC_SIM_PORT\"," + else + config_json=$config_json"\n \"baseUrl\": \"$RIC_SIM_HTTPX://localhost:$(__find_sim_port $ric)\"," + fi if [ $1 == "SDNC" ]; then config_json=$config_json"\n \"controller\": \"$SDNC_APP_NAME\"," elif [ $1 == "SDNC_ONAP" ]; then @@ -1033,8 +1167,24 @@ start_sdnc() { echo -e $BOLD"Starting SDNC A1 Controller"$EBOLD - __start_container sdnc NODOCKERARGS $SDNC_APP_NAME $SDNC_EXTERNAL_PORT "/apidoc/explorer" "http" + __start_container sdnc NODOCKERARGS $SDNC_APP_NAME $SDNC_EXTERNAL_PORT $SDNC_ALIVE_URL "http" + +} + +use_sdnc_http() { + echo -e $BOLD"Using http between agent and SDNC"$EBOLD + export SDNC_HTTPX="http" + export SDNC_PORT=$SDNC_INTERNAL_PORT + export SDNC_LOCAL_PORT=$SDNC_EXTERNAL_PORT + echo "" +} +use_sdnc_https() { + echo -e $BOLD"Using https between agent and SDNC"$EBOLD + export SDNC_HTTPX="https" + export SDNC_PORT=$SDNC_INTERNAL_SECURE_PORT + export SDNC_LOCAL_PORT=$SDNC_EXTERNAL_SECURE_PORT + echo "" } ####################### @@ -1048,7 +1198,7 @@ start_sdnc_onap() { echo -e $BOLD"Starting SDNC ONAP A1 Adapter"$EBOLD - __start_container sdnc_onap NODOCKERARGS $SDNC_ONAP_APP_NAME $SDNC_ONAP_EXTERNAL_PORT "/apidoc/explorer" "http" + __start_container sdnc_onap NODOCKERARGS $SDNC_ONAP_APP_NAME $SDNC_ONAP_EXTERNAL_PORT $SDNC_ONAP_ALIVE_URL "http" } @@ -1068,6 +1218,7 @@ config_sdnc_onap() { exit 1 fi + #Config of the prop file shall be inserted here #Copy file to /tmp and then to final destination, a trick to get correct permission of the file. @@ -1097,9 +1248,25 @@ start_mr() { echo -e $BOLD"Starting Message Router 'mrstub'"$EBOLD export MR_CERT_MOUNT_DIR="./cert" __start_container mr NODOCKERARGS $MR_APP_NAME $MR_EXTERNAL_PORT "/" "http" +} +use_mr_http() { + echo -e $BOLD"Using http between agent and MR"$EBOLD + export MR_HTTPX="http" + export MR_PORT=$MR_INTERNAL_PORT + export MR_LOCAL_PORT=$MR_EXTERNAL_PORT + echo "" +} + +use_mr_https() { + echo -e $BOLD"Using https between agent and MR"$EBOLD + export MR_HTTPX="https" + export MR_PORT=$MR_INTERNAL_SECURE_PORT + export MR_LOCAL_PORT=$MR_EXTERNAL_SECURE_PORT + echo "" } + ################ ### CR functions ################ @@ -1119,14 +1286,30 @@ start_cr() { ### Policy Agents functions ########################### -# Start the policy agwent +# Use an agent on the local machine instead of container +use_agent_stand_alone() { + AGENT_STAND_ALONE=1 +} + +# Start the policy agent # args: - # (Function for test scripts) start_policy_agent() { echo -e $BOLD"Starting Policy Agent"$EBOLD - __start_container policy_agent NODOCKERARGS $POLICY_AGENT_APP_NAME $POLICY_AGENT_EXTERNAL_PORT "/status" "http" + if [ $AGENT_STAND_ALONE -eq 0 ]; then + __start_container policy_agent NODOCKERARGS $POLICY_AGENT_APP_NAME $POLICY_AGENT_EXTERNAL_PORT "/status" "http" + else + echo -e $RED"The consul config produced by this test script (filename '.output"$ERED + echo -e $RED"where the file name is the file in the consul_config_app command in this script) must be pointed out by the agent "$ERED + echo -e $RED"application.yaml"$ERED + echo -e $RED"The application jar may need to be built beforefor continuing"$ERED + echo -e $RED"The agent shall now be running on port $POLICY_AGENT_EXTERNAL_PORT for http"$ERED + + read -p "" + __start_container policy_agent "STANDALONE" $POLICY_AGENT_APP_NAME $POLICY_AGENT_EXTERNAL_PORT "/status" "http" + fi } @@ -1146,18 +1329,20 @@ use_agent_rest_https() { echo -e $BOLD"Using agent REST interface with https"$EBOLD export ADAPTER=$RESTBASE_SECURE echo "" + return 0 } # All calls to the agent will be directed to the agent dmaap interface from now on # args: - # (Function for test scripts) use_agent_dmaap() { - echo -e $BOLD"Using agent DMAAP interface"$EBOLD + echo -e $BOLD"Agent using DMAAP interface"$EBOLD export ADAPTER=$DMAAPBASE echo "" - + return 0 } + # Turn on debug level tracing in the agent # args: - # (Function for test scripts) @@ -1168,8 +1353,8 @@ set_agent_debug() { __print_err "could not set debug mode" $@ return 1 fi - return 0 echo "" + return 0 } # Perform curl retries when making direct call to the agent for the specified http response codes @@ -1179,6 +1364,7 @@ use_agent_retries() { echo -e $BOLD"Do curl retries to the agent REST inteface for these response codes:$@"$EBOLD AGENT_RETRY_CODES=$@ echo "" + return } ################# @@ -1242,7 +1428,7 @@ store_logs() { __print_err "need one arg, " $@ exit 1 fi - echo -e $BOLD"Storing all container logs, Policy Agent app log and consul config using prefix: "$1 + echo -e $BOLD"Storing all container logs, Policy Agent app log and consul config using prefix: "$1$EBOLD docker logs $CONSUL_APP_NAME > $TESTLOGS/$ATC/$1_consul.log 2>&1 docker logs $CBS_APP_NAME > $TESTLOGS/$ATC/$1_cbs.log 2>&1 @@ -1318,7 +1504,7 @@ __var_test() { fi #echo -e "---- ${1} sim test criteria: \033[1m ${3} \033[0m ${4} ${5} within ${6} seconds ----" - echo -e $BOLD"TEST(${BASH_LINENO[1]}): ${1}, ${3} ${4} ${5} within ${6} seconds" + echo -e $BOLD"TEST(${BASH_LINENO[1]}): ${1}, ${3} ${4} ${5} within ${6} seconds"$EBOLD ((RES_TEST++)) start=$SECONDS ctr=0 @@ -1496,5 +1682,3 @@ mr_print() { fi echo -e $BOLD"INFO(${BASH_LINENO[0]}): mrstub, $1 = $(__do_curl $LOCALHOST$MR_EXTERNAL_PORT/counter/$1)"$EBOLD } - - diff --git a/test/cr/cr.py b/test/cr/cr.py index f65d7c0b..105ccc25 100644 --- a/test/cr/cr.py +++ b/test/cr/cr.py @@ -90,7 +90,6 @@ def events_write(id): try: print("Received callback for id: "+id +", content-type="+request.content_type) try: - print("data:"+request.get_data) if (request.content_type == MIME_JSON): msg = request.json print("Payload(json): "+str(msg)) @@ -102,7 +101,7 @@ def events_write(id): print("Payload(content-type="+request.content_type+"). Setting data to empty, quoted, string") except: msg="\"\"" - print("Payload does not contain any json or text data, setting empty string as payload") + print("(Exception) Payload does not contain any json or text data, setting empty string as payload") cntr_msg_callbacks += 1 if (id in msg_callbacks.keys()): diff --git a/test/simulator-group/sdnc/docker-compose.yml b/test/simulator-group/sdnc/docker-compose.yml index 85d88cd7..2c8a29ad 100644 --- a/test/simulator-group/sdnc/docker-compose.yml +++ b/test/simulator-group/sdnc/docker-compose.yml @@ -47,6 +47,7 @@ services: entrypoint: ["/opt/onap/sdnc/bin/startODL.sh"] ports: - ${SDNC_EXTERNAL_PORT}:${SDNC_INTERNAL_PORT} + - ${SDNC_EXTERNAL_SECURE_PORT}:${SDNC_INTERNAL_SECURE_PORT} links: - db:dbhost - db:sdnctldb01 diff --git a/test/simulator-group/sdnc_onap/.gitignore b/test/simulator-group/sdnc_onap/.gitignore new file mode 100644 index 00000000..33841960 --- /dev/null +++ b/test/simulator-group/sdnc_onap/.gitignore @@ -0,0 +1 @@ +.dockererr \ No newline at end of file diff --git a/test/simulator-group/sdnc_onap/docker-compose.yml b/test/simulator-group/sdnc_onap/docker-compose.yml index 0415d342..d4d757ed 100644 --- a/test/simulator-group/sdnc_onap/docker-compose.yml +++ b/test/simulator-group/sdnc_onap/docker-compose.yml @@ -47,6 +47,7 @@ services: entrypoint: ["/opt/onap/sdnc/bin/startODL.sh"] ports: - ${SDNC_ONAP_EXTERNAL_PORT}:${SDNC_ONAP_INTERNAL_PORT} + - ${SDNC_ONAP_EXTERNAL_SECURE_PORT}:${SDNC_ONAP_INTERNAL_SECURE_PORT} links: - db:dbhost - db:sdnctldb01 -- 2.16.6