From 49f0e5ab01b51aee8713a17aed86cd6d229b40cc Mon Sep 17 00:00:00 2001 From: BjornMagnussonXA Date: Sun, 8 Nov 2020 22:41:39 +0100 Subject: [PATCH] Adapted test scripts to changes in PMS 2.0 Issue-ID: NONRTRIC-307 Signed-off-by: BjornMagnussonXA Change-Id: I41effdcfbe41c742d618d247b0d60f6e8090048f --- test/auto-test/FTC1.sh | 58 ++++++---- test/auto-test/FTC10.sh | 15 +-- test/auto-test/FTC100.sh | 81 +++++++++----- test/auto-test/FTC110.sh | 16 +-- test/auto-test/FTC150.sh | 3 + test/auto-test/FTC300.sh | 12 +- test/auto-test/FTC310.sh | 32 ++++-- test/auto-test/FTC350.sh | 80 +++++++------ test/auto-test/FTC800.sh | 14 ++- test/auto-test/FTC810.sh | 21 ++-- test/auto-test/FTC850.sh | 12 +- test/auto-test/FTC900.sh | 11 +- test/auto-test/PM_DEMO.sh | 79 +++++++++++-- .../auto-test/demo-testdata/STD2/pi1_template.json | 9 ++ .../demo-testdata/STD2/qos-agent-modified.json | 36 ++++++ .../demo-testdata/STD2/qos2-agent-modified.json | 36 ++++++ test/auto-test/demo-testdata/STD2/sim_qos.json | 56 ++++++++++ test/auto-test/demo-testdata/STD2/sim_qos2.json | 56 ++++++++++ test/common/README.md | 60 +++++++--- test/common/agent_api_functions.sh | 24 ++-- test/common/api_curl.sh | 9 +- test/common/create_policies_process.py | 89 +++++++++------ test/common/create_rics_json.py | 2 +- test/common/delete_policies_process.py | 46 +++++--- test/common/ricsimulator_api_functions.sh | 4 +- test/common/test_env-onap-guilin.sh | 2 + test/common/test_env-onap-master.sh | 12 +- test/common/test_env-oran-master.sh | 12 +- test/common/testcase_common.sh | 74 ++++++++---- test/cr/Dockerfile | 8 +- test/cr/README.md | 20 +++- test/cr/app/cr.py | 110 ++++++++++++++---- test/cr/basic_test.sh | 124 +++++++++++++++++++-- test/cr/cr-build-start.sh | 2 +- test/simulator-group/sim-monitor.js | 61 +++++++++- 35 files changed, 989 insertions(+), 297 deletions(-) create mode 100644 test/auto-test/demo-testdata/STD2/pi1_template.json create mode 100644 test/auto-test/demo-testdata/STD2/qos-agent-modified.json create mode 100644 test/auto-test/demo-testdata/STD2/qos2-agent-modified.json create mode 100644 test/auto-test/demo-testdata/STD2/sim_qos.json create mode 100644 test/auto-test/demo-testdata/STD2/sim_qos2.json diff --git a/test/auto-test/FTC1.sh b/test/auto-test/FTC1.sh index 4d05b9b7..1898457a 100755 --- a/test/auto-test/FTC1.sh +++ b/test/auto-test/FTC1.sh @@ -23,9 +23,13 @@ TC_ONELINE_DESCR="Sanity test, create service and then create,update and delete #App names to include in the test, space separated list INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM SDNC" +#SUPPORTED TEST ENV FILE +SUPPORTED_PROFILES="ONAP-MASTER ONAP-GUILIN" + . ../common/testcase_common.sh $@ . ../common/agent_api_functions.sh . ../common/ricsimulator_api_functions.sh +. ../common/cr_api_functions.sh #### TEST BEGIN #### @@ -45,9 +49,24 @@ for __httpx in $TESTED_PROTOCOLS ; do echo "#####################################################################" echo "#####################################################################" + # Clean container and start all needed containers # + clean_containers + + if [ $__httpx == "HTTPS" ]; then + use_agent_rest_https + else + use_agent_rest_http + fi + + start_policy_agent + + set_agent_trace + + # Create service to be able to receive events when rics becomes available + # Must use rest towards the agent since dmaap is not configured yet + api_put_service 201 "ric-registration" 0 "$CR_PATH/ric-registration" if [ $__httpx == "HTTPS" ]; then - CR_PATH="https://$CR_APP_NAME:$CR_EXTERNAL_SECURE_PORT/callbacks" use_cr_https use_simulator_https use_mr_https @@ -60,7 +79,6 @@ for __httpx in $TESTED_PROTOCOLS ; do use_agent_rest_https fi else - CR_PATH="http://$CR_APP_NAME:$CR_EXTERNAL_PORT/callbacks" use_cr_http use_simulator_http use_mr_http @@ -74,9 +92,6 @@ for __httpx in $TESTED_PROTOCOLS ; do fi fi - # 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 if [ "$PMS_VERSION" == "V2" ]; then @@ -87,6 +102,8 @@ for __httpx in $TESTED_PROTOCOLS ; do start_cr + start_control_panel + start_consul_cbs if [[ $interface = *"SDNC"* ]]; then @@ -98,14 +115,6 @@ for __httpx in $TESTED_PROTOCOLS ; do consul_config_app ".consul_config.json" - start_control_panel - - start_policy_agent - - set_agent_debug - set_agent_trace - - cr_equal received_callbacks 0 mr_equal requests_submitted 0 sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json @@ -113,13 +122,16 @@ for __httpx in $TESTED_PROTOCOLS ; do if [ "$PMS_VERSION" == "V2" ]; then api_equal json:rics 3 60 - #api_equal json:policy_schemas 2 120 - api_equal json:policy-types 2 120 api_equal json:policies 0 - api_equal json:policy_instances 0 + api_equal json:policy-instances 0 + + cr_equal received_callbacks 3 120 + + cr_api_check_all_sync_events 200 ric-registration ricsim_g1_1 ricsim_g2_1 ricsim_g3_1 + else api_equal json:rics 2 60 @@ -144,7 +156,7 @@ for __httpx in $TESTED_PROTOCOLS ; do api_put_service 201 "serv1" 1000 "$CR_PATH/1" - api_get_service_ids 200 "serv1" + api_get_service_ids 200 "serv1" "ric-registration" api_put_services_keepalive 200 "serv1" @@ -163,7 +175,7 @@ for __httpx in $TESTED_PROTOCOLS ; do echo "############################################" if [ "$PMS_VERSION" == "V2" ]; then - notificationurl="http://localhost:80" + notificationurl=$CR_PATH"/test" else notificationurl="" fi @@ -180,14 +192,16 @@ for __httpx in $TESTED_PROTOCOLS ; do if [ "$PMS_VERSION" == "V2" ]; then api_equal json:policies 0 - api_equal json:policy_instances 0 + api_equal json:policy-instances 0 else api_equal json:policies 0 api_equal json:policy_ids 0 fi - cr_equal received_callbacks 0 + if [ "$PMS_VERSION" == "V2" ]; then + cr_equal received_callbacks 3 + fi if [[ $interface = *"DMAAP"* ]]; then VAL=11 # Number of Agent API calls over DMAAP @@ -217,6 +231,10 @@ for __httpx in $TESTED_PROTOCOLS ; do check_policy_agent_logs check_control_panel_logs + if [[ $interface = *"SDNC"* ]]; then + check_sdnc_logs + fi + store_logs "${__httpx}__${interface}" done diff --git a/test/auto-test/FTC10.sh b/test/auto-test/FTC10.sh index 52a2bb33..ee57b62a 100755 --- a/test/auto-test/FTC10.sh +++ b/test/auto-test/FTC10.sh @@ -22,6 +22,9 @@ TC_ONELINE_DESCR="Basic use case, register service, create/update policy, delete #App names to include in the test, space separated list INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM" +#SUPPORTED TEST ENV FILE +SUPPORTED_PROFILES="ONAP-MASTER ONAP-GUILIN ORAN-MASTER" + . ../common/testcase_common.sh $@ . ../common/agent_api_functions.sh . ../common/ricsimulator_api_functions.sh @@ -30,12 +33,6 @@ INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM" generate_uuid -#Local vars in test script -########################## -# Path to callback receiver -CR_PATH="http://$CR_APP_NAME:$CR_EXTERNAL_PORT/callbacks" - -use_cr_http use_simulator_http use_mr_http use_agent_rest_http @@ -53,8 +50,6 @@ fi start_mr -start_cr - start_consul_cbs prepare_consul_config NOSDNC ".consul_config.json" @@ -89,7 +84,7 @@ fi # Create policies if [ "$PMS_VERSION" == "V2" ]; then - notificationurl="http://localhost:80" + notificationurl=$CR_PATH"/test" else notificationurl="" fi @@ -207,8 +202,6 @@ api_delete_services 204 "service1" api_get_services 404 "service1" - - check_policy_agent_logs #### TEST COMPLETE #### diff --git a/test/auto-test/FTC100.sh b/test/auto-test/FTC100.sh index 13d375b3..e0b8d873 100755 --- a/test/auto-test/FTC100.sh +++ b/test/auto-test/FTC100.sh @@ -23,9 +23,14 @@ TC_ONELINE_DESCR="Full agent API walk through using agent REST/DMAAP and with/wi #App names to include in the test, space separated list INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM SDNC" + +#SUPPORTED TEST ENV FILE +SUPPORTED_PROFILES="ONAP-MASTER ONAP-GUILIN" + . ../common/testcase_common.sh $@ . ../common/agent_api_functions.sh . ../common/ricsimulator_api_functions.sh +. ../common/cr_api_functions.sh #### TEST BEGIN #### @@ -46,8 +51,25 @@ for __httpx in $TESTED_PROTOCOLS ; do echo "#####################################################################" echo "#####################################################################" + # Clean container and start all needed containers # + clean_containers + + if [ $__httpx == "HTTPS" ]; then + use_agent_rest_https + else + use_agent_rest_http + fi + + start_policy_agent + + set_agent_trace + + # Create service to be able to receive events when rics becomes available + # Must use rest towards the agent since dmaap is not configured yet + api_put_service 201 "ric-registration" 0 "$CR_PATH/ric-registration" + + if [ $__httpx == "HTTPS" ]; then - CR_PATH="https://$CR_APP_NAME:$CR_EXTERNAL_SECURE_PORT/callbacks" use_cr_https use_simulator_https use_mr_https @@ -60,7 +82,6 @@ for __httpx in $TESTED_PROTOCOLS ; do use_agent_rest_https fi else - CR_PATH="http://$CR_APP_NAME:$CR_EXTERNAL_PORT/callbacks" use_cr_http use_simulator_http use_mr_http @@ -74,9 +95,6 @@ for __httpx in $TESTED_PROTOCOLS ; do fi fi - # 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 if [ "$PMS_VERSION" == "V2" ]; then @@ -87,6 +105,8 @@ for __httpx in $TESTED_PROTOCOLS ; do start_cr + start_control_panel + start_consul_cbs if [[ $interface = *"SDNC"* ]]; then @@ -98,28 +118,17 @@ for __httpx in $TESTED_PROTOCOLS ; do consul_config_app ".consul_config.json" - start_control_panel - - start_policy_agent - - set_agent_debug - - cr_equal received_callbacks 0 - mr_equal requests_submitted 0 - sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json sim_put_policy_type 201 ricsim_g1_1 2 testdata/OSC/sim_2.json if [ "$PMS_VERSION" == "V2" ]; then api_equal json:rics 3 60 - #api_equal json:policy-schemas 3 120 - api_equal json:policy-types 3 120 api_equal json:policies 0 - api_equal json:policy_instances 0 + api_equal json:policy-instances 0 else api_equal json:rics 2 60 @@ -132,6 +141,12 @@ for __httpx in $TESTED_PROTOCOLS ; do api_equal json:policy_ids 0 fi + if [ "$PMS_VERSION" == "V2" ]; then + cr_equal received_callbacks 3 120 + cr_api_check_all_sync_events 200 ric-registration ricsim_g1_1 ricsim_g2_1 ricsim_g3_1 + fi + mr_equal requests_submitted 0 + echo "############################################" echo "############## Health check ################" @@ -162,18 +177,18 @@ for __httpx in $TESTED_PROTOCOLS ; do api_get_services 200 "service1" "service1" 2000 "$CR_PATH/1" - api_get_service_ids 200 "service1" "service2" + api_get_service_ids 200 "service1" "service2" "ric-registration" api_put_service 201 "service3" 5000 "$CR_PATH/3" - api_get_service_ids 200 "service1" "service2" "service3" + api_get_service_ids 200 "service1" "service2" "service3" "ric-registration" api_get_services 200 "service1" "service1" 2000 "$CR_PATH/1" - 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 NOSERVICE "service1" 2000 "$CR_PATH/1" "service2" 300 "ftp://localhost:80/test" "service3" 5000 "$CR_PATH/3" "ric-registration" 0 "$CR_PATH/ric-registration" api_get_services 200 @@ -195,26 +210,26 @@ for __httpx in $TESTED_PROTOCOLS ; do api_put_services_keepalive 404 "service5" - api_get_service_ids 200 "service1" "service2" "service3" + api_get_service_ids 200 "service1" "service2" "service3" "ric-registration" api_delete_services 204 "service1" - api_get_service_ids 200 "service2" "service3" + api_get_service_ids 200 "service2" "service3" "ric-registration" api_put_service 201 "service1" 50 "$CR_PATH/1" - api_get_service_ids 200 "service1" "service2" "service3" + api_get_service_ids 200 "service1" "service2" "service3" "ric-registration" api_delete_services 204 "service1" api_delete_services 204 "service3" - api_equal json:services 1 + api_equal json:services 2 api_delete_services 204 "service2" - api_equal json:services 0 + api_equal json:services 1 echo "############################################" @@ -321,7 +336,7 @@ for __httpx in $TESTED_PROTOCOLS ; do api_put_service 201 "service10" 3600 "$CR_PATH/1" if [ "$PMS_VERSION" == "V2" ]; then - notificationurl="http://localhost:80" + notificationurl=$CR_PATH"/test" else notificationurl="" fi @@ -359,7 +374,7 @@ for __httpx in $TESTED_PROTOCOLS ; do #api_equal json:policy_ids 2 #Allow 3 for now if [ "$PMS_VERSION" == "V2" ]; then - api_equal json:policy_instances 3 + api_equal json:policy-instances 3 else api_equal json:policy_ids 3 fi @@ -419,7 +434,7 @@ for __httpx in $TESTED_PROTOCOLS ; do api_equal json:policies 1 if [ "$PMS_VERSION" == "V2" ]; then - api_equal json:policy_instances 1 + api_equal json:policy-instances 1 else api_equal json:policy_ids 1 fi @@ -429,12 +444,14 @@ for __httpx in $TESTED_PROTOCOLS ; do api_equal json:policies 0 if [ "$PMS_VERSION" == "V2" ]; then - api_equal json:policy_instances 0 + api_equal json:policy-instances 0 else api_equal json:policy_ids 0 fi - cr_equal received_callbacks 0 + if [ "$PMS_VERSION" == "V2" ]; then + cr_equal received_callbacks 3 + fi if [[ $interface = *"DMAAP"* ]]; then mr_greater requests_submitted 0 @@ -465,6 +482,10 @@ for __httpx in $TESTED_PROTOCOLS ; do check_policy_agent_logs check_control_panel_logs + if [[ $interface = *"SDNC"* ]]; then + check_sdnc_logs + fi + store_logs "${__httpx}__${interface}" done diff --git a/test/auto-test/FTC110.sh b/test/auto-test/FTC110.sh index 23f68c7e..8419a5db 100755 --- a/test/auto-test/FTC110.sh +++ b/test/auto-test/FTC110.sh @@ -23,17 +23,16 @@ TC_ONELINE_DESCR="Testing of service registration timeouts and keepalive" #App names to include in the test, space separated list INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM" +#SUPPORTED TEST ENV FILE +SUPPORTED_PROFILES="ONAP-MASTER ONAP-GUILIN" + . ../common/testcase_common.sh $@ . ../common/agent_api_functions.sh . ../common/ricsimulator_api_functions.sh +. ../common/cr_api_functions.sh generate_uuid -#Local vars in test script -########################## -# Path to callback receiver -CR_PATH="http://$CR_APP_NAME:$CR_EXTERNAL_PORT/callbacks" - use_cr_http use_simulator_http use_mr_http @@ -65,8 +64,6 @@ start_policy_agent set_agent_debug -#Verify no callbacks or dmaap messages has been sent -cr_equal received_callbacks 0 mr_equal requests_submitted 0 #Check agent alive @@ -178,7 +175,7 @@ else fi if [ "$PMS_VERSION" == "V2" ]; then - notificationurl="http://localhost:80" + notificationurl=$CR_PATH"/test" else notificationurl="" fi @@ -218,9 +215,6 @@ sim_equal ricsim_g2_1 num_instances 0 api_get_service_ids 200 -deviation "TR18 Agents sends callback with empty body" -deviation "TR18 Unclear when callbacks are sent...." -#cr_equal received_callbacks 8 mr_equal requests_submitted 0 check_policy_agent_logs diff --git a/test/auto-test/FTC150.sh b/test/auto-test/FTC150.sh index 1cd7754d..bd33bee4 100755 --- a/test/auto-test/FTC150.sh +++ b/test/auto-test/FTC150.sh @@ -23,6 +23,9 @@ TC_ONELINE_DESCR="Sample tests of the SDNC A1 controller restconf API using http #App names to include in the test, space separated list INCLUDED_IMAGES="RICSIM SDNC" +#SUPPORTED TEST ENV FILE +SUPPORTED_PROFILES="ONAP-MASTER ONAP-GUILIN" + . ../common/testcase_common.sh $@ . ../common/controller_api_functions.sh . ../common/ricsimulator_api_functions.sh diff --git a/test/auto-test/FTC300.sh b/test/auto-test/FTC300.sh index 6e00c9d9..61ae8d6a 100755 --- a/test/auto-test/FTC300.sh +++ b/test/auto-test/FTC300.sh @@ -22,6 +22,9 @@ TC_ONELINE_DESCR="Resync 10000 policies using OSC and STD interface" #App names to include in the test, space separated list INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM SDNC" +#SUPPORTED TEST ENV FILE +SUPPORTED_PROFILES="ONAP-MASTER ONAP-GUILIN" + . ../common/testcase_common.sh $@ . ../common/agent_api_functions.sh . ../common/ricsimulator_api_functions.sh @@ -44,7 +47,6 @@ for __httpx in $TESTED_PROTOCOLS ; do echo "#####################################################################" if [ $__httpx == "HTTPS" ]; then - CR_PATH="https://$CR_APP_NAME:$CR_EXTERNAL_SECURE_PORT/callbacks" use_cr_https use_simulator_https use_mr_https @@ -57,7 +59,6 @@ for __httpx in $TESTED_PROTOCOLS ; do use_agent_rest_https fi else - CR_PATH="http://$CR_APP_NAME:$CR_EXTERNAL_PORT/callbacks" use_cr_http use_simulator_http use_mr_http @@ -124,10 +125,10 @@ for __httpx in $TESTED_PROTOCOLS ; do api_put_service 201 "serv1" 3600 "$CR_PATH/1" START_ID=2000 - NUM_POLICIES=10000 + NUM_POLICIES=10000 # Must be at least 100 if [ "$PMS_VERSION" == "V2" ]; then - notificationurl="http://localhost:80" + notificationurl=$CR_PATH"/test" else notificationurl="" fi @@ -184,6 +185,9 @@ for __httpx in $TESTED_PROTOCOLS ; do api_equal json:policies $(($NUM_POLICIES-2+$NUM_POLICIES-3)) check_policy_agent_logs + if [[ $interface = *"SDNC"* ]]; then + check_sdnc_logs + fi store_logs "${__httpx}__${interface}" diff --git a/test/auto-test/FTC310.sh b/test/auto-test/FTC310.sh index bf5785ef..3edb0220 100755 --- a/test/auto-test/FTC310.sh +++ b/test/auto-test/FTC310.sh @@ -21,12 +21,15 @@ TC_ONELINE_DESCR="Resync of RIC via changes in the consul config" #App names to include in the test, space separated list -INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM SDNC" +INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM" + +#SUPPORTED TEST ENV FILE +SUPPORTED_PROFILES="ONAP-MASTER ONAP-GUILIN" . ../common/testcase_common.sh $@ . ../common/agent_api_functions.sh . ../common/ricsimulator_api_functions.sh -. ../common/controller_api_functions.sh +. ../common/cr_api_functions.sh #### TEST BEGIN #### @@ -35,6 +38,14 @@ generate_uuid # Clean container and start all needed containers # clean_containers +start_policy_agent + +set_agent_trace + +# Create service to be able to receive events when rics becomes available +# Must use rest towards the agent since dmaap is not configured yet +api_put_service 201 "ric-registration" 0 "$CR_PATH/ric-registration" + # 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 @@ -48,21 +59,22 @@ start_cr start_consul_cbs +start_control_panel + prepare_consul_config NOSDNC ".consul_config.json" consul_config_app ".consul_config.json" -start_control_panel - -start_policy_agent - if [ "$PMS_VERSION" == "V2" ]; then api_equal json:rics 3 120 + + cr_equal received_callbacks 3 120 + + cr_api_check_all_sync_events 200 ric-registration ricsim_g1_1 ricsim_g2_1 ricsim_g3_1 else api_equal json:rics 2 120 fi - # Add an STD RIC and check start_ric_simulators ricsim_g2 2 STD_1.1.3 @@ -72,6 +84,10 @@ consul_config_app ".consul_config.json" if [ "$PMS_VERSION" == "V2" ]; then api_equal json:rics 4 120 + + cr_equal received_callbacks 4 120 + + cr_api_check_all_sync_events 200 ric-registration ricsim_g2_2 else api_equal json:rics 3 120 fi @@ -88,6 +104,8 @@ consul_config_app ".consul_config.json" if [ "$PMS_VERSION" == "V2" ]; then api_equal json:rics 3 120 + + cr_equal received_callbacks 4 120 else api_equal json:rics 2 120 fi diff --git a/test/auto-test/FTC350.sh b/test/auto-test/FTC350.sh index 4f2244c9..8e366763 100755 --- a/test/auto-test/FTC350.sh +++ b/test/auto-test/FTC350.sh @@ -22,18 +22,18 @@ TC_ONELINE_DESCR="Change supported policy types and reconfigure rics" #App names to include in the test, space separated list INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM SDNC" +#SUPPORTED TEST ENV FILE +SUPPORTED_PROFILES="ONAP-MASTER ONAP-GUILIN" + . ../common/testcase_common.sh $@ . ../common/agent_api_functions.sh . ../common/ricsimulator_api_functions.sh +. ../common/cr_api_functions.sh #### TEST BEGIN #### generate_uuid -#Local vars in test script -########################## -# Path to callback receiver -CR_PATH="http://$CR_APP_NAME:$CR_EXTERNAL_PORT/callbacks" use_cr_http NUM_RICS=10 @@ -64,16 +64,14 @@ for interface in $TESTED_VARIANTS ; do start_consul_cbs + # Create first config if [[ $interface = *"SDNC"* ]]; then start_sdnc - prepare_consul_config SDNC ".consul_config_2.json" + prepare_consul_config SDNC ".consul_config_initial.json" else - prepare_consul_config NOSDNC ".consul_config_2.json" + prepare_consul_config NOSDNC ".consul_config_initial.json" fi - consul_config_app ".consul_config_2.json" - - # Create 2nd config and save for later start_ric_simulators ricsim_g1 $NUM_RICS OSC_2.1.0 @@ -85,11 +83,17 @@ for interface in $TESTED_VARIANTS ; do start_policy_agent - set_agent_debug set_agent_trace api_get_status 200 + # Create service to be able to receive events when rics becomes available + # Must use rest towards the agent since dmaap is not configured yet + api_put_service 201 "ric-registration" 0 "$CR_PATH/ric-registration" + + #Load first config + consul_config_app ".consul_config_initial.json" + for ((i=1; i<=${NUM_RICS}; i++)) do sim_print ricsim_g1_$i interface @@ -98,6 +102,11 @@ for interface in $TESTED_VARIANTS ; do # All sims running but 2 are not configured in consul api_equal json:rics 8 120 + if [ "$PMS_VERSION" == "V2" ]; then + cr_equal received_callbacks?id=ric-registration 8 120 + cr_api_check_all_sync_events 200 ric-registration ricsim_g1_1 ricsim_g1_2 ricsim_g1_3 ricsim_g1_4 ricsim_g1_5 ricsim_g1_6 ricsim_g1_7 ricsim_g1_8 + fi + api_get_rics 200 NOTYPE "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:NOTYPE:???? \ ricsim_g1_2:me1_ricsim_g1_2,me2_ricsim_g1_2:NOTYPE:???? \ ricsim_g1_3:me1_ricsim_g1_3,me2_ricsim_g1_3:NOTYPE:???? \ @@ -136,7 +145,6 @@ for interface in $TESTED_VARIANTS ; do sim_put_policy_type 201 ricsim_g1_6 5 testdata/OSC/sim_5.json sim_put_policy_type 201 ricsim_g1_7 5 testdata/OSC/sim_5.json sim_put_policy_type 201 ricsim_g1_8 5 testdata/OSC/sim_5.json - sim_put_policy_type 201 ricsim_g1_9 5 testdata/OSC/sim_5.json if [ "$PMS_VERSION" == "V2" ]; then api_equal json:policy-types 5 120 @@ -173,12 +181,23 @@ for interface in $TESTED_VARIANTS ; do ricsim_g1_7:me1_ricsim_g1_7,me2_ricsim_g1_7:3,4,5:???? \ ricsim_g1_8:me1_ricsim_g1_8,me2_ricsim_g1_8:4,5:???? " + if [ "$PMS_VERSION" == "V2" ]; then + cr_equal received_callbacks?id=ric-registration 16 120 + cr_api_check_all_sync_events 200 ric-registration ricsim_g1_1 ricsim_g1_2 ricsim_g1_3 ricsim_g1_4 ricsim_g1_5 ricsim_g1_6 ricsim_g1_7 ricsim_g1_8 + fi #Load config with all rics consul_config_app ".consul_config_all.json" api_equal json:rics 10 120 + if [ "$PMS_VERSION" == "V2" ]; then + cr_equal received_callbacks?id=ric-registration 18 120 + cr_api_check_all_sync_events 200 ric-registration ricsim_g1_9 ricsim_g1_10 + fi + + sim_put_policy_type 201 ricsim_g1_9 5 testdata/OSC/sim_5.json + if [ "$PMS_VERSION" == "V2" ]; then echo "Check the number of types in the agent for each ric" @@ -218,6 +237,10 @@ for interface in $TESTED_VARIANTS ; do ricsim_g1_9:me1_ricsim_g1_9,me2_ricsim_g1_9:5:???? \ ricsim_g1_10:me1_ricsim_g1_10,me2_ricsim_g1_10:NOTYPE:???? " + if [ "$PMS_VERSION" == "V2" ]; then + cr_equal received_callbacks?id=ric-registration 19 120 + cr_api_check_all_sync_events 200 ric-registration ricsim_g1_9 + fi #No policy type in sim #10 @@ -230,27 +253,21 @@ for interface in $TESTED_VARIANTS ; do api_put_service 201 "serv1" 3600 "$CR_PATH/serv1" if [ "$PMS_VERSION" == "V2" ]; then - notificationurl="http://localhost:80" + notificationurl=$CR_PATH"/test" else notificationurl="" fi - api_put_policy 201 "serv1" ricsim_g1_9 5 2000 NOTRANSIENT $notificationurl testdata/OSC/pi5_template.json 1 - - if [ "$PMS_VERSION" == "V2" ]; then - api_equal json:policy_instances 1 - else - api_equal json:policy_ids 1 - fi - - sim_equal ricsim_g1_9 num_instances 1 - - # Load config with reduced number of rics - consul_config_app ".consul_config_2.json" + consul_config_app ".consul_config_initial.json" api_equal json:rics 8 120 + if [ "$PMS_VERSION" == "V2" ]; then + cr_equal received_callbacks?id=ric-registration 19 120 + cr_api_check_all_sync_events 200 ric-registration EMPTY + fi + if [ "$PMS_VERSION" == "V2" ]; then echo "Check the number of types in the agent for each ric" api_equal json:policy-types?ric_id=ricsim_g1_1 1 120 @@ -285,17 +302,13 @@ for interface in $TESTED_VARIANTS ; do sleep_wait 120 if [ "$PMS_VERSION" == "V2" ]; then - api_equal json:policy_instances 0 + api_equal json:policy-instances 0 else api_equal json:policy_ids 0 fi api_get_policy_types 404 ricsim_g1_9 - sim_equal ricsim_g1_9 num_instances 0 - - api_delete_policy 404 2000 - # Load config with all rics consul_config_app ".consul_config_all.json" @@ -341,7 +354,7 @@ for interface in $TESTED_VARIANTS ; do sleep_wait 120 if [ "$PMS_VERSION" == "V2" ]; then - api_equal json:policy_instances 0 + api_equal json:policy-instances 0 else api_equal json:policy_ids 0 fi @@ -413,14 +426,15 @@ for interface in $TESTED_VARIANTS ; do check_policy_agent_logs + if [[ $interface = *"SDNC"* ]]; then + check_sdnc_logs + fi + store_logs ${interface} done - - - #### TEST COMPLETE #### diff --git a/test/auto-test/FTC800.sh b/test/auto-test/FTC800.sh index 6d25c29b..da802015 100755 --- a/test/auto-test/FTC800.sh +++ b/test/auto-test/FTC800.sh @@ -22,9 +22,13 @@ TC_ONELINE_DESCR="Create 10000 policies in sequence using http/https and Agent R #App names to include in the test, space separated list INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM SDNC" +#SUPPORTED TEST ENV FILE +SUPPORTED_PROFILES="ONAP-MASTER ONAP-GUILIN" + . ../common/testcase_common.sh $@ . ../common/agent_api_functions.sh . ../common/ricsimulator_api_functions.sh +. ../common/cr_api_functions.sh #### TEST BEGIN #### @@ -50,15 +54,11 @@ for __httpx in $TESTED_PROTOCOLS ; do echo "#####################################################################" if [ $__httpx == "HTTPS" ]; then - # Path to callback receiver - CR_PATH="https://$CR_APP_NAME:$CR_EXTERNAL_SECURE_PORT/callbacks" use_cr_https use_simulator_https use_mr_https use_agent_rest_https else - # Path to callback receiver - CR_PATH="http://$CR_APP_NAME:$CR_EXTERNAL_PORT/callbacks" use_cr_http use_simulator_http use_mr_http @@ -97,7 +97,6 @@ for __httpx in $TESTED_PROTOCOLS ; do set_agent_debug - cr_equal received_callbacks 0 mr_equal requests_submitted 0 @@ -117,7 +116,7 @@ for __httpx in $TESTED_PROTOCOLS ; do api_put_service 201 "serv1" 3600 "$CR_PATH/1" if [ "$PMS_VERSION" == "V2" ]; then - notificationurl="http://localhost:80" + notificationurl=$CR_PATH"/test" else notificationurl="" fi @@ -191,6 +190,9 @@ for __httpx in $TESTED_PROTOCOLS ; do fi check_policy_agent_logs + if [[ $interface = *"SDNC"* ]]; then + check_sdnc_logs + fi store_logs "${__httpx}__${interface}" done diff --git a/test/auto-test/FTC810.sh b/test/auto-test/FTC810.sh index 4cc00bd3..911a1ebd 100755 --- a/test/auto-test/FTC810.sh +++ b/test/auto-test/FTC810.sh @@ -22,9 +22,13 @@ TC_ONELINE_DESCR="Repeatedly create and delete policies in each RICs for 24h (or #App names to include in the test, space separated list INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM SDNC" +#SUPPORTED TEST ENV FILE +SUPPORTED_PROFILES="ONAP-MASTER ONAP-GUILIN" + . ../common/testcase_common.sh $@ . ../common/agent_api_functions.sh . ../common/ricsimulator_api_functions.sh +. ../common/cr_api_functions.sh #### TEST BEGIN #### @@ -46,15 +50,11 @@ clean_containers HTTPX=HTTPS if [ $HTTPX == "HTTP" ]; then - # Path to callback receiver - CR_PATH="http://$CR_APP_NAME:$CR_EXTERNAL_PORT/callbacks" use_cr_http use_agent_rest_http use_sdnc_http use_simulator_http else - # Path to callback receiver - CR_PATH="https://$CR_APP_NAME:$CR_EXTERNAL_SECURE_PORT/callbacks" use_cr_https use_agent_rest_https use_sdnc_https @@ -141,7 +141,7 @@ AGENT_INTERFACES="REST REST_PARALLEL DMAAP DMAAP-BATCH" MR_MESSAGES=0 if [ "$PMS_VERSION" == "V2" ]; then - notificationurl="http://localhost:80" + notificationurl=$CR_PATH"/test" else notificationurl="" fi @@ -198,7 +198,7 @@ while [ $(($SECONDS-$TEST_START)) -lt $TEST_DURATION ]; do done if [ "$PMS_VERSION" == "V2" ]; then - api_equal json:policy_instances $INSTANCES + api_equal json:policy-instances $INSTANCES else api_equal json:policy_ids $INSTANCES fi @@ -223,7 +223,7 @@ while [ $(($SECONDS-$TEST_START)) -lt $TEST_DURATION ]; do done if [ "$PMS_VERSION" == "V2" ]; then - api_equal json:policy_instances $INSTANCES + api_equal json:policy-instances $INSTANCES else api_equal json:policy_ids $INSTANCES fi @@ -251,7 +251,7 @@ while [ $(($SECONDS-$TEST_START)) -lt $TEST_DURATION ]; do done if [ "$PMS_VERSION" == "V2" ]; then - api_equal json:policy_instances $INSTANCES + api_equal json:policy-instances $INSTANCES else api_equal json:policy_ids $INSTANCES fi @@ -277,13 +277,11 @@ while [ $(($SECONDS-$TEST_START)) -lt $TEST_DURATION ]; do done if [ "$PMS_VERSION" == "V2" ]; then - api_equal json:policy_instances $INSTANCES + api_equal json:policy-instances $INSTANCES else api_equal json:policy_ids $INSTANCES fi - cr_equal received_callbacks 0 - mr_equal requests_submitted $MR_MESSAGES mr_equal requests_fetched $MR_MESSAGES mr_equal responses_submitted $MR_MESSAGES @@ -303,6 +301,7 @@ while [ $(($SECONDS-$TEST_START)) -lt $TEST_DURATION ]; do done check_policy_agent_logs +check_sdnc_logs #### TEST COMPLETE #### diff --git a/test/auto-test/FTC850.sh b/test/auto-test/FTC850.sh index b6376f06..c6f61d79 100755 --- a/test/auto-test/FTC850.sh +++ b/test/auto-test/FTC850.sh @@ -22,6 +22,9 @@ TC_ONELINE_DESCR="Create/delete policies in parallel over a number of ric using #App names to include in the test, space separated list INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM SDNC" +#SUPPORTED TEST ENV FILE +SUPPORTED_PROFILES="ONAP-MASTER ONAP-GUILIN" + . ../common/testcase_common.sh $@ . ../common/agent_api_functions.sh . ../common/ricsimulator_api_functions.sh @@ -43,7 +46,7 @@ NUM_POLICIES_PER_RIC=500 generate_uuid if [ "$PMS_VERSION" == "V2" ]; then - notificationurl="http://localhost:80" + notificationurl=$CR_PATH"/test" else notificationurl="" fi @@ -58,7 +61,6 @@ for __httpx in $TESTED_PROTOCOLS ; do echo "#####################################################################" if [ $__httpx == "HTTPS" ]; then - CR_PATH="https://$CR_APP_NAME:$CR_EXTERNAL_SECURE_PORT/callbacks" use_cr_https use_simulator_https use_mr_https @@ -67,7 +69,6 @@ for __httpx in $TESTED_PROTOCOLS ; do fi use_agent_rest_https else - CR_PATH="http://$CR_APP_NAME:$CR_EXTERNAL_PORT/callbacks" use_cr_http use_simulator_http use_mr_http @@ -95,6 +96,8 @@ for __httpx in $TESTED_PROTOCOLS ; do start_mr # Not used, but removes error messages from the agent log + start_cr + start_control_panel start_policy_agent @@ -171,6 +174,9 @@ for __httpx in $TESTED_PROTOCOLS ; do done check_policy_agent_logs + if [[ $interface = *"SDNC"* ]]; then + check_sdnc_logs + fi store_logs "${__httpx}__${interface}" diff --git a/test/auto-test/FTC900.sh b/test/auto-test/FTC900.sh index 6dbe5443..e50fcc0c 100755 --- a/test/auto-test/FTC900.sh +++ b/test/auto-test/FTC900.sh @@ -22,18 +22,15 @@ TC_ONELINE_DESCR="Preparation for test of the Control Panel and the Health Check #App names to include in the test, space separated list INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM" +#SUPPORTED TEST ENV FILE +SUPPORTED_PROFILES="ONAP-MASTER ONAP-GUILIN" + . ../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" -use_cr_http - clean_containers OSC_NUM_RICS=6 @@ -124,7 +121,7 @@ use_agent_rest_http api_put_service 201 "Emergency-response-app" 0 "$CR_PATH/1" if [ "$PMS_VERSION" == "V2" ]; then - notificationurl="http://localhost:80" + notificationurl=$CR_PATH"/test" else notificationurl="" fi diff --git a/test/auto-test/PM_DEMO.sh b/test/auto-test/PM_DEMO.sh index c309ddc6..8473a753 100755 --- a/test/auto-test/PM_DEMO.sh +++ b/test/auto-test/PM_DEMO.sh @@ -22,6 +22,9 @@ TC_ONELINE_DESCR="Preparation demo setup - populating a number of ric simulator #App names to include in the test, space separated list INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM SDNC" +#SUPPORTED TEST ENV FILE +SUPPORTED_PROFILES="ONAP-MASTER ONAP-GUILIN" + . ../common/testcase_common.sh $@ . ../common/agent_api_functions.sh . ../common/ricsimulator_api_functions.sh @@ -30,19 +33,16 @@ INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM SDNC" #Local vars in test script ########################## -# Path to callback receiver -CR_PATH="http://$CR_APP_NAME:$CR_EXTERNAL_PORT/callbacks" if [ "$PMS_VERSION" == "V2" ]; then - notificationurl="http://localhost:80" + notificationurl=$CR_PATH"/test" else notificationurl="" fi -use_cr_http -use_agent_rest_http -use_sdnc_http -use_simulator_http +use_agent_rest_https +use_sdnc_https +use_simulator_https clean_containers @@ -53,12 +53,15 @@ start_ric_simulators $RIC_SIM_PREFIX"_g1" $OSC_NUM_RICS OSC_2.1.0 start_ric_simulators $RIC_SIM_PREFIX"_g2" $STD_NUM_RICS STD_1.1.3 +if [ "$PMS_VERSION" == "V2" ]; then + start_ric_simulators $RIC_SIM_PREFIX"_g3" $STD_NUM_RICS STD_2.0.0 +fi + start_mr #Just to prevent errors in the agent log... start_control_panel -CR_PATH="https://$CR_APP_NAME:$CR_EXTERNAL_SECURE_PORT/callbacks" -use_cr_http +start_control_panel start_sdnc @@ -69,6 +72,8 @@ consul_config_app ".consul_config.json" start_policy_agent +set_agent_trace + api_get_status 200 # Print the A1 version for OSC @@ -78,12 +83,20 @@ do done -# Print the A1 version for STD +# Print the A1 version for STD 1.X for ((i=1; i<=$STD_NUM_RICS; i++)) do sim_print $RIC_SIM_PREFIX"_g2_"$i interface done +if [ "$PMS_VERSION" == "V2" ]; then + # Print the A1 version for STD 2.X + for ((i=1; i<=$STD_NUM_RICS; i++)) + do + sim_print $RIC_SIM_PREFIX"_g3_"$i interface + done +fi + # Load the polictypes in osc for ((i=1; i<=$OSC_NUM_RICS; i++)) @@ -95,6 +108,7 @@ done #Check the number of schemas and the individual schemas in OSC if [ "$PMS_VERSION" == "V2" ]; then + api_equal json:policy-types 3 120 for ((i=1; i<=$OSC_NUM_RICS; i++)) @@ -125,6 +139,41 @@ else fi + + +if [ "$PMS_VERSION" == "V2" ]; then + + # Load the polictypes in std + for ((i=1; i<=$STD_NUM_RICS; i++)) + do + sim_put_policy_type 201 $RIC_SIM_PREFIX"_g3_"$i STD_QOS_0_2_0 demo-testdata/STD2/sim_qos.json + sim_put_policy_type 201 $RIC_SIM_PREFIX"_g3_"$i STD_QOS2_0.1.0 demo-testdata/STD2/sim_qos2.json + done + + #Check the number of schemas and the individual schemas in STD + api_equal json:policy-types 5 120 + + for ((i=1; i<=$STD_NUM_RICS; i++)) + do + api_equal json:policy-types?ric_id=$RIC_SIM_PREFIX"_g3_"$i 2 120 + done + + # Check the schemas in STD + for ((i=1; i<=$STD_NUM_RICS; i++)) + do + api_get_policy_type 200 STD_QOS_0_2_0 demo-testdata/STD2/qos-agent-modified.json + api_get_policy_type 200 'STD_QOS2_0.1.0' demo-testdata/STD2/qos2-agent-modified.json + done +fi + +#Check the number of schemas and the individual schemas in OSC +if [ "$PMS_VERSION" == "V2" ]; then + api_equal json:policy-types 5 120 +else + api_equal json:policy_types 3 120 +fi + + # Create policies use_agent_rest_http @@ -152,6 +201,12 @@ for ((i=1; i<=$STD_NUM_RICS; i++)) do generate_uuid api_put_policy 201 "Emergency-response-app" $RIC_SIM_PREFIX"_g2_"$i NOTYPE $((2100+$i)) NOTRANSIENT $notificationurl demo-testdata/STD/pi1_template.json 1 + if [ "$PMS_VERSION" == "V2" ]; then + generate_uuid + api_put_policy 201 "Emergency-response-app" $RIC_SIM_PREFIX"_g3_"$i STD_QOS_0_2_0 $((2300+$i)) NOTRANSIENT $notificationurl demo-testdata/STD2/pi1_template.json 1 + generate_uuid + api_put_policy 201 "Emergency-response-app" $RIC_SIM_PREFIX"_g3_"$i 'STD_QOS2_0.1.0' $((2400+$i)) NOTRANSIENT $notificationurl demo-testdata/STD2/pi1_template.json 1 + fi done @@ -159,9 +214,13 @@ done for ((i=1; i<=$STD_NUM_RICS; i++)) do sim_equal $RIC_SIM_PREFIX"_g2_"$i num_instances 1 + if [ "$PMS_VERSION" == "V2" ]; then + sim_equal $RIC_SIM_PREFIX"_g3_"$i num_instances 2 + fi done check_policy_agent_logs +check_sdnc_logs #### TEST COMPLETE #### diff --git a/test/auto-test/demo-testdata/STD2/pi1_template.json b/test/auto-test/demo-testdata/STD2/pi1_template.json new file mode 100644 index 00000000..e06b0316 --- /dev/null +++ b/test/auto-test/demo-testdata/STD2/pi1_template.json @@ -0,0 +1,9 @@ +{ + "scope": { + "ueId": "ueXXX", + "qosId": "qosXXX" + }, + "qosObjectives": { + "priorityLevel": XXX + } +} \ No newline at end of file diff --git a/test/auto-test/demo-testdata/STD2/qos-agent-modified.json b/test/auto-test/demo-testdata/STD2/qos-agent-modified.json new file mode 100644 index 00000000..3748b790 --- /dev/null +++ b/test/auto-test/demo-testdata/STD2/qos-agent-modified.json @@ -0,0 +1,36 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "description": "STD QOS policy type", + "title": "STD_QOS_0_2_0", + "type": "object", + "properties": { + "qosObjectives": { + "additionalProperties": false, + "type": "object", + "properties": { + "priorityLevel": { + "type": "number" + } + }, + "required": [ + "priorityLevel" + ] + }, + "scope": { + "additionalProperties": false, + "type": "object", + "properties": { + "qosId": { + "type": "string" + }, + "ueId": { + "type": "string" + } + }, + "required": [ + "ueId", + "qosId" + ] + } + } + } \ No newline at end of file diff --git a/test/auto-test/demo-testdata/STD2/qos2-agent-modified.json b/test/auto-test/demo-testdata/STD2/qos2-agent-modified.json new file mode 100644 index 00000000..43b056b5 --- /dev/null +++ b/test/auto-test/demo-testdata/STD2/qos2-agent-modified.json @@ -0,0 +1,36 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "description": "STD QOS2 policy type", + "title": "STD_QOS2_0.1.0", + "type": "object", + "properties": { + "qosObjectives": { + "additionalProperties": false, + "type": "object", + "properties": { + "priorityLevel": { + "type": "number" + } + }, + "required": [ + "priorityLevel" + ] + }, + "scope": { + "additionalProperties": false, + "type": "object", + "properties": { + "qosId": { + "type": "string" + }, + "ueId": { + "type": "string" + } + }, + "required": [ + "ueId", + "qosId" + ] + } + } +} \ No newline at end of file diff --git a/test/auto-test/demo-testdata/STD2/sim_qos.json b/test/auto-test/demo-testdata/STD2/sim_qos.json new file mode 100644 index 00000000..931498c4 --- /dev/null +++ b/test/auto-test/demo-testdata/STD2/sim_qos.json @@ -0,0 +1,56 @@ +{ + "policySchema": { + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "STD_QOS_0_2_0", + "description": "STD QOS policy type", + "type": "object", + "properties": { + "scope": { + "type": "object", + "properties": { + "ueId": { + "type": "string" + }, + "qosId": { + "type": "string" + } + }, + "additionalProperties": false, + "required": [ + "ueId", + "qosId" + ] + }, + "qosObjectives": { + "type": "object", + "properties": { + "priorityLevel": { + "type": "number" + } + }, + "additionalProperties": false, + "required": [ + "priorityLevel" + ] + } + } + }, + "statusSchema": { + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "STD_QOS_0.2.0", + "description": "STD QOS policy type status", + "type": "object", + "properties": { + "enforceStatus": { + "type": "string" + }, + "enforceReason": { + "type": "string" + }, + "additionalProperties": false, + "required": [ + "enforceStatus" + ] + } + } + } \ No newline at end of file diff --git a/test/auto-test/demo-testdata/STD2/sim_qos2.json b/test/auto-test/demo-testdata/STD2/sim_qos2.json new file mode 100644 index 00000000..355ff8b7 --- /dev/null +++ b/test/auto-test/demo-testdata/STD2/sim_qos2.json @@ -0,0 +1,56 @@ +{ + "policySchema": { + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "STD_QOS2_0.1.0", + "description": "STD QOS2 policy type", + "type": "object", + "properties": { + "scope": { + "type": "object", + "properties": { + "ueId": { + "type": "string" + }, + "qosId": { + "type": "string" + } + }, + "additionalProperties": false, + "required": [ + "ueId", + "qosId" + ] + }, + "qosObjectives": { + "type": "object", + "properties": { + "priorityLevel": { + "type": "number" + } + }, + "additionalProperties": false, + "required": [ + "priorityLevel" + ] + } + } + }, + "statusSchema": { + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "STD_QOS_0.2.0", + "description": "STD QOS policy type status", + "type": "object", + "properties": { + "enforceStatus": { + "type": "string" + }, + "enforceReason": { + "type": "string" + }, + "additionalProperties": false, + "required": [ + "enforceStatus" + ] + } + } + } \ No newline at end of file diff --git a/test/common/README.md b/test/common/README.md index 75b16b52..24dfc9dc 100644 --- a/test/common/README.md +++ b/test/common/README.md @@ -16,7 +16,7 @@ The included functions are described in detail further below. Common functions for running two or more auto test scripts as a suite. `api_curl.sh` \ -A common curl based function for the agent and ecs apis. +A common curl based function for the agent and ecs apis. Also partly used for the Callback receiver api. `agent_api_functions.sh` \ Contains functions for adapting towards the Policy Agent API, also via dmaap (using a message-router stub interface) @@ -54,6 +54,8 @@ A python script to extract the information from an sdnc (A1 Controller) reply js `do_curl_function.sh` A script for executing a curl call with a specific url and optional payload. It also compare the response with an expected result in terms of response code and optional returned payload. Intended to be used by test script (for example basic test scripts of other components) +`cr_api_functions.sh` \ +Contains functions for adapting towards the Callback receiver for checking received callback event. # Description of functions in testcase_common.sh # @@ -344,6 +346,12 @@ Start the ECS container. |--| | None | +## Function: restart_ecs ## +Restart the ECS container. +| arg list | +|--| +| None | + ## Function: use_ecs_rest_http ## Use http for all API calls to the ECS. This is the default protocol. | arg list | @@ -415,21 +423,6 @@ Take a snap-shot of all logs for all running containers and stores them in `./lo | `` | Log file prefix | -## Function: cr_equal ## -Tests if a variable value in the Callback Receiver (CR) simulator is equal to a target value. -Without the timeout, the test sets pass or fail immediately depending on if the variable is equal to the target or not. -With the timeout, the test waits up to the timeout seconds before setting pass or fail depending on if the variable value becomes equal to the target value or not. -See the 'cr' dir for more details. -| arg list | -|--| -| ` [ ]` | - -| parameter | description | -| --------- | ----------- | -| `` | Variable name in the CR | -| `` | Target value for the variable | -| `` | Max time to wait for the variable to reach the target value | - ## Function: mr_equal ## Tests if a variable value in the Message Router (MR) simulator is equal to a target value. Without the timeout, the test sets pass or fail immediately depending on if the variable is equal to the target or not. @@ -531,7 +524,7 @@ See the 'cr' dir for more details. | `` | Max time to wait for the length to reach the target value | ## Function: api_get_policies() ## -Test of GET '/policies' or V2 GET '/v2/policy_instances' and optional check of the array of returned policies. +Test of GET '/policies' or V2 GET '/v2/policy-instances' and optional check of the array of returned policies. To test the response code only, provide the response code parameter as well as the following three parameters. To also test the response payload add the 'NOID' for an expected empty array or repeat the last five/seven parameters for each expected policy. @@ -1478,6 +1471,39 @@ With the timeout, the test waits up to the timeout seconds before setting pass o | `` | Target value for the variable | | `` | Max time to wait for the variable to reach the target value | +# Description of functions in cr_api_function.sh # + + + +## Function: cr_equal ## +Tests if a variable value in the Callback Receiver (CR) simulator is equal to a target value. +Without the timeout, the test sets pass or fail immediately depending on if the variable is equal to the target or not. +With the timeout, the test waits up to the timeout seconds before setting pass or fail depending on if the variable value becomes equal to the target value or not. +See the 'cr' dir for more details. +| arg list | +|--| +| ` [ ]` | + +| parameter | description | +| --------- | ----------- | +| `` | Variable name in the CR | +| `` | Target value for the variable | +| `` | Max time to wait for the variable to reach the target value | + +## Function: cr_api_check_all_sync_events() ## +Check the contents of all ric events received for a callback id. + +| arg list | +|--| +| ` [ EMPTY | ( )+ ]` | + +| parameter | description | +| --------- | ----------- | +| `` | Expected http response code | +| `` | Id of the callback destination | +| `EMPTY` | Indicator for an empty list | +| `` | Id of the ric | + ## License diff --git a/test/common/agent_api_functions.sh b/test/common/agent_api_functions.sh index 507e011d..5f5a2c69 100644 --- a/test/common/agent_api_functions.sh +++ b/test/common/agent_api_functions.sh @@ -49,7 +49,7 @@ api_equal() { return 1 } -# API Test function: GET /policies and V2 GET /v2/policy_instances +# API Test function: GET /policies and V2 GET /v2/policy-instances # args: |NORIC |NOSERVICE |NOTYPE [ NOID | [ EMPTY| ]*] # args(V2): |NORIC |NOSERVICE |NOTYPE [ NOID | [ EMPTY| ]*] # (Function for test scripts) @@ -110,7 +110,7 @@ api_get_policies() { fi fi - query="/v2/policy_instances"$queryparams + query="/v2/policy-instances"$queryparams res="$(__do_curl_to_api PA GET $query)" status=${res:${#res}-3} @@ -134,7 +134,7 @@ api_get_policies() { if [ "$targetJson" != "[" ]; then targetJson=$targetJson"," fi - targetJson=$targetJson"{\"policy_id\":\"$UUID${arr[$i]}\",\"ric_id\":\"${arr[$i+1]}\",\"service_id\":\"${arr[$i+2]}\",\"policy_type_id\":" + targetJson=$targetJson"{\"policy_id\":\"$UUID${arr[$i]}\",\"ric_id\":\"${arr[$i+1]}\",\"service_id\":\"${arr[$i+2]}\",\"policytype_id\":" if [ "${arr[$i+3]}" == "EMPTY" ]; then targetJson=$targetJson"\"\"," else @@ -282,9 +282,9 @@ api_get_policy() { targetJson=$targetJson", \"transient\":$7" fi if [ $6 != "NOTYPE" ]; then - targetJson=$targetJson", \"policy_type_id\":\"$6\"" + targetJson=$targetJson", \"policytype_id\":\"$6\"" else - targetJson=$targetJson", \"policy_type_id\":\"\"" + targetJson=$targetJson", \"policytype_id\":\"\"" fi if [ $8 != "NOURL" ]; then targetJson=$targetJson", \"status_notification_uri\":\"$8\"" @@ -378,9 +378,9 @@ api_put_policy() { inputJson=$inputJson", \"transient\":$trans" fi if [ $pt != "NOTYPE" ]; then - inputJson=$inputJson", \"policy_type_id\":$pt" + inputJson=$inputJson", \"policytype_id\":\"$pt\"" else - inputJson=$inputJson", \"policy_type_id\":\"\"" + inputJson=$inputJson", \"policytype_id\":\"\"" fi if [ $noti != "NOURL" ]; then inputJson=$inputJson", \"status_notification_uri\":\"$noti\"" @@ -478,9 +478,9 @@ api_put_policy_batch() { inputJson=$inputJson", \"transient\":$trans" fi if [ $pt != "NOTYPE" ]; then - inputJson=$inputJson", \"policy_type_id\":$pt" + inputJson=$inputJson", \"policytype_id\":\"$pt\"" else - inputJson=$inputJson", \"policy_type_id\":\"\"" + inputJson=$inputJson", \"policytype_id\":\"\"" fi if [ $noti != "NOURL" ]; then inputJson=$inputJson", \"status_notification_uri\":\"$noti\"" @@ -640,7 +640,7 @@ api_put_policy_parallel() { else res=${tmp:0:1} if [ $res == "0" ]; then - echo " Process $i : OK" + echo " Process $i : OK - "${tmp:1} else echo " Process $i : failed - "${tmp:1} msg="failed" @@ -841,7 +841,7 @@ api_delete_policy_parallel() { else res=${tmp:0:1} if [ $res == "0" ]; then - echo " Process $i : OK" + echo " Process $i : OK - "${tmp:1} else echo " Process $i : failed - "${tmp:1} msg="failed" @@ -1264,7 +1264,7 @@ api_get_policy_types() { targetJson=$targetJson"]" if [ "$PMS_VERSION" == "V2" ]; then - targetJson="{\"policy_type_ids\": $targetJson }" + targetJson="{\"policytype_ids\": $targetJson }" fi echo "TARGET JSON: $targetJson" >> $HTTPLOG res=$(python3 ../common/compare_json.py "$targetJson" "$body") diff --git a/test/common/api_curl.sh b/test/common/api_curl.sh index 2aff131f..611fc4dc 100644 --- a/test/common/api_curl.sh +++ b/test/common/api_curl.sh @@ -40,6 +40,11 @@ __do_curl_to_api() { __RESTBASE=$ECS_RESTBASE __RESTBASE_SECURE=$ECS_RESTBASE_SECURE __RETRY_CODES=$ECS_RETRY_CODES + elif [ $1 == "CR" ]; then + __ADAPTER=$CR_ADAPTER + __RESTBASE=$CR_RESTBASE + __RESTBASE_SECURE=$CR_RESTBASE_SECURE + __RETRY_CODES="" else paramError=1 fi @@ -97,7 +102,7 @@ __do_curl_to_api() { if [ $paramError -eq 1 ]; then ((RES_CONF_FAIL++)) - echo "-Incorrect number of parameters to __do_curl_agent " $@ >> $HTTPLOG + echo "-Incorrect number of parameters to __do_curl_to_api " $@ >> $HTTPLOG echo "-Expected: (PA|ECS GET|PUT|POST|DELETE|GET_BATCH|PUT_BATCH|POST_BATCH|DELETE_BATCH []) | (PA|ECS RESPONSE )" >> $HTTPLOG echo "-Returning response 000" >> $HTTPLOG echo "-000" @@ -150,6 +155,8 @@ __do_curl_to_api() { payload="$(cat $4 | tr -d '\n' | tr -d ' ' )" echo "payload: "$payload >> $HTTPLOG file=" --data-binary "$payload + elif [ $# -eq 4 ]; then + echo " FILE: $(cat $4)" >> $HTTPLOG 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]))" "$3") diff --git a/test/common/create_policies_process.py b/test/common/create_policies_process.py index d1bfd6f4..89bfde8c 100644 --- a/test/common/create_policies_process.py +++ b/test/common/create_policies_process.py @@ -24,6 +24,7 @@ import json import sys import requests import traceback +from time import sleep # disable warning about unverified https requests from requests.packages import urllib3 @@ -79,52 +80,68 @@ try: start=start stop=count*num_rics+start + total_retry_count=0 + for i in range(start,stop): if (i%pids == (pid_id-1)): payload=template.replace("XXX",str(i)) ric_id=(i%num_rics)+1 ric=ric_base+str(ric_id) - try: - headers = {'Content-type': 'application/json'} - if ("/v2/" in baseurl): - url=baseurl - - data={} - data["ric_id"]=ric - data["policy_id"]=uuid+str(i) - data["service_id"]=serv - if (trans != "NOTRANSIENT"): - data["transient"]=trans - if (pt != "NOTYPE"): - data["policy_type_id"]=pt + retry_cnt=5 + while(retry_cnt>0): + try: + headers = {'Content-type': 'application/json'} + if ("/v2/" in baseurl): + url=baseurl + + data={} + data["ric_id"]=ric + data["policy_id"]=uuid+str(i) + data["service_id"]=serv + if (trans != "NOTRANSIENT"): + data["transient"]=trans + if (pt != "NOTYPE"): + data["policytype_id"]=pt + else: + data["policytype_id"]="" + if (noti != "NOURL"): + data["status_notification_uri"]=noti + data["policy_data"]=json.loads(payload) + + url_out=url + data_out=json.dumps(data) else: - data["policy_type_id"]="" - if (noti != "NOURL"): - data["status_notification_uri"]=noti - data["policy_data"]=json.loads(payload) + url=baseurl+"&id="+uuid+str(i)+"&ric="+str(ric) + url_out=url + data_out=json.dumps(json.loads(payload)) - url_out=url - data_out=json.dumps(data) resp=requests.put(url, data_out, headers=headers, verify=False, timeout=90) + except Exception as e1: + print("1Put failed for id:"+uuid+str(i)+ ", "+str(e1) + " "+traceback.format_exc()) + sys.exit() + + if (resp.status_code == None): + print("1Put failed for id:"+uuid+str(i)+ ", expected response code: "+str(responsecode)+", got: None") + sys.exit() + + if (resp.status_code != responsecode): + if (resp.status_code == 503 ) and (retry_cnt > 1): + sleep(0.1) + retry_cnt -= 1 + total_retry_count += 1 + else: + print("1Put failed for id:"+uuid+str(i)+ ", expected response code: "+str(responsecode)+", got: "+str(resp.status_code)) + print(url_out) + print(str(data_out)) + sys.exit() else: - url=baseurl+"&id="+uuid+str(i)+"&ric="+str(ric) - url_out=url - data_out=json.dumps(json.loads(payload)) - resp=requests.put(url, data_out, headers=headers, verify=False, timeout=90) - except Exception as e1: - print("1Put failed for id:"+uuid+str(i)+ ", "+str(e1) + " "+traceback.format_exc()) - sys.exit() - if (resp.status_code == None): - print("1Put failed for id:"+uuid+str(i)+ ", expected response code: "+str(responsecode)+", got: None") - sys.exit() - if (resp.status_code != responsecode): - print("1Put failed for id:"+uuid+str(i)+ ", expected response code: "+str(responsecode)+", got: "+str(resp.status_code)) - print(url_out) - print(str(data_out)) - sys.exit() - - print("0") + retry_cnt=-1 + + if (total_retry_count > 0): + print("0 retries:"+str(total_retry_count)) + else: + print("0") sys.exit() except Exception as e: diff --git a/test/common/create_rics_json.py b/test/common/create_rics_json.py index b2ad5288..5f2fe697 100644 --- a/test/common/create_rics_json.py +++ b/test/common/create_rics_json.py @@ -40,7 +40,7 @@ try: if (api_version == "V2"): param_ric='ric_id' param_me='managed_element_ids' - param_policy_type='policy_type_ids' + param_policy_type='policytype_ids' param_state='state' else: param_ric='ricName' diff --git a/test/common/delete_policies_process.py b/test/common/delete_policies_process.py index cf293c83..febb3cc0 100644 --- a/test/common/delete_policies_process.py +++ b/test/common/delete_policies_process.py @@ -49,26 +49,40 @@ try: if uuid == "NOUUID": uuid="" + total_retry_count=0 + stop=count*num_rics+start for i in range(start,stop): if (i%pids == (pid_id-1)): - if ("/v2/policies/" in baseurl): - url=str(baseurl+uuid+str(i)) - else: - url=str(baseurl+"?id="+uuid+str(i)) - try: - resp=requests.delete(url, verify=False, timeout=90) - except Exception as e1: - print("1Delete failed for id:"+uuid+str(i)+ ", "+str(e1) + " "+traceback.format_exc()) - sys.exit() - if (resp.status_code == None): - print("1Delete failed for id:"+uuid+str(i)+ ", expected response code: "+str(responsecode)+", got: None") - sys.exit() - if (resp.status_code != responsecode): - print("1Delete failed for id:"+uuid+str(i)+ ", expected response code: "+str(responsecode)+", got: "+str(resp.status_code)) - sys.exit() + retry_cnt=5 + while(retry_cnt>0): + if ("/v2/policies/" in baseurl): + url=str(baseurl+uuid+str(i)) + else: + url=str(baseurl+"?id="+uuid+str(i)) + try: + resp=requests.delete(url, verify=False, timeout=90) + except Exception as e1: + print("1Delete failed for id:"+uuid+str(i)+ ", "+str(e1) + " "+traceback.format_exc()) + sys.exit() + if (resp.status_code == None): + print("1Delete failed for id:"+uuid+str(i)+ ", expected response code: "+str(responsecode)+", got: None") + sys.exit() + if (resp.status_code != responsecode): + if (resp.status_code == 503 ) and (retry_cnt > 1): + sleep(0.1) + retry_cnt -= 1 + total_retry_count += 1 + else: + print("1Delete failed for id:"+uuid+str(i)+ ", expected response code: "+str(responsecode)+", got: "+str(resp.status_code)) + sys.exit() + else: + retry_cnt=-1 - print("0") + if (total_retry_count > 0): + print("0 retries:"+str(total_retry_count)) + else: + print("0") sys.exit() except Exception as e: diff --git a/test/common/ricsimulator_api_functions.sh b/test/common/ricsimulator_api_functions.sh index 67a398e1..56f968ee 100644 --- a/test/common/ricsimulator_api_functions.sh +++ b/test/common/ricsimulator_api_functions.sh @@ -30,6 +30,7 @@ __execute_curl_to_sim() { echo " RESP: $res" >> $HTTPLOG retcode=$? if [ $retcode -ne 0 ]; then + ((RES_CONF_FAIL++)) echo " RETCODE: "$retcode echo -e $RED" FAIL - fatal error when executing curl."$ERED return 1 @@ -40,6 +41,7 @@ __execute_curl_to_sim() { return 0 fi echo -e $RED" FAIL - expected http response: "$1" but got http response: "$status $ERED + ((RES_CONF_FAIL++)) return 1 } @@ -119,7 +121,7 @@ sim_put_policy_type() { return $? } -# DSimulator API: Delete a policy type in a ric +# Simulator API: Delete a policy type in a ric # # (Function for test scripts) sim_delete_policy_type() { diff --git a/test/common/test_env-onap-guilin.sh b/test/common/test_env-onap-guilin.sh index f92bf799..51eab698 100644 --- a/test/common/test_env-onap-guilin.sh +++ b/test/common/test_env-onap-guilin.sh @@ -17,6 +17,8 @@ # ============LICENSE_END================================================= # +TEST_ENV_PROFILE="ONAP-GUILIN" + # Set up the image and tags for the test. Do not add the image tag to the image names. # NOTE: A env var for each container is created by the test script. diff --git a/test/common/test_env-onap-master.sh b/test/common/test_env-onap-master.sh index da6906dc..f97309c2 100644 --- a/test/common/test_env-onap-master.sh +++ b/test/common/test_env-onap-master.sh @@ -17,6 +17,8 @@ # ============LICENSE_END================================================= # +TEST_ENV_PROFILE="ONAP-MASTER" + # Set up the image and tags for the test. Do not add the image tag to the image names. # NOTE: A env var for each container is created by the test script. @@ -112,6 +114,8 @@ export ECS_INTERNAL_SECURE_PORT=8434 # ECS container export ECS_APP_NAME="ecs" # Name for ECS container ECS_LOGPATH="/var/log/enrichment-coordinator-service/application.log" # Path the application log in the ECS container export ECS_APP_NAME_ALIAS="enrichment-service-container" # Alias name, name used by the control panel +export ECS_HOST_MNT_DIR="./mnt" # Mounted dir, relative to compose file, on the host +export ECS_CONTAINER_MNT_DIR="/var/enrichment-coordinator-service" # Mounted dir in the container export MR_EXTERNAL_PORT=3905 # MR stub container external port (host -> container) export MR_INTERNAL_PORT=3905 # MR stub container internal port (container -> container) @@ -126,6 +130,7 @@ export CR_INTERNAL_PORT=8090 # Callback recei export CR_EXTERNAL_SECURE_PORT=8091 # Callback receiver container external secure port (host -> container) export CR_INTERNAL_SECURE_PORT=8091 # Callback receiver container internal secure port (container -> container) export CR_APP_NAME="callback-receiver" # Name for the Callback receiver +export CR_APP_CALLBACK="/callbacks" # Url for callbacks export PROD_STUB_EXTERNAL_PORT=8092 # Producer stub container external port (host -> container) export PROD_STUB_INTERNAL_PORT=8092 # Producer stub container internal port (container -> container) @@ -187,4 +192,9 @@ ECS_RESTBASE_SECURE="https://localhost:"$ECS_EXTERNAL_SECURE_PORT # Base url to ECS_DMAAPBASE="http://localhost:"$MR_EXTERNAL_PORT # Base url to the Dmaap adapter, http ECS_DMAAPBASE_SECURE="https://localhost:"$MR_EXTERNAL_SECURE_PORT # Base url to the Dmaap adapter, https ECS_ADAPTER=$ECS_RESTBASE # Adapter holds the address the ECS R-APP interface (REST OR DMAAP) - # The values of this var is swiched between the four base url when needed \ No newline at end of file + # The values of this var is swiched between the four base url when needed + +CR_RESTBASE="http://localhost:"$CR_EXTERNAL_PORT # Base url to the Callback receiver REST interface +CR_RESTBASE_SECURE="https://localhost:"$CR_EXTERNAL_SECURE_PORT # Base url to the secure Callback receiver REST interface +CR_ADAPTER=$CR_RESTBASE # Adapter holds the address the CR admin interface (REST only) + # The values of this var is swiched between the two base url when needed \ No newline at end of file diff --git a/test/common/test_env-oran-master.sh b/test/common/test_env-oran-master.sh index 7b8e8f8c..0077ef09 100755 --- a/test/common/test_env-oran-master.sh +++ b/test/common/test_env-oran-master.sh @@ -17,6 +17,8 @@ # ============LICENSE_END================================================= # +TEST_ENV_PROFILE="ORAN-MASTER" + # Set up the image and tags for the test. Do not add the image tag to the image names. # NOTE: A env var for each container is created by the test script. @@ -115,6 +117,8 @@ export ECS_INTERNAL_SECURE_PORT=8434 # ECS container export ECS_APP_NAME="ecs" # Name for ECS container ECS_LOGPATH="/var/log/enrichment-coordinator-service/application.log" # Path the application log in the ECS container export ECS_APP_NAME_ALIAS="enrichment-service-container" # Alias name, name used by the control panel +export ECS_HOST_MNT_DIR="./mnt" # Mounted dir, relative to compose file, on the host +export ECS_CONTAINER_MNT_DIR="/var/enrichment-coordinator-service" # Mounted dir in the container export MR_EXTERNAL_PORT=3905 # MR stub container external port (host -> container) export MR_INTERNAL_PORT=3905 # MR stub container internal port (container -> container) @@ -129,6 +133,7 @@ export CR_INTERNAL_PORT=8090 # Callback recei export CR_EXTERNAL_SECURE_PORT=8091 # Callback receiver container external secure port (host -> container) export CR_INTERNAL_SECURE_PORT=8091 # Callback receiver container internal secure port (container -> container) export CR_APP_NAME="callback-receiver" # Name for the Callback receiver +export CR_APP_CALLBACK="/callbacks" # Url for callbacks export PROD_STUB_EXTERNAL_PORT=8092 # Producer stub container external port (host -> container) export PROD_STUB_INTERNAL_PORT=8092 # Producer stub container internal port (container -> container) @@ -188,4 +193,9 @@ ECS_RESTBASE_SECURE="https://localhost:"$ECS_EXTERNAL_SECURE_PORT # Base url to ECS_DMAAPBASE="http://localhost:"$MR_EXTERNAL_PORT # Base url to the Dmaap adapter, http ECS_DMAAPBASE_SECURE="https://localhost:"$MR_EXTERNAL_SECURE_PORT # Base url to the Dmaap adapter, https ECS_ADAPTER=$ECS_RESTBASE # Adapter holds the address the ECS R-APP interface (REST OR DMAAP) - # The values of this var is swiched between the four base url when needed \ No newline at end of file + # The values of this var is swiched between the four base url when needed + +CR_RESTBASE="http://localhost:"$CR_EXTERNAL_PORT # Base url to the Callback receiver REST interface +CR_RESTBASE_SECURE="https://localhost:"$CR_EXTERNAL_SECURE_PORT # Base url to the secure Callback receiver REST interface +CR_ADAPTER=$CR_RESTBASE # Adapter holds the address the CR admin interface (REST only) + # The values of this var is swiched between the two base url when needed \ No newline at end of file diff --git a/test/common/testcase_common.sh b/test/common/testcase_common.sh index ea940a18..0afc2bcd 100755 --- a/test/common/testcase_common.sh +++ b/test/common/testcase_common.sh @@ -128,6 +128,17 @@ echo "" > $HTTPLOG # Create a log dir for the test case mkdir -p $TESTLOGS/$ATC +# Save create for current logs +mkdir -p $TESTLOGS/$ATC/previous + +rm $TESTLOGS/$ATC/previous/*.log &> /dev/null +rm $TESTLOGS/$ATC/previous/*.txt &> /dev/null +rm $TESTLOGS/$ATC/previous/*.json &> /dev/null + +mv $TESTLOGS/$ATC/*.log $TESTLOGS/$ATC/previous &> /dev/null +mv $TESTLOGS/$ATC/*.txt $TESTLOGS/$ATC/previous &> /dev/null +mv $TESTLOGS/$ATC/*.txt $TESTLOGS/$ATC/previous &> /dev/null + # Clear the log dir for the test case rm $TESTLOGS/$ATC/*.log &> /dev/null rm $TESTLOGS/$ATC/*.txt &> /dev/null @@ -257,6 +268,18 @@ fi if [ -f "$TEST_ENV_VAR_FILE" ]; then echo -e $BOLD"Sourcing env vars from: "$TEST_ENV_VAR_FILE$EBOLD . $TEST_ENV_VAR_FILE + + if [ -z "$TEST_ENV_PROFILE" ] || [ -z "$SUPPORTED_PROFILES" ]; then + echo -e $YELLOW"This test case may no work with selected test env file. TEST_ENV_PROFILE is missing in test_env file or SUPPORTED_PROFILES is missing in test case file"$EYELLOW + else + if [[ "$SUPPORTED_PROFILES" == *"$TEST_ENV_PROFILE"* ]]; then + echo -e $GREEN"Test case support the selected test env file"$EGREEN + else + echo -e $RED"Test case does not support the selected test env file"$ERED + echo -e $RED"Exiting...."$ERED + exit 1 + fi + fi else echo -e $RED"Selected env var file does not exist: "$TEST_ENV_VAR_FILE$ERED echo " Select one of following env var file matching the intended target of the test" @@ -290,6 +313,7 @@ export MR_LOCAL_PORT=$MR_EXTERNAL_PORT #When agent is running outside the docker export CR_HTTPX="http" export CR_PORT=$CR_INTERNAL_PORT export CR_LOCAL_PORT=$CR_EXTERNAL_PORT #When CR is running outside the docker net +export CR_PATH="$CR_HTTPX://$CR_APP_NAME:$CR_PORT$CR_APP_CALLBACK" export PROD_STUB_HTTPX="http" export PROD_STUB_PORT=$PROD_STUB_INTERNAL_PORT @@ -1154,7 +1178,8 @@ __check_container_start() { ((RES_CONF_FAIL++)) echo "" echo -e $RED" Container $BOLD${appname}$EBOLD could not be started"$ERED - return 1 + echo -e $RED" Stopping script..."$ERED + exit 1 fi if [ $localport -eq 0 ]; then while [ $localport -eq 0 ]; do @@ -1189,7 +1214,7 @@ __check_container_start() { else TS_TMP=$SECONDS while [ $(($TS_TMP+$i)) -gt $SECONDS ]; do - echo -ne " Waiting for container ${appname} service status...retrying in $(($TS_TMP+$i-$SECONDS)) seconds ${SAMELINE}" + echo -ne " Waiting for container ${appname} service status...$(($SECONDS-$TSTART)) seconds, retrying in $(($TS_TMP+$i-$SECONDS)) seconds ${SAMELINE}" sleep 1 done fi @@ -1197,7 +1222,7 @@ __check_container_start() { if [ "$pa_st" = "false" ]; then ((RES_CONF_FAIL++)) - echo -e $RED" Container ${appname} did not respond to service status"$ERED + echo -e $RED" Container ${appname} did not respond to service status in $(($SECONDS-$TSTART)) seconds"$ERED return 0 fi @@ -1228,6 +1253,8 @@ __start_container() { if [ $? -ne 0 ]; then echo -e $RED"Problem to launch container(s) with docker-compose"$ERED cat .dockererr + echo -e $RED"Stopping script...."$ERED + exit 1 fi elif [ "$2" == "STANDALONE" ]; then echo "Skipping docker-compose" @@ -1236,6 +1263,8 @@ __start_container() { if [ $? -ne 0 ]; then echo -e $RED"Problem to launch container(s) with docker-compose"$ERED cat .dockererr + echo -e $RED"Stopping script...."$ERED + exit 1 fi fi app_prefix="" @@ -1652,6 +1681,7 @@ use_cr_http() { export CR_HTTPX="http" export CR_PORT=$CR_INTERNAL_PORT export CR_LOCAL_PORT=$CR_EXTERNAL_PORT + export CR_PATH="$CR_HTTPX://$CR_APP_NAME:$CR_PORT$CR_APP_CALLBACK" echo "" } @@ -1660,6 +1690,7 @@ use_cr_https() { export CR_HTTPX="https" export CR_PORT=$CR_INTERNAL_SECURE_PORT export CR_LOCAL_PORT=$CR_EXTERNAL_SECURE_PORT + export CR_PATH="$CR_HTTPX://$CR_APP_NAME:$CR_PORT$CR_APP_CALLBACK" echo "" } @@ -1771,7 +1802,7 @@ use_agent_dmaap_http() { # args: - # (Function for test scripts) use_agent_dmaap_https() { - echo -e "Using $BOLD https $EBOLD and $BOLD REST $EBOLD towards the agent" + echo -e "Using $BOLD https $EBOLD and $BOLD DMAAP $EBOLD towards the agent" export ADAPTER=$DMAAPBASE_SECURE echo "" return 0 @@ -1847,6 +1878,23 @@ start_ecs() { __start_container ecs NODOCKERARGS $ECS_APP_NAME $ECS_EXTERNAL_PORT "/status" "http" } +# Restart ECS +# args: - +# (Function for test scripts) +restart_ecs() { + docker restart $ECS_APP_NAME &> ./tmp/.dockererr + if [ $? -ne 0 ]; then + __print_err "Could restart $ECS_APP_NAME" $@ + cat ./tmp/.dockererr + ((RES_CONF_FAIL++)) + return 1 + fi + + __check_container_start $ECS_APP_NAME $ECS_EXTERNAL_PORT "/status" "http" + echo "" + return 0 +} + # All calls to ECS will be directed to the ECS REST interface from now on # args: - # (Function for test scripts) @@ -2000,7 +2048,7 @@ store_logs() { __print_err "need one arg, " $@ exit 1 fi - echo -e $BOLD"Storing all container logs using prefix: "$1$EBOLD + echo -e $BOLD"Storing all container logs in $TESTLOGS/$ATC using prefix: "$1$EBOLD docker stats --no-stream > $TESTLOGS/$ATC/$1_docker_stats.log 2>&1 @@ -2226,22 +2274,6 @@ __var_test() { ### Generic test cases for varaible checking -# Tests if a variable value in the CR is equal to a target value and and optional timeout. -# Arg: - This test set pass or fail depending on if the variable is -# equal to the target or not. -# Arg: - This test waits up to the timeout seconds -# before setting pass or fail depending on if the variable value becomes equal to the target -# value or not. -# (Function for test scripts) -cr_equal() { - if [ $# -eq 2 ] || [ $# -eq 3 ]; then - __var_test "CR" "$LOCALHOST$CR_EXTERNAL_PORT/counter/" $1 "=" $2 $3 - else - ((RES_CONF_FAIL++)) - __print_err "Wrong args to cr_equal, needs two or three args: [ timeout ]" $@ - fi -} - # Tests if a variable value in the MR stub is equal to a target value and and optional timeout. # Arg: - This test set pass or fail depending on if the variable is # equal to the target or not. diff --git a/test/cr/Dockerfile b/test/cr/Dockerfile index bdc3521d..8349554b 100644 --- a/test/cr/Dockerfile +++ b/test/cr/Dockerfile @@ -17,6 +17,10 @@ FROM python:3.8-slim-buster +#install nginx +RUN apt-get update +RUN apt-get install -y nginx=1.14.* + COPY app/ /usr/src/app/ COPY cert/ /usr/src/app/cert/ @@ -26,8 +30,4 @@ RUN pip install -r requirements.txt RUN chmod +x start.sh -#install nginx -RUN apt-get update -RUN apt-get install -y nginx=1.14.* - CMD [ "./start.sh" ] diff --git a/test/cr/README.md b/test/cr/README.md index 251f0b31..becace1a 100644 --- a/test/cr/README.md +++ b/test/cr/README.md @@ -2,7 +2,7 @@ The callback receiver is intended for function tests to simulate a RAPP. The callback receiver exposes the read and write urls, used by the agent, as configured in service. -The callback receiver receives notifications from PMS when synchronization happens between PMS and RICs. +The callback receiver receives notifications from PMS when synchronization happens between PMS and RICs. However, the callback receiver can be uses to receive any json payload from any source. # Ports and certificates @@ -24,14 +24,30 @@ The following REST operations are available: >Send a message to CR
This method puts a request message from PMS to notify that sychronization between PMS and certain RIC happens.
-```URI and payload, (PUT or POST): /callbacks/ ```

+```URI and payload, (PUT or POST): /callbacks/ ```
```response: OK 200 or 500 for other errors``` +>Fetch one message for an id from CR
+This method fetches the oldes message for an id, and removes the message.
+```URI and payload, (GET): /get-event/```
+```response: 200 or 500 for other errors``` + +>Fetch all messages for an id from CR
+This method fetches all message in an array for an id, and removes all messages.
+```URI and payload, (GET): /get-all-events/```
+```response: 200 or 500 for other errors``` + +>Dump all currently wating callback messages in CR
+This method fetches all message in an array for an id. Messages are left intact in the CR.
+```URI and payload, (GET): /db```
+```response: 200``` + >Metrics - counters
There are a number of counters that can be read to monitor the message processing. Do a http GET on any of the current counters and an integer value will be returned with http response code 200. ```/counter/received_callbacks``` - The total number of received callbacks
```/counter/fetched_callbacks``` - The total number of fetched callbacks
```/counter/current_messages``` - The current number of callback messages waiting to be fetched
+All counters also support the query parameter "id" to fetch counter for one individual id, eg ```/counter/current_messages?id=my-id``` ### Build and start ### diff --git a/test/cr/app/cr.py b/test/cr/app/cr.py index bc6e28f9..fe0fbe4e 100644 --- a/test/cr/app/cr.py +++ b/test/cr/app/cr.py @@ -16,13 +16,11 @@ # ============LICENSE_END================================================= # -from flask import Flask, request +from flask import Flask, request, Response from time import sleep import time import datetime import json -from flask import Flask -from flask import Response import traceback app = Flask(__name__) @@ -37,10 +35,13 @@ HOST_PORT = 2222 # Metrics vars cntr_msg_callbacks=0 cntr_msg_fetched=0 +cntr_callbacks={} # Request and response constants CALLBACK_URL="/callbacks/" APP_READ_URL="/get-event/" +APP_READ_ALL_URL="/get-all-events/" +DUMP_ALL_URL="/db" MIME_TEXT="text/plain" MIME_JSON="application/json" @@ -57,7 +58,7 @@ def index(): # Fetch the oldest callback message for an id # URI and parameter, (GET): /get-event/ -# response: message + 200 or 204 +# response: message + 200 or just 204 or just 500(error) @app.route(APP_READ_URL, methods=['GET']) def receiveresponse(id): @@ -67,19 +68,47 @@ def receiveresponse(id): try: if ((id in msg_callbacks.keys()) and (len(msg_callbacks[id]) > 0)): cntr_msg_fetched+=1 - msg=str(msg_callbacks[id][0]) - print("Fetching msg for id: "+id+", msg="+msg) + cntr_callbacks[id][1]+=1 + msg=msg_callbacks[id][0] + print("Fetching msg for id: "+id+", msg="+str(msg)) del msg_callbacks[id][0] - return msg,200 + return json.dumps(msg),200 print("No messages for id: "+id) except Exception as e: print(CAUGHT_EXCEPTION+str(e)) + traceback.print_exc() + return "",500 return "",204 +# Fetch all callback message for an id in an array +# URI and parameter, (GET): /get-all-events/ +# response: message + 200 or just 500(error) +@app.route(APP_READ_ALL_URL, + methods=['GET']) +def receiveresponse_all(id): + global msg_callbacks + global cntr_msg_fetched + + try: + if ((id in msg_callbacks.keys()) and (len(msg_callbacks[id]) > 0)): + cntr_msg_fetched+=len(msg_callbacks[id]) + cntr_callbacks[id][1]+=len(msg_callbacks[id]) + msg=msg_callbacks[id] + print("Fetching all msgs for id: "+id+", msg="+str(msg)) + del msg_callbacks[id] + return json.dumps(msg),200 + print("No messages for id: "+id) + except Exception as e: + print(CAUGHT_EXCEPTION+str(e)) + traceback.print_exc() + return "",500 + + msg=[] + return json.dumps(msg),200 # Receive a callback message -# URI and payload, (PUT or POST): /callbacks/ +# URI and payload, (PUT or POST): /callbacks/ # response: OK 200 or 500 for other errors @app.route(CALLBACK_URL, methods=['PUT','POST']) @@ -91,17 +120,16 @@ def events_write(id): print("Received callback for id: "+id +", content-type="+request.content_type) try: if (request.content_type == MIME_JSON): - msg = request.json + data = request.data + msg = json.loads(data) print("Payload(json): "+str(msg)) - elif (request.content_type == MIME_TEXT): - msg= request.form - print("Payload(text): "+str(msg)) else: - msg="\"\"" - print("Payload(content-type="+request.content_type+"). Setting data to empty, quoted, string") - except: - msg="\"\"" - print("(Exception) Payload does not contain any json or text data, setting empty string as payload") + msg={} + print("Payload(content-type="+request.content_type+"). Setting empty json as payload") + except Exception as e: + msg={} + print("(Exception) Payload does not contain any json, setting empty json as payload") + traceback.print_exc() cntr_msg_callbacks += 1 if (id in msg_callbacks.keys()): @@ -109,30 +137,68 @@ def events_write(id): else: msg_callbacks[id]=[] msg_callbacks[id].append(msg) + + if (id in cntr_callbacks.keys()): + cntr_callbacks[id][0] += 1 + else: + cntr_callbacks[id]=[] + cntr_callbacks[id].append(1) + cntr_callbacks[id].append(0) + except Exception as e: print(CAUGHT_EXCEPTION+str(e)) - return 'OK',500 + traceback.print_exc() + return 'NOTOK',500 return 'OK',200 +### Functions for test ### + +# Dump the whole db of current callbacks +# URI and parameter, (GET): /db +# response: message + 200 +@app.route(DUMP_ALL_URL, + methods=['GET']) +def dump_db(): + return json.dumps(msg_callbacks),200 ### Functions for metrics read out ### @app.route('/counter/received_callbacks', methods=['GET']) def requests_submitted(): - return Response(str(cntr_msg_callbacks), status=200, mimetype=MIME_TEXT) + req_id = request.args.get('id') + if (req_id is None): + return Response(str(cntr_msg_callbacks), status=200, mimetype=MIME_TEXT) + + if (req_id in cntr_callbacks.keys()): + return Response(str(cntr_callbacks[req_id][0]), status=200, mimetype=MIME_TEXT) + else: + return Response(str("0"), status=200, mimetype=MIME_TEXT) @app.route('/counter/fetched_callbacks', methods=['GET']) def requests_fetched(): - return Response(str(cntr_msg_fetched), status=200, mimetype=MIME_TEXT) + req_id = request.args.get('id') + if (req_id is None): + return Response(str(cntr_msg_fetched), status=200, mimetype=MIME_TEXT) + + if (req_id in cntr_callbacks.keys()): + return Response(str(cntr_callbacks[req_id][1]), status=200, mimetype=MIME_TEXT) + else: + return Response(str("0"), status=200, mimetype=MIME_TEXT) @app.route('/counter/current_messages', methods=['GET']) def current_messages(): - return Response(str(cntr_msg_callbacks-cntr_msg_fetched), status=200, mimetype=MIME_TEXT) - + req_id = request.args.get('id') + if (req_id is None): + return Response(str(cntr_msg_callbacks-cntr_msg_fetched), status=200, mimetype=MIME_TEXT) + + if (req_id in cntr_callbacks.keys()): + return Response(str(cntr_callbacks[req_id][0]-cntr_callbacks[req_id][1]), status=200, mimetype=MIME_TEXT) + else: + return Response(str("0"), status=200, mimetype=MIME_TEXT) ### Admin ### diff --git a/test/cr/basic_test.sh b/test/cr/basic_test.sh index dbaca4f0..d0bf25d3 100755 --- a/test/cr/basic_test.sh +++ b/test/cr/basic_test.sh @@ -49,6 +49,9 @@ echo "=== CR hello world ===" RESULT="OK" do_curl GET / 200 +echo "=== Reset ===" +RESULT="*" +do_curl POST /reset 200 echo "=== Get counter - callbacks ===" RESULT="0" @@ -62,11 +65,16 @@ echo "=== Get counter - current events ===" RESULT="0" do_curl GET /counter/current_messages 200 +echo "=== Send a request non json ===" +RESULT="*" +#create payload +echo "DATA" > .tmp.json +do_curl POST '/callbacks/test' 200 .tmp.json echo "=== Send a request ===" RESULT="*" #create payload -echo "\"DATA-MSG\"" > .tmp.json +echo "{\"DATA-MSG\":\"msg\"}" > .tmp.json do_curl POST '/callbacks/test' 200 .tmp.json @@ -74,9 +82,9 @@ echo "=== Fetch an event, wrong id===" RESULT="*" do_curl GET '/get-event/wrongid' 204 - +# Test counters for all ids echo "=== Get counter - callbacks ===" -RESULT="1" +RESULT="2" do_curl GET /counter/received_callbacks 200 echo "=== Get counter - fetched events ===" @@ -84,12 +92,42 @@ RESULT="0" do_curl GET /counter/fetched_callbacks 200 echo "=== Get counter - current events ===" -RESULT="1" +RESULT="2" do_curl GET /counter/current_messages 200 +# Test counter for one id +echo "=== Get counter - callbacks ===" +RESULT="2" +do_curl GET /counter/received_callbacks?id=test 200 + +echo "=== Get counter - fetched events ===" +RESULT="0" +do_curl GET /counter/fetched_callbacks?id=test 200 + +echo "=== Get counter - current events ===" +RESULT="2" +do_curl GET /counter/current_messages?id=test 200 + +# Test counter for dummy id +echo "=== Get counter - callbacks ===" +RESULT="0" +do_curl GET /counter/received_callbacks?id=dummy 200 + +echo "=== Get counter - fetched events ===" +RESULT="0" +do_curl GET /counter/fetched_callbacks?id=dummy 200 + +echo "=== Get counter - current events ===" +RESULT="0" +do_curl GET /counter/current_messages?id=dummy 200 + + +echo "=== Fetch an event ===" +RESULT="json:{}" +do_curl GET '/get-event/test' 200 echo "=== Fetch an event ===" -RESULT="DATA-MSG" +RESULT="json:{\"DATA-MSG\":\"msg\"}" do_curl GET '/get-event/test' 200 echo "=== Fetch an event again ===" @@ -97,15 +135,87 @@ RESULT="*" do_curl GET '/get-event/test' 204 echo "=== Get counter - callbacks ===" -RESULT="1" +RESULT="2" do_curl GET /counter/received_callbacks 200 echo "=== Get counter - fetched events ===" -RESULT="1" +RESULT="2" +do_curl GET /counter/fetched_callbacks 200 + +echo "=== Get counter - current events ===" +RESULT="0" +do_curl GET /counter/current_messages 200 + +# Test counter for one id +echo "=== Get counter - callbacks ===" +RESULT="2" +do_curl GET /counter/received_callbacks?id=test 200 + +echo "=== Get counter - fetched events ===" +RESULT="2" +do_curl GET /counter/fetched_callbacks?id=test 200 + +echo "=== Get counter - current events ===" +RESULT="0" +do_curl GET /counter/current_messages?id=test 200 + +echo "=== Send a request ===" +RESULT="*" +#create payload +echo "{\"DATA-MSG\":\"msg\"}" > .tmp.json +do_curl POST '/callbacks/test' 200 .tmp.json + +echo "=== Send a request ===" +RESULT="*" +#create payload +echo "{\"DATA-MSG2\":\"msg2\"}" > .tmp.json +do_curl POST '/callbacks/test' 200 .tmp.json + +echo "=== Send a request ===" +RESULT="*" +#create payload +echo "{\"DATA-MSG3\":\"msg3\"}" > .tmp.json +do_curl POST '/callbacks/test1' 200 .tmp.json + +echo "=== Get counter - callbacks ===" +RESULT="5" +do_curl GET /counter/received_callbacks 200 + +echo "=== Get counter - fetched events ===" +RESULT="2" do_curl GET /counter/fetched_callbacks 200 echo "=== Get counter - current events ===" +RESULT="3" +do_curl GET /counter/current_messages 200 + +# Test counter for one id, test1 +echo "=== Get counter - callbacks ===" +RESULT="1" +do_curl GET /counter/received_callbacks?id=test1 200 + +echo "=== Get counter - fetched events ===" RESULT="0" +do_curl GET /counter/fetched_callbacks?id=test1 200 + +echo "=== Get counter - current events ===" +RESULT="1" +do_curl GET /counter/current_messages?id=test1 200 + +echo "=== Fetch all events ===" +RESULT="json:[{\"DATA-MSG2\":\"msg2\"},{\"DATA-MSG\":\"msg\"}]" +do_curl GET '/get-all-events/test' 200 + +echo "=== Get counter - callbacks ===" +RESULT="5" +do_curl GET /counter/received_callbacks 200 + +echo "=== Get counter - fetched events ===" +RESULT="4" +do_curl GET /counter/fetched_callbacks 200 + +echo "=== Get counter - current events ===" +RESULT="1" do_curl GET /counter/current_messages 200 echo "=== CR reset ===" diff --git a/test/cr/cr-build-start.sh b/test/cr/cr-build-start.sh index a971d680..22346798 100755 --- a/test/cr/cr-build-start.sh +++ b/test/cr/cr-build-start.sh @@ -21,4 +21,4 @@ docker build -t callback-receiver . -docker run -it -p 8090:8090 -p 8091:8091 callback-receiver +docker run --rm -it -p 8090:8090 -p 8091:8091 callback-receiver diff --git a/test/simulator-group/sim-monitor.js b/test/simulator-group/sim-monitor.js index b746ae5d..7d7ffdf8 100644 --- a/test/simulator-group/sim-monitor.js +++ b/test/simulator-group/sim-monitor.js @@ -30,6 +30,7 @@ var PRODSTUB_PORT="8092" var http = require('http'); var express = require('express'); +const { POINT_CONVERSION_HYBRID } = require('constants') var app = express(); var fieldSize=32; @@ -197,6 +198,9 @@ var ps_producer_type_arr=new Array(0) var ps_producer_jobs_arr=new Array(0) var ps_producer_delivery_arr=new Array(0) +//Full CR DB +var cr_db={} + //Counts the number of get request for the html page var getCtr=0 @@ -204,6 +208,8 @@ var refreshCount_pol=-1 var refreshCount_ecs=-1 +var refreshCount_cr=-1 + var ricbasename="ricsim" function fetchAllMetrics_pol() { @@ -611,6 +617,58 @@ function fetchAllMetrics_ecs() { }, 500) } +function fetchAllMetrics_cr() { + + console.log("Fetching CR DB - timer:" + refreshCount_ecs) + + if (refreshCount_cr < 0) { + refreshCount_cr = -1 + return + } else { + refreshCount_cr = refreshCount_cr - 1 + } + setTimeout(() => { + + if (checkFunctionFlag("cr_stat")) { + getSimCtr(LOCALHOST+CR_PORT+"/db", 0, function(data, index) { + ecs4="" + try { + cr_db=JSON.parse(data); + } + catch (err) { + cr_db={} + } + }); + clearFlag("cr_stat") + } + fetchAllMetrics_cr(); + }, 500) +} + +// Monitor for CR db +app.get("/mon3",function(req, res){ + + console.log("Creating CR DB page - timer: " + refreshCount_ecs) + + if (refreshCount_cr < 0) { + refreshCount_cr=5 + fetchAllMetrics_cr() + } + refreshCount_cr=5 + var json_str=JSON.stringify(cr_db, null, 1) + var htmlStr = "" + + "" + + "" + + ""+ //2 sec auto refresh + "CR DB dump"+ + "" + + "" + + json_str + + "" + + ""; + res.send(htmlStr); +}) + // Monitor for ECS app.get("/mon2",function(req, res){ @@ -831,4 +889,5 @@ var httpPort=9999; httpServer.listen(httpPort); console.log("Simulator monitor listening (http) at "+httpPort); console.log("Open the web page on localhost:9999/mon to view the policy statistics page.") -console.log("Open the web page on localhost:9999/mon2 to view the enrichment statistics page.") \ No newline at end of file +console.log("Open the web page on localhost:9999/mon2 to view the enrichment statistics page.") +console.log("Open the web page on localhost:9999/mon3 to view CR DB in json.") \ No newline at end of file -- 2.16.6