From 72667f1d4b9e534b38b206f64f2ac67df01a2ed9 Mon Sep 17 00:00:00 2001 From: BjornMagnussonXA Date: Fri, 24 Apr 2020 09:20:18 +0200 Subject: [PATCH] Further updates to the auto-test environment Aligned python to python 3 Added test script of ric re-sync Preparing for secure port of simulator and agent Integrated SNDC ONAP adapter to the test environment MR-stub now support long poll and message limits Change-Id: I280f173f811a9fd859c4cc5234084a5a20f77a90 Issue-ID: NONRTRIC-154 Signed-off-by: BjornMagnussonXA --- test/auto-test/.gitignore | 1 + test/auto-test/FTC10.sh | 24 +- test/auto-test/FTC100.sh | 335 +++++++++++---------- test/auto-test/FTC200.sh | 4 +- test/auto-test/FTC300.sh | 2 +- test/auto-test/FTC301.sh | 92 ++++++ test/auto-test/FTC310.sh | 2 +- test/auto-test/FTC320.sh | 2 +- test/auto-test/FTC600.sh | 87 ++++++ test/auto-test/FTC_SDNC.sh | 4 +- test/auto-test/testdata/OSC/1-agent-modified.json | 40 +++ test/auto-test/testdata/OSC/2-agent-modified.json | 36 +++ test/certificate/cert.crt | 16 + test/certificate/generate_cert_and_key.sh | 21 ++ test/certificate/key.crt | 30 ++ test/common/agent_api_functions.sh | 38 +-- test/common/compare_json.py | 111 +++++-- test/common/controller_api_functions.sh | 8 +- test/common/do_curl_function.sh | 31 +- test/common/ricsimulator_api_functions.sh | 16 +- test/common/test_env.sh | 40 ++- test/common/testcase_common.sh | 268 +++++++++++++---- test/cr/.gitignore | 3 +- test/cr/cr.py | 2 +- test/mrstub/.gitignore | 3 +- test/mrstub/Dockerfile | 19 +- test/mrstub/README.md | 35 ++- test/mrstub/basic_test.sh | 70 ++++- test/mrstub/cert/cert.crt | 16 + test/mrstub/cert/key.crt | 30 ++ test/mrstub/frontend.js | 117 +++++++ test/mrstub/mr.py | 29 +- test/mrstub/mrstub-build-start.sh | 2 +- test/mrstub/package.json | 65 ++++ test/mrstub/requirements.txt | 4 +- test/mrstub/start.sh | 21 ++ test/simulator-group/consul_cbs/.gitignore | 2 + test/simulator-group/control_panel/.gitignore | 2 + test/simulator-group/cr/.gitignore | 2 + test/simulator-group/mr/.gitignore | 2 + test/simulator-group/mr/cert/cert.crt | 16 + test/simulator-group/mr/cert/key.crt | 30 ++ test/simulator-group/mr/docker-compose.yml | 3 + test/simulator-group/policy_agent/.gitignore | 2 + .../policy_agent/docker-compose.yml | 5 +- test/simulator-group/ric/.gitignore | 5 +- test/simulator-group/ric/cert/cert.crt | 16 + test/simulator-group/ric/cert/key.crt | 30 ++ test/simulator-group/ric/docker-compose.yml | 17 +- test/simulator-group/sdnc/.gitignore | 2 + test/simulator-group/sdnc_onap/docker-compose.yml | 65 ++++ test/simulator-group/sim-monitor.js | 134 ++++++--- 52 files changed, 1580 insertions(+), 377 deletions(-) create mode 100755 test/auto-test/FTC301.sh create mode 100755 test/auto-test/FTC600.sh create mode 100644 test/auto-test/testdata/OSC/1-agent-modified.json create mode 100644 test/auto-test/testdata/OSC/2-agent-modified.json create mode 100644 test/certificate/cert.crt create mode 100755 test/certificate/generate_cert_and_key.sh create mode 100644 test/certificate/key.crt create mode 100644 test/mrstub/cert/cert.crt create mode 100644 test/mrstub/cert/key.crt create mode 100644 test/mrstub/frontend.js create mode 100644 test/mrstub/package.json create mode 100644 test/mrstub/start.sh create mode 100644 test/simulator-group/consul_cbs/.gitignore create mode 100644 test/simulator-group/control_panel/.gitignore create mode 100644 test/simulator-group/cr/.gitignore create mode 100644 test/simulator-group/mr/.gitignore create mode 100644 test/simulator-group/mr/cert/cert.crt create mode 100644 test/simulator-group/mr/cert/key.crt create mode 100644 test/simulator-group/policy_agent/.gitignore create mode 100644 test/simulator-group/ric/cert/cert.crt create mode 100644 test/simulator-group/ric/cert/key.crt create mode 100644 test/simulator-group/sdnc/.gitignore create mode 100644 test/simulator-group/sdnc_onap/docker-compose.yml diff --git a/test/auto-test/.gitignore b/test/auto-test/.gitignore index 6215d91c..602c2fb7 100644 --- a/test/auto-test/.gitignore +++ b/test/auto-test/.gitignore @@ -8,3 +8,4 @@ logs .tmp.curl.json .consul* .ext.consul* +.dockererr diff --git a/test/auto-test/FTC10.sh b/test/auto-test/FTC10.sh index 88088959..58128b78 100755 --- a/test/auto-test/FTC10.sh +++ b/test/auto-test/FTC10.sh @@ -21,7 +21,7 @@ TC_ONELINE_DESCR="Basic use case, register rapp, create/update policy, delete po . ../common/testcase_common.sh $@ . ../common/agent_api_functions.sh - +. ../common/ricsimulator_api_functions.sh #### TEST BEGIN #### @@ -47,11 +47,11 @@ consul_config_app ".consul_config.json" start_control_panel -#start_sdnc - start_policy_agent -use_agent_rest +set_agent_debug + +use_agent_rest_http api_get_status 200 @@ -65,9 +65,9 @@ api_equal json:policy_types 2 60 # Create policies -use_agent_rest +use_agent_rest_http -api_put_service 201 "rapp1" 3600 "$CR_PATH/callbacks/1" +api_put_service 201 "rapp1" 3600 "$CR_PATH/1" api_put_policy 201 "rapp1" ricsim_g1_1 1 2000 testdata/OSC/pi1_template.json 1 @@ -81,7 +81,7 @@ api_put_policy 201 "rapp1" ricsim_g1_1 1 3000 testdata/OSC/pi1_template.json 1 sim_equal ricsim_g1_1 num_instances 2 -use_agent_rest +use_agent_rest_http api_put_policy 201 "rapp1" ricsim_g2_1 NOTYPE 2100 testdata/STD/pi1_template.json 1 @@ -96,7 +96,7 @@ sim_equal ricsim_g2_1 num_instances 2 #Update policies -use_agent_rest +use_agent_rest_http api_put_service 200 "rapp1" 3600 "$CR_PATH/callbacks/1" @@ -112,7 +112,7 @@ api_put_policy 200 "rapp1" ricsim_g1_1 1 3000 testdata/OSC/pi1_template.json 1 sim_equal ricsim_g1_1 num_instances 2 -use_agent_rest +use_agent_rest_http api_put_policy 200 "rapp1" ricsim_g2_1 NOTYPE 2100 testdata/STD/pi1_template.json 1 @@ -136,18 +136,18 @@ api_get_policy 200 3100 testdata/STD/pi1_template.json use_agent_dmaap api_delete_policy 204 2000 -use_agent_rest +use_agent_rest_http api_delete_policy 204 3000 use_agent_dmaap api_delete_policy 204 2100 -use_agent_rest +use_agent_rest_http api_delete_policy 204 3100 sim_equal ricsim_g1_1 num_instances 0 sim_equal ricsim_g2_1 num_instances 0 # Check policy removal -use_agent_rest +use_agent_rest_http api_get_policy 404 2000 api_get_policy 404 3000 api_get_policy 404 2100 diff --git a/test/auto-test/FTC100.sh b/test/auto-test/FTC100.sh index 79fdd491..42c86768 100755 --- a/test/auto-test/FTC100.sh +++ b/test/auto-test/FTC100.sh @@ -36,283 +36,302 @@ 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 interface in $TESTED_VARIANTS ; do +for __httpx in $TESTED_PROTOCOLS ; do + for interface in $TESTED_VARIANTS ; do - echo "#####################################################################" - echo "#####################################################################" - echo "### Testing agent: "$interface - echo "#####################################################################" - echo "#####################################################################" + echo "#####################################################################" + echo "#####################################################################" + echo "### Testing agent: "$interface + echo "#####################################################################" + echo "#####################################################################" - # Clean container and start all needed containers # - clean_containers + # 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 [ $__httpx == "HTTPS" ]; then + echo "Using secure ports towards simulators" + use_simulator_https + else + echo "Using non-secure ports towards simulators" + use_simulator_http + fi - start_mr + start_ric_simulators ricsim_g1 1 OSC_2.1.0 + start_ric_simulators ricsim_g2 1 STD_1.1.3 - start_cr + start_mr - start_consul_cbs + start_cr - if [ $interface == "SDNC" ] || [ $interface == "DMAAP+SDNC" ]; then - prepare_consul_config SDNC ".consul_config.json" - else - prepare_consul_config NOSDNC ".consul_config.json" - fi + start_consul_cbs - consul_config_app ".consul_config.json" + if [ $interface == "REST+SDNC" ] || [ $interface == "DMAAP+SDNC" ]; then + prepare_consul_config SDNC ".consul_config.json" + else + prepare_consul_config NOSDNC ".consul_config.json" + fi - start_control_panel + consul_config_app ".consul_config.json" - if [ $interface == "SDNC" ] || [ $interface == "DMAAP+SDNC" ]; then - start_sdnc - fi + start_control_panel - start_policy_agent + if [ $interface == "REST+SDNC" ] || [ $interface == "DMAAP+SDNC" ]; then + start_sdnc + fi - if [ $interface == "DMAAP" ] || [ $interface == "DMAAP+SDNC" ]; then - use_agent_dmaap - else - use_agent_rest - fi + start_policy_agent + 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 - sim_put_policy_type 201 ricsim_g1_1 2 testdata/OSC/sim_2.json + cr_equal received_callbacks 0 + mr_equal requests_submitted 0 - api_equal json:rics 2 60 + 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 - api_equal json:policy_schemas 3 120 + api_equal json:rics 2 60 - api_equal json:policy_types 3 + api_equal json:policy_schemas 3 120 - api_equal json:policies 0 + api_equal json:policy_types 3 - api_equal json:policy_ids 0 + api_equal json:policies 0 + api_equal json:policy_ids 0 - echo "############################################" - echo "############## Health check ################" - echo "############################################" - api_get_status 200 + echo "############################################" + echo "############## Health check ################" + echo "############################################" - echo "############################################" - echo "##### Service registry and supervision #####" - echo "############################################" + api_get_status 200 - api_get_services 404 "rapp1" + echo "############################################" + echo "##### Service registry and supervision #####" + echo "############################################" - api_put_service 201 "rapp1" 1000 "$CR_PATH/1" + api_get_services 404 "rapp1" - api_put_service 200 "rapp1" 2000 "$CR_PATH/1" + api_put_service 201 "rapp1" 1000 "$CR_PATH/1" + api_put_service 200 "rapp1" 2000 "$CR_PATH/1" - api_put_service 400 "rapp2" -1 "$CR_PATH/2" - api_put_service 400 "rapp2" "wrong" "$CR_PATH/2" + api_put_service 400 "rapp2" -1 "$CR_PATH/2" - api_put_service 400 "rapp2" 100 "/test" + api_put_service 400 "rapp2" "wrong" "$CR_PATH/2" - api_put_service 400 "rapp2" 100 "test-path" + api_put_service 400 "rapp2" 100 "/test" - api_put_service 201 "rapp2" 300 "ftp://localhost:80/test" + api_put_service 400 "rapp2" 100 "test-path" - api_get_services 200 "rapp1" "rapp1" 2000 "$CR_PATH/1" + api_put_service 201 "rapp2" 300 "ftp://localhost:80/test" - api_get_service_ids 200 "rapp1" "rapp2" + api_get_services 200 "rapp1" "rapp1" 2000 "$CR_PATH/1" + api_get_service_ids 200 "rapp1" "rapp2" - api_put_service 201 "rapp3" 5000 "$CR_PATH/3" + api_put_service 201 "rapp3" 5000 "$CR_PATH/3" - api_get_service_ids 200 "rapp1" "rapp2" "rapp3" + api_get_service_ids 200 "rapp1" "rapp2" "rapp3" - api_get_services 200 "rapp1" "rapp1" 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 "rapp1" "rapp1" 2000 "$CR_PATH/1" - api_get_services 200 + api_get_services 200 NOSERVICE "rapp1" 2000 "$CR_PATH/1" "rapp2" 300 "ftp://localhost:80/test" "rapp3" 5000 "$CR_PATH/3" - echo -e $YELLOW"TR2"$EYELLOW - api_put_services_keepalive 201 "rapp1" - echo -e $YELLOW"TR2"$EYELLOW - api_put_services_keepalive 201 "rapp3" + api_get_services 200 - api_put_services_keepalive 200 "rapp1" + echo -e $YELLOW"TR2"$EYELLOW + api_put_services_keepalive 201 "rapp1" + echo -e $YELLOW"TR2"$EYELLOW + api_put_services_keepalive 201 "rapp3" - api_put_services_keepalive 200 "rapp3" + api_put_services_keepalive 200 "rapp1" - api_put_services_keepalive 404 "rapp5" + api_put_services_keepalive 200 "rapp3" - api_get_service_ids 200 "rapp1" "rapp2" "rapp3" + api_put_services_keepalive 404 "rapp5" - api_delete_services 204 "rapp1" + api_get_service_ids 200 "rapp1" "rapp2" "rapp3" - api_get_service_ids 200 "rapp2" "rapp3" + api_delete_services 204 "rapp1" + api_get_service_ids 200 "rapp2" "rapp3" - api_put_service 201 "rapp1" 50 "$CR_PATH/1" - api_get_service_ids 200 "rapp1" "rapp2" "rapp3" + api_put_service 201 "rapp1" 50 "$CR_PATH/1" + api_get_service_ids 200 "rapp1" "rapp2" "rapp3" - api_delete_services 204 "rapp1" - api_delete_services 204 "rapp3" - api_equal json:services 1 + api_delete_services 204 "rapp1" + api_delete_services 204 "rapp3" - api_delete_services 204 "rapp2" + api_equal json:services 1 - api_equal json:services 0 + api_delete_services 204 "rapp2" + api_equal json:services 0 - echo "############################################" - echo "############## RIC Repository ##############" - echo "############################################" - api_get_rics 200 NOTYPE "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1,2:AVAILABLE ricsim_g2_1:me1_ricsim_g2_1,me2_ricsim_g2_1:EMPTYTYPE:AVAILABLE" + echo "############################################" + echo "############## RIC Repository ##############" + echo "############################################" - api_get_rics 200 1 "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1,2:AVAILABLE" + api_get_rics 200 NOTYPE "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1,2:AVAILABLE ricsim_g2_1:me1_ricsim_g2_1,me2_ricsim_g2_1:EMPTYTYPE:AVAILABLE" - api_get_rics 404 47 + api_get_rics 200 1 "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1,2:AVAILABLE" - api_get_rics 404 "test" + api_get_rics 404 47 + api_get_rics 404 "test" - api_get_ric 200 me1_ricsim_g1_1 ricsim_g1_1 - api_get_ric 200 me2_ricsim_g1_1 ricsim_g1_1 + api_get_ric 200 me1_ricsim_g1_1 ricsim_g1_1 - api_get_ric 200 me1_ricsim_g2_1 ricsim_g2_1 + api_get_ric 200 me2_ricsim_g1_1 ricsim_g1_1 - api_get_ric 200 me2_ricsim_g2_1 ricsim_g2_1 + api_get_ric 200 me1_ricsim_g2_1 ricsim_g2_1 - api_get_ric 404 test + api_get_ric 200 me2_ricsim_g2_1 ricsim_g2_1 + api_get_ric 404 test - echo "############################################" - echo "########### A1 Policy Management ###########" - echo "############################################" - echo -e $YELLOW"TR9"$EYELLOW - api_get_policy_schema 200 1 testdata/OSC/1.json - echo -e $YELLOW"TR9"$EYELLOW - api_get_policy_schema 200 2 testdata/OSC/2.json - api_get_policy_schema 404 3 - echo -e $YELLOW"TR9"$EYELLOW - api_get_policy_schemas 200 NORIC testdata/OSC/1.json testdata/OSC/2.json NOFILE - echo -e $YELLOW"TR9"$EYELLOW - api_get_policy_schemas 200 ricsim_g1_1 testdata/OSC/1.json testdata/OSC/2.json + echo "############################################" + echo "########### A1 Policy Management ###########" + echo "############################################" + echo -e $YELLOW"TR9"$EYELLOW + api_get_policy_schema 200 1 testdata/OSC/1-agent-modified.json + echo -e $YELLOW"TR9"$EYELLOW + api_get_policy_schema 200 2 testdata/OSC/2-agent-modified.json - api_get_policy_schemas 200 ricsim_g2_1 NOFILE + api_get_policy_schema 404 3 + echo -e $YELLOW"TR9"$EYELLOW + api_get_policy_schemas 200 NORIC testdata/OSC/1-agent-modified.json testdata/OSC/2-agent-modified.json NOFILE + echo -e $YELLOW"TR9"$EYELLOW + api_get_policy_schemas 200 ricsim_g1_1 testdata/OSC/1-agent-modified.json testdata/OSC/2-agent-modified.json - api_get_policy_schemas 404 test + api_get_policy_schemas 200 ricsim_g2_1 NOFILE + api_get_policy_schemas 404 test - api_get_policy_types 200 NORIC 1 2 EMPTY - api_get_policy_types 200 ricsim_g1_1 1 2 + api_get_policy_types 200 NORIC 1 2 EMPTY - api_get_policy_types 200 ricsim_g2_1 EMPTY + api_get_policy_types 200 ricsim_g1_1 1 2 - api_get_policy_types 404 dummy-ric + api_get_policy_types 200 ricsim_g2_1 EMPTY + api_get_policy_types 404 dummy-ric - 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_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 + 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_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 "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 - VAL='NOT IN EFFECT' - api_get_policy_status 200 5000 OSC "$VAL" "false" - api_get_policy_status 200 5100 STD "UNDEFINED" + 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 + 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 - api_get_policy_ids 200 ricsim_g2_1 NOSERVICE NOTYPE 5100 + 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 + 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 NOSERVICE 2 NOID + 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 ricsim_g2_1 NOSERVICE 1 NOID + api_get_policy_ids 200 NORIC NOSERVICE 2 NOID + api_get_policy_ids 200 ricsim_g2_1 NOSERVICE 1 NOID - api_get_policy 200 5000 testdata/OSC/pi1_template.json - api_get_policy 200 5100 testdata/STD/pi1_template.json + api_get_policy 200 5000 testdata/OSC/pi1_template.json + 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 "rapp10" 1 5000 ricsim_g1_1 "rapp10" 1 testdata/OSC/pi1_template.json - echo -e $YELLOW"TR10"$EYELLOW - api_delete_policy 404 2000 - api_delete_policy 404 1500 + echo -e $YELLOW"TR10"$EYELLOW + api_delete_policy 404 2000 - api_delete_policy 204 5000 + api_delete_policy 404 1500 - api_equal json:policies 1 + api_delete_policy 204 5000 - api_equal json:policy_ids 1 + api_equal json:policies 1 - api_delete_policy 204 5100 + api_equal json:policy_ids 1 - api_equal json:policies 0 + api_delete_policy 204 5100 - api_equal json:policy_ids 0 + api_equal json:policies 0 - cr_equal received_callbacks 0 + api_equal json:policy_ids 0 - if [ $interface == "DMAAP" ] || [ $interface == "DMAAP+SDNC" ]; then - mr_greater requests_submitted 0 - VAL=$(mr_read requests_submitted) - 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 + cr_equal received_callbacks 0 + + if [ $interface == "DMAAP" ] || [ $interface == "DMAAP+SDNC" ]; then + mr_greater requests_submitted 0 + VAL=$(mr_read requests_submitted) + 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 + + check_policy_agent_logs + check_control_panel_logs - check_policy_agent_logs - check_control_panel_logs + store_logs $interface - store_logs $interface + done done diff --git a/test/auto-test/FTC200.sh b/test/auto-test/FTC200.sh index 2f62c56d..b53ae4e1 100755 --- a/test/auto-test/FTC200.sh +++ b/test/auto-test/FTC200.sh @@ -48,11 +48,9 @@ consul_config_app ".consul_config.json" start_control_panel -#start_sdnc - start_policy_agent -use_agent_rest +use_agent_rest_http #Verify no callbacks or dmaap messages has been sent cr_equal received_callbacks 0 diff --git a/test/auto-test/FTC300.sh b/test/auto-test/FTC300.sh index 3b07f603..a004292d 100755 --- a/test/auto-test/FTC300.sh +++ b/test/auto-test/FTC300.sh @@ -48,7 +48,7 @@ start_control_panel start_policy_agent -use_agent_rest +use_agent_rest_http api_get_status 200 diff --git a/test/auto-test/FTC301.sh b/test/auto-test/FTC301.sh new file mode 100755 index 00000000..fc5aba8b --- /dev/null +++ b/test/auto-test/FTC301.sh @@ -0,0 +1,92 @@ +#!/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 10000 policies using OSC interface over REST+SNDC" + +. ../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 4 OSC_2.1.0 + +start_mr + +start_cr + +start_sdnc + +start_consul_cbs + +prepare_consul_config SDNC ".consul_config.json" +consul_config_app ".consul_config.json" + +start_control_panel + + +start_policy_agent + +use_agent_rest_http + +api_get_status 200 + +sim_print ricsim_g1_1 interface + +sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json + +api_equal json:policy_types 1 120 #Wait for the agent to refresh types from the simulator + +api_put_service 201 "rapp1" 3600 "$CR_PATH/callbacks/1" + +api_put_policy 201 "rapp1" ricsim_g1_1 1 2000 testdata/OSC/pi1_template.json 10000 + +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 + +api_delete_policy 204 2435 + +api_delete_policy 204 8693 + +sim_post_delete_instances 200 ricsim_g1_1 + +sim_post_delete_instances 200 ricsim_g1_1 + +sim_equal ricsim_g1_1 num_instances 9998 300 + + +check_policy_agent_logs + +#### TEST COMPLETE #### + +store_logs END + +print_result \ No newline at end of file diff --git a/test/auto-test/FTC310.sh b/test/auto-test/FTC310.sh index 0edd82e5..9600f4ad 100755 --- a/test/auto-test/FTC310.sh +++ b/test/auto-test/FTC310.sh @@ -53,7 +53,7 @@ start_control_panel start_policy_agent -use_agent_rest +use_agent_rest_http api_get_status 200 diff --git a/test/auto-test/FTC320.sh b/test/auto-test/FTC320.sh index 2b1b96a5..067cd876 100755 --- a/test/auto-test/FTC320.sh +++ b/test/auto-test/FTC320.sh @@ -54,7 +54,7 @@ start_control_panel start_policy_agent -use_agent_rest +use_agent_rest_http set_agent_debug diff --git a/test/auto-test/FTC600.sh b/test/auto-test/FTC600.sh new file mode 100755 index 00000000..4afe3768 --- /dev/null +++ b/test/auto-test/FTC600.sh @@ -0,0 +1,87 @@ +#!/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/FTC_SDNC.sh b/test/auto-test/FTC_SDNC.sh index 0a8dce5c..71faf7ae 100755 --- a/test/auto-test/FTC_SDNC.sh +++ b/test/auto-test/FTC_SDNC.sh @@ -21,6 +21,8 @@ TC_ONELINE_DESCR="Create 1 policy with SDNC and 1 policy without SDNC over agent . ../common/testcase_common.sh $@ . ../common/agent_api_functions.sh +. ../common/ricsimulator_api_functions.sh +. ../common/controller_api_functions.sh #### TEST BEGIN #### @@ -54,7 +56,7 @@ for TEST in $VARIANTS ; do set_agent_debug - use_agent_rest + use_agent_rest_http echo "Using: "$TEST diff --git a/test/auto-test/testdata/OSC/1-agent-modified.json b/test/auto-test/testdata/OSC/1-agent-modified.json new file mode 100644 index 00000000..3b37214a --- /dev/null +++ b/test/auto-test/testdata/OSC/1-agent-modified.json @@ -0,0 +1,40 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "1", + "description": "Type 1 policy type", + "type": "object", + "properties": { + "scope": { + "type": "object", + "properties": { + "ueId": { + "type": "string" + }, + "qosId": { + "type": "string" + } + }, + "additionalProperties": false, + "required": [ + "ueId", + "qosId" + ] + }, + "qosObjective": { + "type": "object", + "properties": { + "priorityLevel": { + "type": "number" + } + }, + "additionalProperties": false, + "required": [ + "priorityLevel" + ] + } + }, + "additionalProperties": false, + "required": [ + "scope", "qosObjective" + ] + } diff --git a/test/auto-test/testdata/OSC/2-agent-modified.json b/test/auto-test/testdata/OSC/2-agent-modified.json new file mode 100644 index 00000000..88e75b08 --- /dev/null +++ b/test/auto-test/testdata/OSC/2-agent-modified.json @@ -0,0 +1,36 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "2", + "description": "Type 2 policy type", + "type": "object", + "properties": { + "scope": { + "type": "object", + "properties": { + "sliceId": { + "type": "string" + } + }, + "additionalProperties": false, + "required": [ + "sliceId" + ] + }, + "qoeObjectives": { + "type": "object", + "properties": { + "qoeScore": { + "type": "number" + } + }, + "additionalProperties": false, + "required": [ + "qoeScore" + ] + } + }, + "additionalProperties": false, + "required": [ + "scope", "qoeObjectives" + ] + } diff --git a/test/certificate/cert.crt b/test/certificate/cert.crt new file mode 100644 index 00000000..51e37a79 --- /dev/null +++ b/test/certificate/cert.crt @@ -0,0 +1,16 @@ +-----BEGIN CERTIFICATE----- +MIICljCCAX4CCQDVlvlNzxH9FzANBgkqhkiG9w0BAQsFADANMQswCQYDVQQGEwJT +RTAeFw0yMDA0MjgxOTE2MTNaFw00NzA5MTMxOTE2MTNaMA0xCzAJBgNVBAYTAlNF +MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqpnXP5VmOvMPOTWaxWvm +zfSBRvnioEFHoriGld+pW+vvvrma9UiWfxX3GaGFItxuwbwLwqwvR2LDo6wQQpbl +SaNhg89DYD/NZvlRlLNcYOL218LjfFf4xaKVQGBHfT0Ts9JGTbTD/zcR2VS+3DUR +lvLzbNpQ+Rdvwls7wsL1ZblR+1lry9HMGKCrtsYDSOMSyGqE40u1bOYAw1+VMrfp +cK14u9toNPIbvk+HDP5yYnjC4FEp0ai07s3T6YDWHvp0WNIFJHCVFYzYQgS79/2b +8zg4H7ZMQ5XjxcenU6f8Q97nN0VMk46LIutGe/7rYO0uYKrHcJz1qUu1ui96zOVC +DQIDAQABMA0GCSqGSIb3DQEBCwUAA4IBAQBGvmFRHuUESpwijkekR0WFBuW6UNE5 +J7cZ9CXm7Mz06jeTAZWoCWVAZjYnpQ/MjvyzFglD9wL+A6LblIU+yNctYwtfspAq +xDYmBKlhsKzlgZ3fyBUlfrM5BFxZR2uu1/4bUU4geEQrI2rYzif3Flj0a55EIeSa +37fa7Acc+nNfy47mAa8Dsog6LHMs+FXGmuMS31c9lc70c9v4jCArctdDn/zKg9A7 +HCwd0+icgyDD+9U9eBhcFreBWyA1tPREWyx0qbhlw43OsVMpB6VM4exLGs/v1e0x +/Nmmsis1o54eu2cLGjr5EYlDmdFD3Dn458r0zFkxg4CE23lRUtFz8d6F +-----END CERTIFICATE----- diff --git a/test/certificate/generate_cert_and_key.sh b/test/certificate/generate_cert_and_key.sh new file mode 100755 index 00000000..0f79bbf7 --- /dev/null +++ b/test/certificate/generate_cert_and_key.sh @@ -0,0 +1,21 @@ +#!/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================================================= +# + +# This will generate a self-signed certificate with password 'test' +openssl req -x509 -passout pass:"test" -newkey rsa:2048 -keyout key.crt -out cert.crt -days 9999 diff --git a/test/certificate/key.crt b/test/certificate/key.crt new file mode 100644 index 00000000..380e145b --- /dev/null +++ b/test/certificate/key.crt @@ -0,0 +1,30 @@ +-----BEGIN ENCRYPTED PRIVATE KEY----- +MIIFHzBJBgkqhkiG9w0BBQ0wPDAbBgkqhkiG9w0BBQwwDgQIoefVgflG3OYCAggA +MB0GCWCGSAFlAwQBKgQQEaJvnbiOIkAwGcyqi6eYCQSCBNDnK9PT/NdGvZAriJAg +VYbqJiCxrqfrfRDAKU4Z4GWFnodzLt2+Xe6iEeOmCkCfs/oVaWx+yIMFzZKY2sq/ +jMmiihJggV+R+hIEXBsVnvqL/nqbchQ7ckhJK8ofXMcpdUdCd8CHylRPNmNNfMsu +o3BbDjKEdCtWMmBWuMWI3DtF0U5Tu5d+nH2ZHpl7YtA7U+N5w3nWBlxoPVXmqsEH +YE8cL0C/b+nFNs81FXKlbIPGNSv51c5YPjS0WQneci2Vj9JMPHWT6VMCaxVlv3js +droG6AxzHH+UpB1Lx4BfVunHR79nmhzmH9mo74rWCiYZ+Kh7DnC26WHrJW/tqJX8 +AvDPIEyVsQ8JQH7omBviVs6NCwoDCwS7jX0NUTy2aWgd4feI+BLwt9SDpEIzyQHt +YXZnwREd2ymDhS0ewvC4fjV82PJHc/yGBlNnXTh4er8hpUPjxTIuNZGaaWP7fcYP +qqPuyfTZvTkKtzHKYsrOk6Fq7M5kMGjFBrGWK3dCNptCXM/R8gaxRqcOvEOb9G5g +ISlC+TZy5T/EUZXJUJEK3gGMrQY4LYCxGm71Wnwe89zmC6bK/z/2XvNts867YKU+ +pODWHcxntJhwlzBRLL56dn2T0OhJEiynUMtpm45O3bHBtRkMjlQ5BhNic0Tog6fb +757gJnbnSNFB5mCSkB09iPt8LEEamQGYUGbXE+0mPTdqwaAaKbz4Gh1yV3T9alh+ +AxJu/YaB52mmf2KdFVUuPBVzSMawYvp6hXHIgzJ6tb/GmYFI7P21RBQfVR/fKuJx +pQMgRclNdYCAC0VCqHxSZdO0Lu7Sd/SWybCCNbfw+0tEO1fDlZwWbVQiF79AL62J +VvaWX3pX8IF227astnyMxkCH6MB4fvu7CSZKTYgdkXekP81Ck5ZxStRcSj4jOvYj +xuMqIvGzy16JRG1aGE1jpzunYBdDKiKKOIphH+jBK3NPk3b7wkTLxi7IkdS4MUf1 +e5E50W/Xx3wUlfyBvuc1TQy/1Moh+HvXIIG3JHU9MjfPkYwHvDITWIdXJb1vSEAE +opi+zNt7C5A+mC1/CC2MCjHk+g+cqpLcSFmv9MXnhg8bHmuhSjaXWChD8sj/S7H4 +Kazc87gikvQguxFv+bFiVQ6+GdPcGvsrnh+UFn/kfHUM8wt2AWnrKc8OLWXbs8Ge +0bCqXo1uy2sZEv558BGRKI35c/F4sovf0FLe8+M+UHPqOeYVaxSt9accXTHK2ajN +IEEKuL5v0BDNTQqo0uDw0HJyKW+L55UpJQ9nNSdVjtQUnPJtbWlVg0V2Q7mnVOSF +GRMqBtu+U9sejR03odkURjDFULntSw80M+U0LC+ceOrESLkO0AK2Yub1+IhR3OBh +jICv3eTZbqZ27ltZrsyDTAYoRVnTvPQwSZoUJ6cQS6XgLa3QitDcj+Zqch9z7sV2 +ydkEHEbLXPIt/sQyASluKm5j1tHJVtzwezb5GO54WYwdpy3MmZ3VhXsagJc9oLHX +MtsDGZR0hXMgzPp49leBhcieWW6fWXAZKt2oa64eI/12i2wSTjNsxPfsu45tJYXO +GAPL0OYBKeVLi1Pfa3kCLqlMDAyC4GzTScWXad5/FEeo189JU1aGcJn7Gn7Ao805 +wuOOs1TQk+KHvAFDEGkkJEM0lg== +-----END ENCRYPTED PRIVATE KEY----- diff --git a/test/common/agent_api_functions.sh b/test/common/agent_api_functions.sh index 312eacb5..46026c19 100644 --- a/test/common/agent_api_functions.sh +++ b/test/common/agent_api_functions.sh @@ -79,10 +79,10 @@ __do_curl_to_agent() { return 1 fi - if [ $ADAPTER == $RESTBASE ]; then + if [ $ADAPTER == $RESTBASE ] || [ $ADAPTER == $RESTBASE_SECURE ]; then url=" "${ADAPTER}${2} oper=" -X "$oper - curlString="curl"${oper}${timeout}${httpcode}${accept}${content}${url}${file} + curlString="curl -k "${oper}${timeout}${httpcode}${accept}${content}${url}${file} echo " CMD: "$curlString >> $HTTPLOG if [ $# -eq 3 ]; then echo " FILE: $(<$3)" >> $HTTPLOG @@ -126,7 +126,7 @@ __do_curl_to_agent() { file=" --data-binary "$payload fi #urlencode the request url since it will be carried by send-request url - requestUrl=$(python -c "from __future__ import print_function; import urllib.parse, sys; print(urllib.parse.quote(sys.argv[1]))" "$2") + 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 @@ -286,7 +286,7 @@ api_get_policies() { targetJson=$targetJson"]" echo "TARGET JSON: $targetJson" >> $HTTPLOG - res=$(python ../common/compare_json.py "$targetJson" "$body" "id") + res=$(python3 ../common/compare_json.py "$targetJson" "$body") if [ $res -ne 0 ]; then echo -e $RED" FAIL, returned body not correct"$ERED @@ -331,7 +331,7 @@ api_get_policy() { sed 's/XXX/'${2}'/g' $3 > $file targetJson=$(< $file) echo "TARGET JSON: $targetJson" >> $HTTPLOG - res=$(python ../common/compare_json.py "$targetJson" "$body") + res=$(python3 ../common/compare_json.py "$targetJson" "$body") if [ $res -ne 0 ]; then echo -e $RED" FAIL, returned body not correct"$ERED ((RES_FAIL++)) @@ -381,7 +381,7 @@ api_put_policy() { sed 's/XXX/'${pid}'/g' $6 > $file res="$(__do_curl_to_agent PUT $query $file)" status=${res:${#res}-3} - echo -ne " Creating "$count"("$max")\033[0K\r" + echo -ne " Creating "$count"("$max")${SAMELINE}" if [ $status -ne $1 ]; then let pid=$pid+1 @@ -393,7 +393,7 @@ api_put_policy() { let pid=$pid+1 let count=$count+1 - echo -ne " Created "$count"("$max")\033[0K\r" + echo -ne " Created "$count"("$max")${SAMELINE}" done echo "" @@ -429,7 +429,7 @@ api_delete_policy() { query="/policy?id="$pid res="$(__do_curl_to_agent DELETE $query)" status=${res:${#res}-3} - echo -ne " Deleting "$count"("$max")\033[0K\r" + echo -ne " Deleting "$count"("$max")${SAMELINE}" if [ $status -ne $1 ]; then echo " Deleted "$count"?("$max")" @@ -439,7 +439,7 @@ api_delete_policy() { fi let pid=$pid+1 let count=$count+1 - echo -ne " Deleted "$count"("$max")\033[0K\r" + echo -ne " Deleted "$count"("$max")${SAMELINE}" done echo "" @@ -507,7 +507,7 @@ api_get_policy_ids() { targetJson=$targetJson"]" echo "TARGET JSON: $targetJson" >> $HTTPLOG - res=$(python ../common/compare_json.py "$targetJson" "$body") + res=$(python3 ../common/compare_json.py "$targetJson" "$body") if [ $res -ne 0 ]; then echo -e $RED" FAIL, returned body not correct"$ERED @@ -550,7 +550,7 @@ api_get_policy_schema() { targetJson=$(< $3) echo "TARGET JSON: $targetJson" >> $HTTPLOG - res=$(python ../common/compare_json.py "$targetJson" "$body") + res=$(python3 ../common/compare_json.py "$targetJson" "$body") if [ $res -ne 0 ]; then echo -e $RED" FAIL, returned body not correct"$ERED @@ -602,13 +602,13 @@ api_get_policy_schemas() { if [ $file == "NOFILE" ]; then targetJson=$targetJson"{}" else - targetJson=$targetJson$(< $3) + targetJson=$targetJson$(< $file) fi done targetJson=$targetJson"]" echo "TARGET JSON: $targetJson" >> $HTTPLOG - res=$(python ../common/compare_json.py "$targetJson" "$body") + res=$(python3 ../common/compare_json.py "$targetJson" "$body") if [ $res -ne 0 ]; then echo -e $RED" FAIL, returned body not correct"$ERED @@ -666,7 +666,7 @@ api_get_policy_status() { echo "TARGET JSON: $targetJson" >> $HTTPLOG body=${res:0:${#res}-3} - res=$(python ../common/compare_json.py "$targetJson" "$body") + res=$(python3 ../common/compare_json.py "$targetJson" "$body") if [ $res -ne 0 ]; then echo -e $RED" FAIL, returned body not correct"$ERED @@ -725,7 +725,7 @@ api_get_policy_types() { targetJson=$targetJson"]" echo "TARGET JSON: $targetJson" >> $HTTPLOG - res=$(python ../common/compare_json.py "$targetJson" "$body") + res=$(python3 ../common/compare_json.py "$targetJson" "$body") if [ $res -ne 0 ]; then echo -e $RED" FAIL, returned body not correct"$ERED @@ -841,7 +841,7 @@ api_get_rics() { if [ $# -gt 2 ]; then body=${res:0:${#res}-3} - res=$(python ../common/create_rics_json.py ".tmp_rics.json" "$3" ) + res=$(python3 ../common/create_rics_json.py ".tmp_rics.json" "$3" ) if [ $res -ne 0 ]; then echo -e $RED" FAIL, could not create target ric info json"$ERED ((RES_FAIL++)) @@ -850,7 +850,7 @@ api_get_rics() { targetJson=$(<.tmp_rics.json) echo "TARGET JSON: $targetJson" >> $HTTPLOG - res=$(python ../common/compare_json.py "$targetJson" "$body") + res=$(python3 ../common/compare_json.py "$targetJson" "$body") if [ $res -ne 0 ]; then echo -e $RED" FAIL, returned body not correct"$ERED ((RES_FAIL++)) @@ -960,7 +960,7 @@ api_get_services() { done targetJson=$targetJson"]" echo "TARGET JSON: $targetJson" >> $HTTPLOG - res=$(python ../common/compare_json.py "$targetJson" "$body" "serviceName") + res=$(python3 ../common/compare_json.py "$targetJson" "$body") if [ $res -ne 0 ]; then echo -e $RED" FAIL, returned body not correct"$ERED ((RES_FAIL++)) @@ -1007,7 +1007,7 @@ api_get_service_ids() { targetJson=$targetJson"]" echo "TARGET JSON: $targetJson" >> $HTTPLOG - res=$(python ../common/compare_json.py "$targetJson" "$body" "serviceName") + res=$(python3 ../common/compare_json.py "$targetJson" "$body") if [ $res -ne 0 ]; then echo -e $RED" FAIL, returned body not correct"$ERED diff --git a/test/common/compare_json.py b/test/common/compare_json.py index 7110f480..44477d9e 100644 --- a/test/common/compare_json.py +++ b/test/common/compare_json.py @@ -15,50 +15,97 @@ # ============LICENSE_END================================================= # +# This script compare two jsons for eqaulity, taken into account that the parameter values +# marked with '????' are not checked (only the parameter name need to exist) +# Example of target json with '????' +# [ +# { +# "callbackUrl": "????", +# "keepAliveIntervalSeconds": "????", +# "serviceName": "serv2", +# "timeSinceLastActivitySeconds": "????" +# }, +# { +# "callbackUrl": "????", +# "keepAliveIntervalSeconds": "????", +# "serviceName": "serv1", +# "timeSinceLastActivitySeconds": "????" +# } +#] + + import os import json import sys -# Deep compare of two json obects -# If a parameter value in the target json is set to '????' then the result json value is not checked for the that parameter -# Any included json array will be sorted before comparison -# An optional array key can be given to sort array of objects containing that key +# # Helper function to compare two json list. +# # Returns true for equal, false for not equal +def compare_json_list(list1, list2): + if (list1.__len__() != list2.__len__()): + return False -def comparejson(jsonTarget,jsonResult,arrayKey): + for l in list1: + found = False + for m in list2: + res = compare_json_obj(l, m) + if (res): + found = True + break - if isinstance(jsonTarget, dict): - if (len(jsonTarget) != len(jsonResult)): - return 1 - for key in jsonTarget.keys(): - if (jsonResult.get(key) is None): - return 1 - if (comparejson(jsonTarget.get(key), jsonResult.get(key), arrayKey) != 0): - return 1 - elif isinstance(jsonTarget, list): - if (len(jsonTarget) != len(jsonResult)): - return 1 - if (arrayKey is None): - jsonTarget.sort() - jsonResult.sort() - else: - jsonTarget.sort(key=lambda k: k[arrayKey]) - jsonResult.sort(key=lambda k: k[arrayKey]) + if (not found): + return False - for i in range(len(jsonTarget)): - if (comparejson(jsonTarget[i], jsonResult[i], arrayKey) != 0): - return 1 + return True + +# Deep compare of two json obects +# If a parameter value in the target json is set to '????' then the result json value is not checked for the that parameter +# Return true for equal json, false for not equal json +def compare_json_obj(obj1, obj2): + if isinstance(obj1, list): + if (not isinstance(obj2, list)): + return False + return compare_json_list(obj1, obj2) + elif (isinstance(obj1, dict)): + if (not isinstance(obj2, dict)): + return False + exp = set(obj2.keys()) == set(obj1.keys()) + if (not exp): + return False + for k in obj1.keys(): + val1 = obj1.get(k) + val2 = obj2.get(k) + if isinstance(val1, list): + if (not compare_json_list(val1, val2)): + return False + elif isinstance(val1, dict): + if (not compare_json_obj(val1, val2)): + return False + else: + #Do not check parameter values marked with '????' + if ((val1 != "????") and (val2 != val1)) and ((val2 != "????") and (val2 != val1)): + return False else: - if (jsonTarget != "????") and (jsonTarget != jsonResult): - return 1 - return 0 + return obj1 == obj2 + + return True + try: + #Read the input file and compare the two json (target->result) jsonTarget = json.loads(sys.argv[1]) jsonResult = json.loads(sys.argv[2]) - arrayKey = None - if (len(sys.argv) > 3): - arrayKey = sys.argv[3] - print(comparejson(jsonTarget,jsonResult,arrayKey)) + res1=compare_json_obj(jsonTarget, jsonResult) + + #Read the json again (in case the previous calls has re-arranged the jsons) + jsonTarget = json.loads(sys.argv[1]) + jsonResult = json.loads(sys.argv[2]) + #Compare the opposite order (result->target) to catch special duplicate json key cases + res2=compare_json_obj(jsonResult, jsonTarget) + + if (res1 and res2): + print (0) + else: + print (1) except Exception as e: print (1) diff --git a/test/common/controller_api_functions.sh b/test/common/controller_api_functions.sh index ed298f16..25de2a95 100644 --- a/test/common/controller_api_functions.sh +++ b/test/common/controller_api_functions.sh @@ -62,7 +62,7 @@ __do_curl_to_controller() { fi body=${res:0:${#res}-3} echo "$body" > .sdnc-reply.json - res=$(python ../common/extract_sdnc_reply.py .sdnc-reply.json) + res=$(python3 ../common/extract_sdnc_reply.py .sdnc-reply.json) echo " EXTRACED BODY+CODE: "$res >> $HTTPLOG echo "$res" return 0 @@ -122,7 +122,7 @@ controller_api_get_A1_policy_ids() { echo " TARGET JSON: $targetJson" >> $HTTPLOG - res=$(python ../common/compare_json.py "$targetJson" "$body") + res=$(python3 ../common/compare_json.py "$targetJson" "$body") if [ $res -ne 0 ]; then echo -e $RED" FAIL, returned body not correct"$ERED @@ -178,7 +178,7 @@ controller_api_get_A1_policy_type() { targetJson=$(< $5) echo " TARGET JSON: $targetJson" >> $HTTPLOG - res=$(python ../common/compare_json.py "$targetJson" "$body") + res=$(python3 ../common/compare_json.py "$targetJson" "$body") if [ $res -ne 0 ]; then echo -e $RED" FAIL, returned body not correct"$ERED @@ -337,7 +337,7 @@ controller_api_get_A1_policy_status() { body=${res:0:${#res}-3} echo " TARGET JSON: $targetJson" >> $HTTPLOG - res=$(python ../common/compare_json.py "$targetJson" "$body") + res=$(python3 ../common/compare_json.py "$targetJson" "$body") if [ $res -ne 0 ]; then echo -e $RED" FAIL, returned body not correct"$ERED diff --git a/test/common/do_curl_function.sh b/test/common/do_curl_function.sh index e1d890d0..c4365d8b 100755 --- a/test/common/do_curl_function.sh +++ b/test/common/do_curl_function.sh @@ -25,9 +25,11 @@ # All calls made to 'localhost:'. # Expects env PORT set to intended port number # Expects env RESULT to contain the target response body. +# Optional env HTTPX shall contain protocol 'http' or 'https'. If not set, 'http' is used. For 'https' all cert errors are ignored # RESULT="*" means that returned payload is not checked, may container any text -# RESULT="" menans that the returned payload has to match the exactly +# RESULT="" means that the returned payload has to match the exactly # RESULT="json:" means that the returned json payload is compared with the expected result (order of json keys and index is irrelevant) +# RESULT="json-array-size:" means that the returned json payload shall contain the number of element given by the # Env BODY contains the response body after the call # Any error will stop script execution # How to use in a test script: source this file into your bash test script to the make the function available. @@ -39,7 +41,19 @@ do_curl() { echo "Exting test script....." exit 1 fi - curlstr="curl -X "$1" -sw %{http_code} localhost:$PORT$2 -H accept:*/*" + + if [ -z $HTTPX ]; then + if [ "$HTTPX" != "http" ] && [ "$HTTPX" != "https" ]; then + echo "Env var HTTPX shall be set to 'http' or 'https'" + echo "Exting test script....." + exit 1 + fi + PROT="http" + else + PROT=$HTTPX + fi + + curlstr="curl -X "$1" -skw %{http_code} ${PROT}://localhost:$PORT$2 -H accept:*/*" if [ $# -gt 3 ]; then curlstr=$curlstr" -H Content-Type:application/json --data-binary @"$4 fi @@ -70,6 +84,19 @@ do_curl() { echo "Exiting....." exit 1 fi + elif [[ "$RESULT" == "json-array-size:"* ]]; then + count=${RESULT:16:${#RESULT}} + #Find dir of the common dir + DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" + echo $body > .tmp.json + res=$(python ${DIR}/count_json_elements.py .tmp.json) + if [ $res -eq $count ]; then + echo " Body (array size) as expected" + else + echo " Expected json array size: "$count + echo "Exiting....." + exit 1 + fi else body="$(echo $body | tr -d '\n' )" if [ "$RESULT" == "$body" ]; then diff --git a/test/common/ricsimulator_api_functions.sh b/test/common/ricsimulator_api_functions.sh index 049e43db..f4cbc02e 100644 --- a/test/common/ricsimulator_api_functions.sh +++ b/test/common/ricsimulator_api_functions.sh @@ -58,7 +58,7 @@ sim_equal() { if [ $# -eq 3 ] || [ $# -eq 4 ]; then app=$1 port=$(__find_sim_port $app) - __var_test $app "$LOCALHOST$port/counter/" $2 "=" $3 $4 + __var_test $app "$RIC_SIM_LOCALHOST$port/counter/" $2 "=" $3 $4 return 0 else ((RES_CONF_FAIL++)) @@ -79,7 +79,7 @@ sim_print() { fi app=$1 port=$(__find_sim_port $app) - echo -e $BOLD"INFO(${BASH_LINENO[0]}): $app, $2 = $(__do_curl $LOCALHOST$port/counter/$2)"$EBOLD + echo -e $BOLD"INFO(${BASH_LINENO[0]}): $app, $2 = $(__do_curl $RIC_SIM_LOCALHOST$port/counter/$2)"$EBOLD } # Simulator API: Put a policy type in a ric @@ -95,7 +95,7 @@ sim_put_policy_type() { app=$2 res=$(__find_sim_port $app) - curlString="curl -X PUT -sw %{http_code} $LOCALHOST"$res"/policytype?id="$3" -H Content-Type:application/json --data-binary @"$4 + curlString="curl -X PUT -skw %{http_code} $RIC_SIM_LOCALHOST"$res"/policytype?id="$3" -H Content-Type:application/json --data-binary @"$4 __execute_curl_to_sim $1 "$curlString" $4 return $? @@ -114,7 +114,7 @@ sim_delete_policy_type() { app=$2 res=$(__find_sim_port $app) - curlString="curl -X DELETE -sw %{http_code} $LOCALHOST"$res"/policytype?id="$3 + curlString="curl -X DELETE -skw %{http_code} $RIC_SIM_LOCALHOST"$res"/policytype?id="$3 __execute_curl_to_sim $1 "$curlString" return $? @@ -133,7 +133,7 @@ sim_post_delete_instances() { app=$2 res=$(__find_sim_port $app) - curlString="curl -X POST -sw %{http_code} $LOCALHOST"$res"/deleteinstances" + curlString="curl -X POST -skw %{http_code} $RIC_SIM_LOCALHOST"$res"/deleteinstances" __execute_curl_to_sim $1 "$curlString" return $? @@ -152,7 +152,7 @@ sim_post_delete_all() { app=$2 res=$(__find_sim_port $app) - curlString="curl -X POST -sw %{http_code} $LOCALHOST"$res"/deleteall" + curlString="curl -X POST -skw %{http_code} $RIC_SIM_LOCALHOST"$res"/deleteall" __execute_curl_to_sim $1 "$curlString" return $? @@ -171,7 +171,7 @@ sim_post_forcedresponse() { app=$2 res=$(__find_sim_port $app) - curlString="curl -X POST -sw %{http_code} $LOCALHOST"$res"/forceresponse" + curlString="curl -X POST -skw %{http_code} $RIC_SIM_LOCALHOST"$res"/forceresponse" if [ $# -eq 3 ]; then curlString=$curlString"?code="$3 fi @@ -193,7 +193,7 @@ sim_post_forcedelay() { app=$2 res=$(__find_sim_port $app) - curlString="curl -X POST -sw %{http_code} $LOCALHOST$res/delay" + curlString="curl -X POST -skw %{http_code} $RIC_SIM_LOCALHOST$res/delay" if [ $# -eq 3 ]; then curlString=$curlString"?delay="$3 fi diff --git a/test/common/test_env.sh b/test/common/test_env.sh index 3bda6019..38839865 100755 --- a/test/common/test_env.sh +++ b/test/common/test_env.sh @@ -47,12 +47,23 @@ SDNC_A1_CONTROLLER_REMOTE_IMAGE="nexus3.o-ran-sc.org:10004/o-ran-sc/nonrtric-a1- SDNC_A1_CONTROLLER_REMOTE_IMAGE_TAG="1.7.4" -#SDNC DN remote image and tag +#SDNC DB remote image and tag SDNC_DB_REMOTE_IMAGE="mysql/mysql-server" SDNC_DB_REMOTE_IMAGE_TAG="5.6" #No local image for DB, remote image always used +# SDNC ONAP A1 Adapte remote image and tag +SDNC_ONAP_A1_ADAPTER_REMOTE_IMAGE="nexus3.onap.org:10003/onap/sdnc-image" +SDNC_ONAP_A1_ADAPTER_REMOTE_IMAGE_TAG="1.8-STAGING-latest" +#No local image for the A1 adapter, remote image always used + +#ONAP A1 Adatper remote image and tag +SDNC_ONAP_DB_REMOTE_IMAGE="mysql/mysql-server" +SDNC_ONAP_DB_REMOTE_IMAGE_TAG="5.6" +#No local image for DB, remote image always used + + # Near RT RIC Simulator local image and tag RIC_SIM_LOCAL_IMAGE="nexus3.o-ran-sc.org:10004/o-ran-sc/a1-simulator" RIC_SIM_LOCAL_IMAGE_TAG="latest" @@ -60,6 +71,9 @@ 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" @@ -89,11 +103,17 @@ export DOCKER_SIM_NWNAME="nonrtric-docker-net" # Name of docker export POLICY_AGENT_EXTERNAL_PORT=8081 # Policy Agent container external port (host -> container) export POLICY_AGENT_INTERNAL_PORT=8081 # Policy Agent container internal port (container -> container) +export POLICY_AGENT_EXTERNAL_SECURE_PORT=8433 # Policy Agent container external secure port (host -> container) +export POLICY_AGENT_INTERNAL_SECURE_PORT=8433 # Policy Agent container internal secure port (container -> container) + export POLICY_AGENT_APP_NAME="policy-agent" # Name for Policy Agent container POLICY_AGENT_LOGPATH="/var/log/policy-agent/application.log" # Path the application log in the Policy Agent container +export POLICY_AGENT_APP_NAME_ALIAS="policy-agent-container" # Alias name, name used by the control panel export MR_EXTERNAL_PORT=3905 # MR stub container external port (host -> container) export MR_INTERNAL_PORT=3905 # MR stub container internal port (container -> container) +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 CR_EXTERNAL_PORT=8090 # Callback receiver container external port (host -> container) @@ -114,7 +134,9 @@ export RIC_SIM_BASE="g" # Base name of t # Note, a prefix is added to each container name by the .env file in the 'ric' dir RIC_SIM_PREFIX="ricsim" # Prefix added to ric container name, added in the .env file in the 'ric' dir export RIC_SIM_INTERNAL_PORT=8085 # RIC Simulator container internal port (container -> container). - # (externl ports allocated by docker) + # (external ports allocated by docker) +export RIC_SIM_INTERNAL_SECURE_PORT=8185 # RIC Simulator container internal secure port (container -> container). + # (external ports allocated by docker) 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) @@ -123,13 +145,25 @@ export SDNC_DB_APP_NAME="sdnc-db" # Name of the SD 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_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_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_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 export CONTROL_PANEL_APP_NAME="control-panel" # Name of the Control Panel container export CONTROL_PANEL_EXTERNAL_PORT=8080 # Control Panel container external port (host -> container) export CONTROL_PANEL_INTERNAL_PORT=8080 # Control Panel container external port (host -> container) CONTROL_PANEL_LOGPATH="/logs/nonrtric-controlpanel.log" # Path the application log in the Control Panel container -RESTBASE="http://localhost:"$POLICY_AGENT_EXTERNAL_PORT # Base url to the R-APP interface +RESTBASE="http://localhost:"$POLICY_AGENT_EXTERNAL_PORT # Base url to the Agent NB REST interface +RESTBASE_SECURE="https://localhost:"$POLICY_AGENT_EXTERNAL_SECURE_PORT # Base url to the secure Agent NB REST interface DMAAPBASE="http://localhost:"$MR_EXTERNAL_PORT # Base url to the Dmaap adapter ADAPTER=$RESTBASE # Adapter holds the address the agent R-APP interface (REST OR DMAAP) # 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 088995fd..830ee733 100755 --- a/test/common/testcase_common.sh +++ b/test/common/testcase_common.sh @@ -20,6 +20,7 @@ # This is a script that contains all the functions needed for auto test # Arg: local|remote|remote-remove [auto-clean] + #Formatting for 'echo' cmd BOLD="\033[1m" EBOLD="\033[0m" @@ -29,6 +30,18 @@ GREEN="\033[32m\033[1m" EGREEN="\033[0m" YELLOW="\033[33m\033[1m" EYELLOW="\033[0m" +SAMELINE="\033[0K\r" + +tmp=$(which python3) +if [ $? -ne 0 ] || [ -z tmp ]; then + echo -e $RED"python3 is required to run the test environment, pls install"$ERED + exit 1 +fi +tmp=$(which docker) +if [ $? -ne 0 ] || [ -z tmp ]; then + echo -e $RED"docker is required to run the test environment, pls install"$ERED + exit 1 +fi # Just resetting any previous echo formatting... echo -ne $EBOLD$ERED$EGREEN @@ -46,6 +59,12 @@ G1_COUNT=0 G2_COUNT=0 G3_COUNT=0 +# Var 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 + #Localhost constant LOCALHOST="http://localhost:" @@ -209,6 +228,8 @@ __check_image_var " Callback Receiver" $1 "CR_IMAGE" "CR_LOCAL_IMAGE" "CR_LOCAL_ __check_image_var " Consul" $1 "CONSUL_IMAGE" "CONSUL_REMOTE_IMAGE" "CONSUL_REMOTE_IMAGE_TAG" __check_image_var " CBS" $1 "CBS_IMAGE" "CBS_REMOTE_IMAGE" "CBS_REMOTE_IMAGE_TAG" __check_image_var " SDNC DB" $1 "SDNC_DB_IMAGE" "SDNC_DB_REMOTE_IMAGE" "SDNC_DB_REMOTE_IMAGE_TAG" +__check_image_var " SDNC ONAP A1 Adapter" $1 "SDNC_ONAP_A1_ADAPTER_IMAGE" "SDNC_ONAP_A1_ADAPTER_REMOTE_IMAGE" "SDNC_ONAP_A1_ADAPTER_REMOTE_IMAGE_TAG" +__check_image_var " SDNC ONAP DB" $1 "SDNC_ONAP_DB_IMAGE" "SDNC_ONAP_DB_REMOTE_IMAGE" "SDNC_ONAP_DB_REMOTE_IMAGE_TAG" #Errors in image setting - exit if [ $IMAGE_ERR -ne 0 ]; then @@ -263,37 +284,40 @@ __check_and_pull_image() { fi elif [ $1 == "remote" ] || [ $1 == "remote-remove" ]; then if [ $1 == "remote-remove" ]; then - echo -ne " Attempt to stop and remove container(s), if running - \033[0K\r" + echo -ne " Attempt to stop and remove container(s), if running - ${SAMELINE}" tmp="$(docker ps -aq --filter name=${3})" if [ $? -eq 0 ] && [ ! -z "$tmp" ]; then - docker stop $tmp &> /dev/null + docker stop $tmp &> .dockererr if [ $? -ne 0 ]; then ((IMAGE_ERR++)) echo "" echo -e $RED" Container(s) could not be stopped - try manual stopping the container(s)"$ERED + cat .dockererr return 1 fi fi - echo -ne " Attempt to stop and remove container(s), if running - "$GREEN"stopped"$EGREEN"\033[0K\r" + echo -ne " Attempt to stop and remove container(s), if running - "$GREEN"stopped"$EGREEN"${SAMELINE}" tmp="$(docker ps -aq --filter name=${3})" &> /dev/null if [ $? -eq 0 ] && [ ! -z "$tmp" ]; then - docker rm $tmp &> /dev/null + docker rm $tmp &> .dockererr if [ $? -ne 0 ]; then ((IMAGE_ERR++)) echo "" echo -e $RED" Container(s) could not be removed - try manual removal of the container(s)"$ERED + cat .dockererr return 1 fi fi echo -e " Attempt to stop and remove container(s), if running - "$GREEN"stopped removed"$EGREEN - echo -ne " Removing image - \033[0K\r" + echo -ne " Removing image - ${SAMELINE}" tmp="$(docker images -q ${4})" &> /dev/null if [ $? -eq 0 ] && [ ! -z "$tmp" ]; then - docker rmi $4 &> /dev/null + docker rmi $4 &> .dockererr if [ $? -ne 0 ]; then ((IMAGE_ERR++)) echo "" echo -e $RED" Image could not be removed - try manual removal of the image"$ERED + cat .dockererr return 1 fi echo -e " Removing image - "$GREEN"removed"$EGREEN @@ -303,13 +327,14 @@ __check_and_pull_image() { tmp_im="" fi if [ -z "$tmp_im" ]; then - echo -ne " Pulling image\033[0K\r" - docker pull $4 > /dev/null + echo -ne " Pulling image${SAMELINE}" + docker pull $4 &> .dockererr tmp_im=$(docker images ${4} | grep -v REPOSITORY) if [ -z "$tmp_im" ]; then echo "" echo -e " Pulling image -$RED could not be pulled"$ERED ((IMAGE_ERR++)) + cat .dockererr return 1 fi echo -e " Pulling image -$GREEN Pulled $EGREEN" @@ -331,6 +356,8 @@ 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 # 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 @@ -354,23 +381,25 @@ curdir=$PWD cd $curdir cd ../mrstub echo " Building mrstub image: mrstub:latest" -docker build -t mrstub . &> /dev/null +docker build -t mrstub . &> .dockererr if [ $? -eq 0 ]; then echo -e $GREEN" Build Ok"$EGREEN else echo -e $RED" Build Failed"$ERED ((RES_CONF_FAIL++)) + cat .dockererr fi cd $curdir cd ../cr echo " Building Callback Receiver image: callback-receiver:latest" -docker build -t callback-receiver . &> /dev/null +docker build -t callback-receiver . &> .dockererr if [ $? -eq 0 ]; then echo -e $GREEN" Build Ok"$EGREEN else echo -e $RED" Build Failed"$ERED ((RES_CONF_FAIL++)) + cat .dockererr fi cd $curdir @@ -391,6 +420,8 @@ echo -e " Callback Receiver\t$(docker images --format $format_string $CR_IMAGE)" echo -e " Consul\t$(docker images --format $format_string $CONSUL_IMAGE)" >> $docker_tmp_file echo -e " CBS\t$(docker images --format $format_string $CBS_IMAGE)" >> $docker_tmp_file echo -e " SDNC DB\t$(docker images --format $format_string $SDNC_DB_IMAGE)" >> $docker_tmp_file +echo -e " SDNC ONAP A1 Adapter\t$(docker images --format $format_string $SDNC_ONAP_A1_ADAPTER_IMAGE)" >> $docker_tmp_file +echo -e " SDNC ONAP DB\t$(docker images --format $format_string $SDNC_ONAP_DB_IMAGE)" >> $docker_tmp_file column -t -s $'\t' $docker_tmp_file @@ -503,6 +534,8 @@ clean_containers() { "Control Panel " $CONTROL_PANEL_APP_NAME\ "SDNC A1 Controller " $SDNC_APP_NAME\ "SDNC DB " $SDNC_DB_APP_NAME\ + "SDNC ONAP A1 Adapter " $SDNC_ONAP_APP_NAME\ + "SDNC DB " $SDNC_ONAP_DB_APP_NAME\ "CBS " $CBS_APP_NAME\ "Consul " $CONSUL_APP_NAME) @@ -519,9 +552,9 @@ clean_containers() { for((w=${#CONTR}; w<$nw; w=w+1)); do CONTR="$CONTR " done - echo -ne " $APP: $CONTR - ${GREEN}stopping${EGREEN}\033[0K\r" + echo -ne " $APP: $CONTR - ${GREEN}stopping${EGREEN}${SAMELINE}" docker stop $(docker ps -qa --filter name=${CONTR}) &> /dev/null - echo -ne " $APP: $CONTR - ${GREEN}stopped${EGREEN}\033[0K\r" + echo -ne " $APP: $CONTR - ${GREEN}stopped${EGREEN}${SAMELINE}" docker rm $(docker ps -qa --filter name=${CONTR}) &> /dev/null echo -e " $APP: $CONTR - ${GREEN}stopped removed${EGREEN}" done @@ -555,11 +588,11 @@ sleep_wait() { start=$SECONDS duration=$((SECONDS-start)) while [ $duration -lt $1 ]; do - echo -ne " Slept for ${duration} seconds\033[0K\r" + echo -ne " Slept for ${duration} seconds${SAMELINE}" sleep 1 duration=$((SECONDS-start)) done - echo -ne " Slept for ${duration} seconds\033[0K\r" + echo -ne " Slept for ${duration} seconds${SAMELINE}" echo "" } @@ -590,12 +623,12 @@ __find_sim_port() { # Function to create the docker network for the test # Not to be called from the test script itself. __create_docker_network() { - tmp=$(docker network ls -q --filter name=$DOCKER_SIM_NWNAME) + tmp=$(docker network ls --format={{.Name}} --filter name=$DOCKER_SIM_NWNAME) if [ $? -ne 0 ]; then echo -e $RED" Could not check if docker network $DOCKER_SIM_NWNAME exists"$ERED return 1 fi - if [ -z tmp ]; then + if [ "$tmp" != $DOCKER_SIM_NWNAME ]; then echo -e "Creating docker network:$BOLD $DOCKER_SIM_NWNAME $EBOLD" docker network create $DOCKER_SIM_NWNAME if [ $? -ne 0 ]; then @@ -608,29 +641,35 @@ __create_docker_network() { } # Check if container is started by calling url on localhost using a port, expects response code 2XX -# args: +# args: https|https # Not to be called from the test script itself. __check_container_start() { - if [ $# -ne 3 ]; then + paramError=0 + if [ $# -ne 4 ]; then + paramError=1 + elif [ $4 != "http" ] && [ $4 != "https" ]; then + paramError=1 + fi + if [ $paramError -ne 0 ]; then ((RES_CONF_FAIL++)) - __print_err "need 3 args, " $@ + __print_err "need 3 args, https|https" $@ return 1 fi - echo -ne " Container $BOLD$1$EBOLD starting\033[0K\r" + echo -ne " Container $BOLD$1$EBOLD starting${SAMELINE}" appname=$1 localport=$2 url=$3 - pa_started=false + app_started=0 for i in {1..10}; do - if [ $(docker inspect --format '{{ .State.Running }}' $appname) ]; then + 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" - pa_started=true + app_started=1 break else sleep $i fi done - if ! [ $pa_started ]; then + if [ $app_started -eq 0 ]; then ((RES_CONF_FAIL++)) echo "" echo -e $RED" Container $BOLD${appname}$EBOLD could not be started"$ERED @@ -638,31 +677,35 @@ __check_container_start() { fi if [ $localport -eq 0 ]; then while [ $localport -eq 0 ]; do - echo -ne " Waiting for container ${appname} to publish its ports...\033[0K\r" + 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....\033[0K\r" + 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 pa_st=false - echo -ne " Waiting for container ${appname} service status...\033[0K\r" + echo -ne " Waiting for container ${appname} service status...${SAMELINE}" for i in {1..20}; do - result="$(__do_curl $LOCALHOST${localport}${url})" + if [ $4 == "https" ]; then + result="$(__do_curl "-k https://localhost:"${localport}${url})" + else + result="$(__do_curl $LOCALHOST${localport}${url})" + fi if [ $? -eq 0 ]; then if [ ${#result} -gt 15 ]; then #If response is too long, truncate result="...response text too long, omitted" fi - echo -ne " Waiting for container $BOLD${appname}$EBOLD service status, result: $result\033[0K\r" + echo -ne " Waiting for container $BOLD${appname}$EBOLD service status, result: $result${SAMELINE}" echo -ne " Container $BOLD${appname}$EBOLD$GREEN is alive$EGREEN, responds to service status:$GREEN $result $EGREEN" pa_st=true break else #echo " Retrying in $i seconds" - echo -ne " Waiting for container ${appname} service status...retrying in $i seconds\033[0K\r" + echo -ne " Waiting for container ${appname} service status...retrying in $i seconds${SAMELINE}" sleep $i fi done @@ -683,9 +726,9 @@ __check_container_start() { __start_container() { variableArgCount=$(($#-2)) - if [ $# -lt 5 ] && [ [ $(($variableArgCount%3)) -ne 0 ]; then + if [ $# -lt 6 ] && [ [ $(($variableArgCount%4)) -ne 0 ]; then ((RES_CONF_FAIL++)) - __print_err "need 5 or more args, NODOCKERARGS| [ ]*" $@ + __print_err "need 6 or more args, NODOCKERARGS| http|https [ http|https ]*" $@ exit 1 fi @@ -696,9 +739,17 @@ __start_container() { cd $1 if [ "$2" == "NODOCKERARGS" ]; then - docker-compose up -d &> /dev/null + docker-compose up -d &> .dockererr + if [ $? -ne 0 ]; then + echo -e $RED"Problem to launch container(s) with docker-compose"$ERED + cat .dockererr + fi else - docker-compose up -d $2 &> /dev/null + docker-compose up -d $2 &> .dockererr + if [ $? -ne 0 ]; then + echo -e $RED"Problem to launch container(s) with docker-compose"$ERED + cat .dockererr + fi fi shift; shift; @@ -707,9 +758,10 @@ __start_container() { app=$1; shift; port=$1; shift; url=$1; shift; - let cntr=cntr+3 + httpx=$1; shift; + let cntr=cntr+4 - __check_container_start "$app" "$port" "$url" + __check_container_start "$app" "$port" "$url" $httpx done cd $curdir @@ -752,7 +804,7 @@ consul_config_app() { targetJson=$(< $1) targetJson="{\"config\":"$targetJson"}" echo "TARGET JSON: $targetJson" >> $HTTPLOG - res=$(python ../common/compare_json.py "$targetJson" "$body") + res=$(python3 ../common/compare_json.py "$targetJson" "$body") if [ $res -ne 0 ]; then echo -e $RED" FAIL - policy json config read from consul/cbs is not equal to the intended json config...." $ERED ((RES_CONF_FAIL++)) @@ -767,7 +819,7 @@ consul_config_app() { } # Function to perpare the consul configuration according to the current simulator configuration -# args: SDNC|NOSDNC +# args: SDNC|SDNC_ONAP|NOSDNC # (Function for test scripts) prepare_consul_config() { echo -e $BOLD"Prepare Consul config"$EBOLD @@ -776,17 +828,19 @@ prepare_consul_config() { if [ $# != 2 ]; then ((RES_CONF_FAIL++)) - __print_err "need two args, SDNC|NOSDNC " $@ + __print_err "need two args, SDNC|SDNC_ONAP|NOSDNC " $@ exit 1 fi if [ $1 == "SDNC" ]; then echo -e " Config$BOLD including SDNC$EBOLD configuration" + elif [ $1 == "SDNC_ONAP" ]; then + echo -e " Config$BOLD including SDNC ONAP$EBOLD configuration" elif [ $1 == "NOSDNC" ]; then - echo -e " Config$BOLD excluding SDNC$EBOLD configuration" + echo -e " Config$BOLD excluding SDNC or SDNC ONAP$EBOLD configuration" else ((RES_CONF_FAIL++)) - __print_err "need two args, SDNC|NOSDNC " $@ + __print_err "need two args, SDNC|SDNC_ONAP|NOSDNC " $@ exit 1 fi @@ -801,6 +855,16 @@ prepare_consul_config() { config_json=$config_json"\n }" config_json=$config_json"\n ]," fi + if [ $1 == "SDNC_ONAP" ]; then + 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\"," + config_json=$config_json"\n \"userName\": \"$SDNC_ONAP_USER\"," + config_json=$config_json"\n \"password\": \"$SDNC_ONAP_PWD\"" + config_json=$config_json"\n }" + config_json=$config_json"\n ]," + fi config_json=$config_json"\n \"streams_publishes\": {" @@ -837,9 +901,11 @@ prepare_consul_config() { fi config_json=$config_json"\n {" config_json=$config_json"\n \"name\": \"$ric\"," - config_json=$config_json"\n \"baseUrl\": \"http://$ric:$RIC_SIM_INTERNAL_PORT\"," + config_json=$config_json"\n \"baseUrl\": \"$RIC_SIM_HTTPX://$ric:$RIC_SIM_PORT\"," if [ $1 == "SDNC" ]; then config_json=$config_json"\n \"controller\": \"$SDNC_APP_NAME\"," + elif [ $1 == "SDNC_ONAP" ]; then + config_json=$config_json"\n \"controller\": \"$SDNC_ONAP_APP_NAME\"," fi config_json=$config_json"\n \"managedElementIds\": [" config_json=$config_json"\n \"me1_$ric\"," @@ -866,14 +932,32 @@ start_consul_cbs() { echo -e $BOLD"Starting Consul and CBS"$EBOLD - __start_container consul_cbs NODOCKERARGS "$CONSUL_APP_NAME" "$CONSUL_EXTERNAL_PORT" "/ui/dc1/kv" \ - "$CBS_APP_NAME" "$CBS_EXTERNAL_PORT" "/healthcheck" + __start_container consul_cbs NODOCKERARGS "$CONSUL_APP_NAME" "$CONSUL_EXTERNAL_PORT" "/ui/dc1/kv" "http" \ + "$CBS_APP_NAME" "$CBS_EXTERNAL_PORT" "/healthcheck" "http" } ########################### ### RIC Simulator functions ########################### +use_simulator_http() { + echo -e "Using unsecure $BOLD http $EBOLD towards the simulators" + 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 + echo "" +} + +use_simulator_https() { + echo -e "Using secure $BOLD https $EBOLD towards the simulators" + export RIC_SIM_HTTPX="https" + export RIC_SIM_LOCALHOST=$RIC_SIM_HTTPX"://localhost:" + export RIC_SIM_PORT=$RIC_SIM_INTERNAL_SECURE_PORT + export RIC_SIM_CERT_MOUNT_DIR="./cert" + echo "" +} + # Start one group (ricsim_g1, ricsim_g2 or ricsim_g3) with a number of RIC Simulators using a given A interface # args: ricsim_g1|ricsim_g2|ricsim_g3 # (Function for test scripts) @@ -916,10 +1000,9 @@ start_ric_simulators() { while [ $cntr -le $2 ]; do app=$1"_"$cntr port=0 - app_data="$app_data $app $port /" + app_data="$app_data $app $port / "$RIC_SIM_HTTPX let cntr=cntr+1 done - __start_container ric "$docker_args" $app_data } @@ -935,7 +1018,7 @@ start_control_panel() { echo -e $BOLD"Starting Control Panel"$EBOLD - __start_container control_panel NODOCKERARGS $CONTROL_PANEL_APP_NAME $CONTROL_PANEL_EXTERNAL_PORT "/" + __start_container control_panel NODOCKERARGS $CONTROL_PANEL_APP_NAME $CONTROL_PANEL_EXTERNAL_PORT "/" "http" } @@ -950,10 +1033,58 @@ start_sdnc() { echo -e $BOLD"Starting SDNC A1 Controller"$EBOLD - __start_container sdnc NODOCKERARGS $SDNC_APP_NAME $SDNC_EXTERNAL_PORT "/apidoc/explorer" + __start_container sdnc NODOCKERARGS $SDNC_APP_NAME $SDNC_EXTERNAL_PORT "/apidoc/explorer" "http" } +####################### +### SDNC ONAP functions +####################### + +# Start the SDNC ONAP A1 Adapter +# args: - +# (Function for test scripts) +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" + +} + +# Configure the SDNC ONAP A1 Adapter +# args: - +# (Function for test scripts) +config_sdnc_onap() { + + echo -e $BOLD"Configuring SDNC ONAP A1 Adapter"$EBOLD + + LOCALFILE=".sdnc_onap.prop" + REMOTEFILE="/tmp/.sdnc_onap.prop" + + docker cp $SDNC_ONAP_APP_NAME:$SDNC_ONAP_PROPERTIES_FILE $LOCALFILE + if [ $? -ne 0 ]; then + echo -e $RED"Could not copy $SDNC_ONAP_PROPERTIES_FILE from $SDNC_ONAP_APP_NAME container"$ERED + 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. + + docker cp $LOCALFILE $SDNC_ONAP_APP_NAME:$REMOTEFILE + if [ $? -ne 0 ]; then + echo -e $RED"Could not copy local $LOCALFILE to $REMOTEFILE in $SDNC_ONAP_APP_NAME container"$ERED + exit 1 + fi + + docker exec -it $SDNC_ONAP_APP_NAME cp $REMOTEFILE $SDNC_ONAP_PROPERTIES_FILE + if [ $? -ne 0 ]; then + echo -e $RED"Could not copy $REMOTEFILE to $SDNC_ONAP_PROPERTIES_FILE in $SDNC_ONAP_APP_NAME container"$ERED + exit 1 + fi +} + ##################### ### MR stub functions ##################### @@ -964,8 +1095,8 @@ start_sdnc() { start_mr() { echo -e $BOLD"Starting Message Router 'mrstub'"$EBOLD - - __start_container mr NODOCKERARGS $MR_APP_NAME $MR_EXTERNAL_PORT "/" + export MR_CERT_MOUNT_DIR="./cert" + __start_container mr NODOCKERARGS $MR_APP_NAME $MR_EXTERNAL_PORT "/" "http" } @@ -980,7 +1111,7 @@ start_cr() { echo -e $BOLD"Starting Callback Receiver"$EBOLD - __start_container cr NODOCKERARGS $CR_APP_NAME $CR_EXTERNAL_PORT "/" + __start_container cr NODOCKERARGS $CR_APP_NAME $CR_EXTERNAL_PORT "/" "http" } @@ -995,19 +1126,28 @@ start_policy_agent() { echo -e $BOLD"Starting Policy Agent"$EBOLD - __start_container policy_agent NODOCKERARGS $POLICY_AGENT_APP_NAME $POLICY_AGENT_EXTERNAL_PORT "/status" + __start_container policy_agent NODOCKERARGS $POLICY_AGENT_APP_NAME $POLICY_AGENT_EXTERNAL_PORT "/status" "http" } # All calls to the agent will be directed to the agent REST interface from now on # args: - # (Function for test scripts) -use_agent_rest() { - echo -e $BOLD"Using agent REST interface"$EBOLD +use_agent_rest_http() { + echo -e $BOLD"Using agent REST interface with http"$EBOLD export ADAPTER=$RESTBASE echo "" } +# All calls to the agent will be directed to the agent REST interface from now on +# args: - +# (Function for test scripts) +use_agent_rest_https() { + echo -e $BOLD"Using agent REST interface with https"$EBOLD + export ADAPTER=$RESTBASE_SECURE + echo "" +} + # All calls to the agent will be directed to the agent dmaap interface from now on # args: - # (Function for test scripts) @@ -1112,7 +1252,9 @@ store_logs() { docker logs $CR_APP_NAME > $TESTLOGS/$ATC/$1_cr.log 2>&1 cp .httplog_${ATC}.txt $TESTLOGS/$ATC/$1_httplog_${ATC}.txt 2>&1 - docker exec -it $SDNC_APP_NAME cat /opt/opendaylight/data/log/karaf.log > $TESTLOGS/$ATC/$1_karaf.log 2>&1 + docker exec -it $SDNC_APP_NAME cat $SDNC_KARAF_LOG> $TESTLOGS/$ATC/$1_SDNC_karaf.log 2>&1 + + docker exec -it $SDNC_ONAP_APP_NAME cat $SDNC_ONAP_KARAF_LOG > $TESTLOGS/$ATC/$1_SDNC_ONAP_karaf.log 2>&1 rics=$(docker ps -f "name=$RIC_SIM_PREFIX" --format "{{.Names}}") for ric in $rics; do @@ -1190,10 +1332,10 @@ __var_test() { result="$(__do_curl $2$path)" retcode=$? echo "$result" > .tmp.curl.json - result=$(python ../common/count_json_elements.py ".tmp.curl.json") + result=$(python3 ../common/count_json_elements.py ".tmp.curl.json") fi duration=$((SECONDS-start)) - echo -ne " Result=${result} after ${duration} seconds\033[0K\r" + echo -ne " Result=${result} after ${duration} seconds${SAMELINE}" let ctr=ctr+1 if [ $retcode -ne 0 ]; then if [ $duration -gt $6 ]; then @@ -1204,25 +1346,25 @@ __var_test() { fi elif [ $4 = "=" ] && [ "$result" -eq $5 ]; then ((RES_PASS++)) - echo -e " Result=${result} after ${duration} seconds\033[0K\r" + echo -e " Result=${result} after ${duration} seconds${SAMELINE}" echo -e $GREEN" PASS${EGREEN} - Result=${result} after ${duration} seconds" #echo -e "---- \033[32m\033[1mPASS\033[0m - Test criteria met in ${duration} seconds ----" return elif [ $4 = ">" ] && [ "$result" -gt $5 ]; then ((RES_PASS++)) - echo -e " Result=${result} after ${duration} seconds\033[0K\r" + echo -e " Result=${result} after ${duration} seconds${SAMELINE}" echo -e $GREEN" PASS${EGREEN} - Result=${result} after ${duration} seconds" #echo -e "---- \033[32m\033[1mPASS\033[0m - Test criteria met in ${duration} seconds, result = ${result} ----" return elif [ $4 = "<" ] && [ "$result" -lt $5 ]; then ((RES_PASS++)) - echo -e " Result=${result} after ${duration} seconds\033[0K\r" + echo -e " Result=${result} after ${duration} seconds${SAMELINE}" echo -e $GREEN" PASS${EGREEN} - Result=${result} after ${duration} seconds" #echo -e "---- \033[32m\033[1mPASS\033[0m - Test criteria met in ${duration} seconds, result = ${result} ----" return elif [ $4 = "contain_str" ] && [[ $result =~ $5 ]]; then ((RES_PASS++)) - echo -e " Result=${result} after ${duration} seconds\033[0K\r" + echo -e " Result=${result} after ${duration} seconds${SAMELINE}" echo -e $GREEN" PASS${EGREEN} - Result=${result} after ${duration} seconds" #echo -e "---- \033[32m\033[1mPASS\033[0m - Test criteria met in ${duration} seconds, result = ${result} ----" return @@ -1253,7 +1395,7 @@ __var_test() { result="$(__do_curl $2$path)" retcode=$? echo "$result" > .tmp.curl.json - result=$(python ../common/count_json_elements.py ".tmp.curl.json") + result=$(python3 ../common/count_json_elements.py ".tmp.curl.json") fi if [ $retcode -ne 0 ]; then ((RES_FAIL++)) @@ -1331,7 +1473,7 @@ mr_equal() { # (Function for test scripts) mr_greater() { if [ $# -eq 2 ] || [ $# -eq 3 ]; then - __var_test "MR" "$LOCALHOST$MR_EXTERNAL_PORT/counter/" $1 "=" $2 $3 + __var_test "MR" "$LOCALHOST$MR_EXTERNAL_PORT/counter/" $1 ">" $2 $3 else ((RES_CONF_FAIL++)) __print_err "Wrong args to mr_greater, needs two or three args: [ timeout ]" $@ diff --git a/test/cr/.gitignore b/test/cr/.gitignore index 4512d6f1..4aa3a7ae 100644 --- a/test/cr/.gitignore +++ b/test/cr/.gitignore @@ -1 +1,2 @@ -.tmp.json \ No newline at end of file +.tmp.json +.dockererr \ No newline at end of file diff --git a/test/cr/cr.py b/test/cr/cr.py index 28e3b100..f65d7c0b 100644 --- a/test/cr/cr.py +++ b/test/cr/cr.py @@ -31,7 +31,7 @@ app = Flask(__name__) msg_callbacks={} # Server info -HOST_IP = "0.0.0.0" +HOST_IP = "::" HOST_PORT = 8090 # Metrics vars diff --git a/test/mrstub/.gitignore b/test/mrstub/.gitignore index 4512d6f1..4aa3a7ae 100644 --- a/test/mrstub/.gitignore +++ b/test/mrstub/.gitignore @@ -1 +1,2 @@ -.tmp.json \ No newline at end of file +.tmp.json +.dockererr \ No newline at end of file diff --git a/test/mrstub/Dockerfile b/test/mrstub/Dockerfile index f1d16b7b..ea867adc 100644 --- a/test/mrstub/Dockerfile +++ b/test/mrstub/Dockerfile @@ -15,14 +15,27 @@ # ============LICENSE_END================================================= # -FROM python:3.7 +#Dockerfile to create an image with both python3.8 and nodejs 14 +FROM python:3.8 WORKDIR /usr/src/app +#Install python modules COPY requirements.txt requirements.txt - RUN pip install -r requirements.txt +#Install nodejs and packages +RUN curl -sL https://deb.nodesource.com/setup_14.x | bash - +RUN apt-get install -y nodejs +COPY package.json package.json +RUN npm install express +RUN npm install express-http-proxy + +#Copy apps and start script COPY mr.py mr.py +COPY frontend.js frontend.js +COPY start.sh start.sh + +RUN chmod +x ./start.sh -CMD [ "python3", "-u", "./mr.py" ] \ No newline at end of file +CMD ["./start.sh"] \ No newline at end of file diff --git a/test/mrstub/README.md b/test/mrstub/README.md index 6a69930a..f6d0ddef 100644 --- a/test/mrstub/README.md +++ b/test/mrstub/README.md @@ -4,6 +4,32 @@ The mrstub is intended for function tests to simulate a message router. The mrstub exposes the read and write urls, used by the agent, as configured in consul. In addition, request messages can be fed to the mrstub and the response messages can be read by polling. +# Ports and certificates + +The MR normally opens the port 3905 for http. If a certificate and a key are provided the simulator will also open port 3906 for https. +The certificate and key shall be placed in the same dir and the dir shall be mounted to /usr/src/app/cert in the container. + +| Port | Protocol | +| -------- | ----- | +| 3905 | http | +| 3906 | https | + +The dir cert contains a self-signed cert. Use the script generate_cert_and_key.sh to generate a new certificate and key. The password of the certificate must be set 'test'. +The same urls are availables on both the http port 3905 and the https port 3906. If using curl and https, the flag -k shall be given to make curl ignore checking the certificate. + +### Message Router interface ### + +Messages from the MR can be read using this url using http(s) GET:
+```events/A1-POLICY-AGENT-READ/users/policy-agent?timeout=&limit=```
+Both 'timeout' and 'limit' are optional. +|Parameter|Description| +|---------|--------------------| +|limit|Optional parameter to limit the maximum number of messages to return. A value 0 < limit < 4096. If limit is not given, the limit is set to 4096.| +|timeout|Optional parameter to control the max length of the poll. A value in milliseconds 0 < timeout < 60000. If timeout is not given, the timeout is 10 seconds. If not messages are available when the poll starts, the poll will end as soon as there is at least one message available| + +Messages to the MR can be written using this url http(s) POST/PUT:
+```/events/A1-POLICY-AGENT-WRITE```
+One or more messages can be written in the same operation. ### Control interface ### @@ -35,13 +61,16 @@ There are a number of counters that can be read to monitor the message processin >Build image
```docker build -t mrstub .``` ->Start the image
+>Start the image on http only
```docker run -it -p 3905:3905 mrstub``` -The script ```mrstub-build-start.sh``` do the above two steps in one go. This starts the stub container in stand-alone mode for basic test.
If the mrstub should be executed manually with the agent, replace docker run with this command to connect to the docker network with the correct service name (--name shall be the same as configured in consul for the read and write streams). +>Start the image on http and https
+```docker run -it -p 3905:3905 -p 3906:3906 -v "/PATH_TO_CERT/cert:/usr/src/app/cert" mrstub``` + +The script ```mrstub-build-start.sh``` do the build and docker run in one go. This starts the stub container in stand-alone mode for basic test.
If the mrstub should be executed manually with the agent, replace docker run with this command to connect to the docker network with the correct service name (--name shall be the same as configured in consul for the read and write streams). ```docker run -it -p 3905:3905 --network nonrtric-docker-net --name message-router mrstub``` ### Basic test ### -Basic test is made with the script ```basic_test.sh``` which tests all the available urls with a subset of the possible operations. Use the script ```mrstub-build-start.sh``` to start the mrstub in a container first. \ No newline at end of file +Basic test is made with the script ```basic_test.sh nonsecure|secure``` which tests all the available urls with a subset of the possible operations. Choose nonsecure for http and secure for https. Use the script ```mrstub-build-start.sh``` to start the mrstub in a container first. \ No newline at end of file diff --git a/test/mrstub/basic_test.sh b/test/mrstub/basic_test.sh index 13ea3a60..577894d8 100755 --- a/test/mrstub/basic_test.sh +++ b/test/mrstub/basic_test.sh @@ -19,8 +19,27 @@ # Automated test script for mrstub container -# mr-stub port -export PORT=3905 +# Run the build_and_start with the same arg as this script +if [ $# -ne 1 ]; then + echo "Usage: ./basic_test nonsecure|secure" + exit 1 +fi +if [ "$1" != "nonsecure" ] && [ "$1" != "secure" ]; then + echo "Usage: ./basic_test nonsecure|secure" + exit 1 +fi + +if [ $1 == "nonsecure" ]; then + #Default http port for the simulator + PORT=3905 + # Set http protocol + HTTPX="http" +else + #Default https port for the mr-stub + PORT=3906 + # Set https protocol + HTTPX="https" +fi # source function to do curl and check result . ../common/do_curl_function.sh @@ -78,6 +97,53 @@ echo "=== Fetch a request ===" RESULT="json:[{\"apiVersion\":\"1.0\",\"operation\":\"GET\",\"correlationId\":\""$CORRID"\",\"originatorId\": \"849e6c6b420\",\"payload\":{},\"requestId\":\"23343221\", \"target\":\"policy-agent\", \"timestamp\":\"????\", \"type\":\"request\",\"url\":\"/test2\"}]" do_curl GET '/events/A1-POLICY-AGENT-READ/users/policy-agent' 200 +echo "=== Fetch a request, empty. Shall delay 10 seconds ===" +T1=$SECONDS +RESULT="json:[]" +do_curl GET '/events/A1-POLICY-AGENT-READ/users/policy-agent' 200 +T2=$SECONDS +if [ $(($T2-$T1)) -lt 10 ] || [ $(($T2-$T1)) -gt 15 ]; then + echo "Delay to short or too long"$(($T2-$T1))". Should be default 10 sec" + exit 1 +else + echo " Delay ok:"$(($T2-$T1)) +fi + +echo "=== Fetch a request, empty. Shall delay 5 seconds ===" +T1=$SECONDS +RESULT="json:[]" +do_curl GET '/events/A1-POLICY-AGENT-READ/users/policy-agent?timeout=5000' 200 +T2=$SECONDS +if [ $(($T2-$T1)) -lt 5 ] || [ $(($T2-$T1)) -gt 7 ]; then + echo "Delay to short or too long"$(($T2-$T1))". Should be 10 sec" + exit 1 +else + echo " Delay ok:"$(($T2-$T1)) +fi + +echo "=== Fetch a request with limit 25, shall be empty. ===" +RESULT="json-array-size:0" +do_curl GET '/events/A1-POLICY-AGENT-READ/users/policy-agent?timeout=1000&limit=25' 200 + +echo "=== Send 5 request to test limit on MR GET===" +RESULT="*" +for i in {1..5} +do + do_curl POST '/send-request?operation=GET&url=/test2' 200 +done + +echo "=== Fetch a request with limit 3. ===" +RESULT="json-array-size:3" +do_curl GET '/events/A1-POLICY-AGENT-READ/users/policy-agent?timeout=1000&limit=3' 200 + +echo "=== Fetch a request with limit 3, shall return 2. ===" +RESULT="json-array-size:2" +do_curl GET '/events/A1-POLICY-AGENT-READ/users/policy-agent?timeout=1000&limit=3' 200 + +echo "=== Fetch a request with limit 3, shall return 0. ===" +RESULT="json-array-size:0" +do_curl GET '/events/A1-POLICY-AGENT-READ/users/policy-agent?timeout=1000&limit=3' 200 + echo "=== Send a json response ===" # Create minimal accepted response message echo "[{\"correlationId\": \""$CORRID"\", \"message\": \"test2-response\", \"status\": \"200\"}]" > .tmp.json diff --git a/test/mrstub/cert/cert.crt b/test/mrstub/cert/cert.crt new file mode 100644 index 00000000..a24dfc49 --- /dev/null +++ b/test/mrstub/cert/cert.crt @@ -0,0 +1,16 @@ +-----BEGIN CERTIFICATE----- +MIICljCCAX4CCQCv7SV/aTc/YjANBgkqhkiG9w0BAQsFADANMQswCQYDVQQGEwJT +RTAeFw0yMDA1MDMwMDI0MzdaFw00NzA5MTgwMDI0MzdaMA0xCzAJBgNVBAYTAlNF +MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEApsGQcCv+Ce/+AbHx+3Wu +ujGtWF7uLX+/MahOHPfdXqidwG7OpmYnGkL06cA52P0BcZdc1hPGQbQdFJC8aW6U +5X9owRz9IRiwpzRhRqmMJfeqrLaqLL9K5MpCv+qsDzXu9ngRLJDk5CyeEfTjosEr +GWDywWahQKHChamdH701djFGwWGP3gttGvQoMnaSpzeyDKitBZql6bSxKkhWgFop +yxfU7qjbzOASLWaMx2r+MIJ88+AYDqYBTj649N534AYrIdjlQnvEKzGH0sOgHFYO +oaTTvmE/vRPlmbSX1U7mo/SvMWNPZkKUPDltyapOpBltfMiRJH4ndLOXJWRgmYha +SQIDAQABMA0GCSqGSIb3DQEBCwUAA4IBAQAdAwQpntpgUWUxCTk/Pw2+w5v+VxMM +K6QWhm9JdRn3XKQnKrFexVRso/x8TA8V50EUGwQwbnKApNXvJsV2jvbP/YwDsG2u +jBxs0DSspjDvbhUTkuWNYufQZIUGYMyccHap+CKD4rD2loMkmwbh5rII3SGEzUFE +rOY4VhqDjGCcILbChiY/QMA6Uyb6jLGxTARhgblWi9RWr9LuKv7raaUcnAIz1GO8 +z559kUnOKbsB46RZKRa0uIumz9qqXqxnVLWnIwT3DinpXsnzcPqNyyhTk6XR+W5o +0AuUCyT1WKlejrfMmmV6hRNHbT4x7cQrx4EjNf5hM00mN++F+QdGMa/G +-----END CERTIFICATE----- diff --git a/test/mrstub/cert/key.crt b/test/mrstub/cert/key.crt new file mode 100644 index 00000000..105ee75b --- /dev/null +++ b/test/mrstub/cert/key.crt @@ -0,0 +1,30 @@ +-----BEGIN ENCRYPTED PRIVATE KEY----- +MIIFHzBJBgkqhkiG9w0BBQ0wPDAbBgkqhkiG9w0BBQwwDgQIpz2Uxhl1+ZwCAggA +MB0GCWCGSAFlAwQBKgQQu1or54X1Bk5IMPGoDrdxkASCBNCBKcePejHXlG0fb2qt +TtQrpEr8UR60iFOaeUQ2Lc1zK0wzFCXAIXEWEcaozv75mJ5ReemkBMCyuzPJnoiM +LTeKuoUw8l48S9arB9l+/vVgUnMY0fm+QDsnPffkXKxC2kNwwFgGCT7tIGezuo/e +a9a5JJY707YEnkhUKWAQI2Oz/I95tbeYu64d/WtSN2OLu5JVLsCGAhV4cqcShjEb +pFlfgOHrT0z+qK7YXVR9P74qAZtGsH2ydUrtPtdvddKRpOAm4LzDNmox4Bs6e9nr +jY56sVRiHGhqeeqW04qRks5ReZF7zuwEgUSzGNlAcbbHn6FNJPOZKuN0e8KYexEM +y0G04rSNW8qppMsvez6txsou62CeIZ5LyAumwaJJYzwkob0nCmWYcZl5tSpkXZly +HsQKI2UlO3tiRKd057a46/kxcK85Pwav3Il+FaRXJkzl2rkU3DSy9SjaGL0ROD0U +1EaZCjeDdzN2GmqRQ1WhN5ivowQyWVf6H/mrxtkWZ3qLKmpa1JmvUgOybPcbqqQr +tqjj3Oj0zvLFZDqBjfIlTAAimXPgh6qLHH+qUGrI62pMpaldNZNy/swnpPuTX2sF +TUxFZvnGOmG3qHyvPm91+PypbdVSMb0PeB75XQFqWmajwnua7xfWrH8PLSijp5xQ +aLyiJ1jjFqXWE9D2v7JhB2BNCYlHxP98UI8kHxh7Fw5y0EKT5pCcbrg2nuLzMrCz +D4QaxZRuiIiPgy21kowk3WbHLYAjG7f9cIcbbX6Khc/3ulbB8xJ24WNRuzv4EHeh +TATHqk8nIgpkn1zmvPsKILdWzqZh70IlSctSzoIGzI6C2J76ycSZmcKtar2BZya9 +f1coUlFgXMvdmrf4bt4j2u/biA48OJaVlWBYVfIXUbliFTAQ8biRZFC2n3Xg+W8t +U2xqW14lZWBOIQFJp27foG6Z4JzyL2WZgQ0PWe0m0+tDaKA/LSWB2Qpwt4o2n0cb +RCs++c0eFCeOgErEfmmeburMhzQsfkUqpsL+J/ZMaRSiuTCpYM8qbz+KKT/Z6zbl +2cHWxSFRIqRKAMsj2a61IANjNIdwi2uBHZrWH1HMVVXAbGUJQFKZhxdpn5PBrXqg +vHRa9u0MQFCjs9NcQAGnBQDS6u+pUVO02WT4MvTker+hbu+f6NPU9FMLu+QbQUEP +SUdEZL4W9ZuBTdS3n/fTHEL8wKRB5yEW/CS5JuD+8YinZZXrsd3n3Oky05fdk6Bk +QH9cjMXdsd0Sb0Epw3CWGtXZ6YTHlVWqjdTNlOQdzQ7qfzktgcKujGwvQK0Mgd8x +nmG+f/HWMOss0JEL3ZR+K9Rr50u8/R+W5+e4VE57yw1fg9Jpq2/sVe2Pt8S7isFK +qDLoFZtF5RXi1O9KcA9BpnQX1ihPSC1RoY1pGXoF2D4KkV9U4/4j2qM6MGxjQ6lw +MN0qJ/N70Lti3YWqvYiTymLwVJr8FqoMQsV19MB8012Xd51Bvy6igddhrO83wuuV +b8PlUzl3Tl7yOviYqxiJ0xd8qw+Hs4+FkHbZIFJcUzTHVbb4SlPUE3wn6nrrIcfK +rT4wsYhK3afrlvK3ILi6kzzazS1dK+Hv9+mNozNf5u5nNBFQ+7MhtttzLWIaiV6D +ilLpOwcoO0X0qrzXKR7a+rQ/Dw== +-----END ENCRYPTED PRIVATE KEY----- diff --git a/test/mrstub/frontend.js b/test/mrstub/frontend.js new file mode 100644 index 00000000..7b08f752 --- /dev/null +++ b/test/mrstub/frontend.js @@ -0,0 +1,117 @@ +// ============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================================================= +// + +//This script acts like a proxy. All operations, except MR GET messages, are re-sent to the python backend server. +//The MR GET is intercepted and the python backend is polled until a message is available or up to a +//maximum time decided by a query parameter. No query parameter will result in a 10s long poll. + + +const proxy = require('express-http-proxy'); +const app = require('express')(); +const http = require('http'); +const https = require('https'); +const fs = require('fs'); +var privateKey; +var certificate; +var credentials; + +try { + privateKey = fs.readFileSync('cert/key.crt', 'utf8'); + certificate = fs.readFileSync('cert/cert.crt', 'utf8'); + credentials = {key: privateKey, + cert: certificate, + passphrase: 'test'}; +} catch(exp) { + console.log("Could not load cert and key") +} + +const httpPort=3905; +const httpsPort=3906; +const proxyport=2222 + +const sleep = (milliseconds) => { + return new Promise(resolve => setTimeout(resolve, milliseconds)) +} + +app.get("*/events/A1-POLICY-AGENT-READ/users/policy-agent*", inititate_long_poll); + +function inititate_long_poll(req,res) { + var millis=10000 //MR default is 10sec + var tmp=req.query.timeout + if (tmp != undefined) { + millis=parseInt(tmp); + millis=(millis < 0 ? 10000 : Math.min(millis, 60000)) //Max poll is 60 sec + console.log("Setting poll time to (ms): " + millis) + } + do_poll(req, res, req.url, Date.now()+millis) +} + +function do_poll(req,res, url, millis) { + const options = { + hostname: 'localhost', + port: proxyport, + path: url, + method: 'GET' + } + http.get(options, function(resp) { + let data = ''; + // Receiving chunk by chunk + resp.on('data', (chunk) => { + data += chunk; + }); + + // Full response received + resp.on('end', () => { + var payload=data.trim(); + if (resp.statusCode == 200 && payload.length == 2 && payload=="[]" && Date.now() { + do_poll(req,res, this.url, this.millis) + }) + } else { + //Eventually return the response + res.statusCode=resp.statusCode + res.header(resp.headers); + res.send(data) + return; + } + }); + }.bind({millis:millis, url:url})).on("error", (err) => { + console.log("Error when reading from backend: " + err.message); + res.statusCode=500 + res.send("ERROR detected in frontend: "+ err.message) + return + }); +} + +//Catch all, resend from proxy +app.use(proxy('localhost:'+proxyport, { + limit: '5mb', +})); + +//Start serving http +var httpServer = http.createServer(app); +var httpsServer; +console.log("Running on http: "+httpPort) +httpServer.listen(httpPort, "::"); + +//Start serving https if cert is available +if (credentials != undefined) { + httpsServer = https.createServer(credentials, app); + console.log("Running on https: "+httpsPort) + httpsServer.listen(httpsPort, "::"); +} diff --git a/test/mrstub/mr.py b/test/mrstub/mr.py index 45f8cfe5..1094e7c3 100644 --- a/test/mrstub/mr.py +++ b/test/mrstub/mr.py @@ -28,12 +28,12 @@ import traceback app = Flask(__name__) # list of messages to/from Dmaap -msg_requests={} +msg_requests=[] msg_responses={} # Server info -HOST_IP = "0.0.0.0" -HOST_PORT = 3905 +HOST_IP = "127.0.0.1" +HOST_PORT = 2222 # Metrics vars cntr_msg_requests_submitted=0 @@ -106,7 +106,7 @@ def sendrequest(): msg=create_message(oper, correlation_id, payload, url) print(msg) print(APP_WRITE_URL+" MSG(correlationid = "+correlation_id+"): " + json.dumps(json.loads(msg), indent=2)) - msg_requests[correlation_id]=msg + msg_requests.append(msg) cntr_msg_requests_submitted += 1 return Response(correlation_id, status=200, mimetype=MIME_TEXT) except Exception as e: @@ -151,15 +151,26 @@ def receiveresponse(): def events_read(): global msg_requests global cntr_msg_requests_fetched + + limit=request.args.get('limit') + if (limit is None): + limit=4096 + else: + limit=int(limit) + if (limit<0): + limit=0 + if (limit>4096): + limit=4096 + print("Limting number of returned messages to: "+str(limit)) try: msgs='' - for item in msg_requests: + cntr=0 + while(cntr0): if (len(msgs)>1): msgs=msgs+',' - msgs=msgs+msg_requests[item] + msgs=msgs+msg_requests.pop(0) cntr_msg_requests_fetched += 1 - - msg_requests={} + cntr=cntr+1 msgs='['+msgs+']' print(AGENT_READ_URL+" MSGs: "+json.dumps(json.loads(msgs), indent=2)) return Response(msgs, status=200, mimetype=MIME_JSON) @@ -255,7 +266,7 @@ def reset(): cntr_msg_requests_fetched=0 cntr_msg_responses_submitted=0 cntr_msg_responses_fetched=0 - msg_requests={} + msg_requests=[] msg_responses={} return Response('OK', status=200, mimetype=MIME_TEXT) diff --git a/test/mrstub/mrstub-build-start.sh b/test/mrstub/mrstub-build-start.sh index 1a463dc8..3e431167 100755 --- a/test/mrstub/mrstub-build-start.sh +++ b/test/mrstub/mrstub-build-start.sh @@ -21,4 +21,4 @@ docker build -t mrstub . -docker run -it -p 3905:3905 mrstub +docker run -it -p 3905:3905 -p 3906:3906 -v "$PWD/cert:/usr/src/app/cert" mrstub diff --git a/test/mrstub/package.json b/test/mrstub/package.json new file mode 100644 index 00000000..ab94945a --- /dev/null +++ b/test/mrstub/package.json @@ -0,0 +1,65 @@ +{ + "name": "app", + "version": "1.0.0", + "description": "", + "main": "frontend.js", + "dependencies": { + "accepts": "^1.3.7", + "array-flatten": "^3.0.0", + "body-parser": "^1.19.0", + "bytes": "^3.1.0", + "content-disposition": "^0.5.3", + "content-type": "^1.0.4", + "cookie": "^0.4.1", + "cookie-signature": "^1.1.0", + "debug": "^4.1.1", + "depd": "^2.0.0", + "destroy": "^1.0.4", + "ee-first": "^1.1.1", + "encodeurl": "^1.0.2", + "es6-promise": "^4.2.8", + "escape-html": "^1.0.3", + "etag": "^1.8.1", + "express": "^4.17.1", + "express-http-proxy": "^1.6.0", + "finalhandler": "^1.1.2", + "forwarded": "^0.1.2", + "fresh": "^0.5.2", + "http-errors": "^1.7.3", + "iconv-lite": "^0.5.1", + "inherits": "^2.0.4", + "ipaddr.js": "^1.9.1", + "media-typer": "^1.1.0", + "merge-descriptors": "^1.0.1", + "methods": "^1.1.2", + "mime": "^2.4.5", + "mime-db": "^1.44.0", + "mime-types": "^2.1.27", + "ms": "^2.1.2", + "negotiator": "^0.6.2", + "on-finished": "^2.3.0", + "parseurl": "^1.3.3", + "path-to-regexp": "^6.1.0", + "proxy-addr": "^2.0.6", + "qs": "^6.9.3", + "range-parser": "^1.2.1", + "raw-body": "^2.4.1", + "safe-buffer": "^5.2.0", + "safer-buffer": "^2.1.2", + "send": "^0.17.1", + "serve-static": "^1.14.1", + "setprototypeof": "^1.2.0", + "statuses": "^2.0.0", + "toidentifier": "^1.0.0", + "type-is": "^1.6.18", + "unpipe": "^1.0.0", + "utils-merge": "^1.0.1", + "vary": "^1.1.2" + }, + "devDependencies": {}, + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "", + "license": "ISC" +} diff --git a/test/mrstub/requirements.txt b/test/mrstub/requirements.txt index 1dabaa87..7c2c8e60 100644 --- a/test/mrstub/requirements.txt +++ b/test/mrstub/requirements.txt @@ -1,3 +1,5 @@ -Flask==1.1.1 +pip==20.1 +Flask==1.1.2 + diff --git a/test/mrstub/start.sh b/test/mrstub/start.sh new file mode 100644 index 00000000..3342bb83 --- /dev/null +++ b/test/mrstub/start.sh @@ -0,0 +1,21 @@ +#!/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================================================= +# + +nodejs frontend.js & +python3 -u ./mr.py \ No newline at end of file diff --git a/test/simulator-group/consul_cbs/.gitignore b/test/simulator-group/consul_cbs/.gitignore new file mode 100644 index 00000000..4aa3a7ae --- /dev/null +++ b/test/simulator-group/consul_cbs/.gitignore @@ -0,0 +1,2 @@ +.tmp.json +.dockererr \ No newline at end of file diff --git a/test/simulator-group/control_panel/.gitignore b/test/simulator-group/control_panel/.gitignore new file mode 100644 index 00000000..4aa3a7ae --- /dev/null +++ b/test/simulator-group/control_panel/.gitignore @@ -0,0 +1,2 @@ +.tmp.json +.dockererr \ No newline at end of file diff --git a/test/simulator-group/cr/.gitignore b/test/simulator-group/cr/.gitignore new file mode 100644 index 00000000..4aa3a7ae --- /dev/null +++ b/test/simulator-group/cr/.gitignore @@ -0,0 +1,2 @@ +.tmp.json +.dockererr \ No newline at end of file diff --git a/test/simulator-group/mr/.gitignore b/test/simulator-group/mr/.gitignore new file mode 100644 index 00000000..4aa3a7ae --- /dev/null +++ b/test/simulator-group/mr/.gitignore @@ -0,0 +1,2 @@ +.tmp.json +.dockererr \ No newline at end of file diff --git a/test/simulator-group/mr/cert/cert.crt b/test/simulator-group/mr/cert/cert.crt new file mode 100644 index 00000000..a24dfc49 --- /dev/null +++ b/test/simulator-group/mr/cert/cert.crt @@ -0,0 +1,16 @@ +-----BEGIN CERTIFICATE----- +MIICljCCAX4CCQCv7SV/aTc/YjANBgkqhkiG9w0BAQsFADANMQswCQYDVQQGEwJT +RTAeFw0yMDA1MDMwMDI0MzdaFw00NzA5MTgwMDI0MzdaMA0xCzAJBgNVBAYTAlNF +MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEApsGQcCv+Ce/+AbHx+3Wu +ujGtWF7uLX+/MahOHPfdXqidwG7OpmYnGkL06cA52P0BcZdc1hPGQbQdFJC8aW6U +5X9owRz9IRiwpzRhRqmMJfeqrLaqLL9K5MpCv+qsDzXu9ngRLJDk5CyeEfTjosEr +GWDywWahQKHChamdH701djFGwWGP3gttGvQoMnaSpzeyDKitBZql6bSxKkhWgFop +yxfU7qjbzOASLWaMx2r+MIJ88+AYDqYBTj649N534AYrIdjlQnvEKzGH0sOgHFYO +oaTTvmE/vRPlmbSX1U7mo/SvMWNPZkKUPDltyapOpBltfMiRJH4ndLOXJWRgmYha +SQIDAQABMA0GCSqGSIb3DQEBCwUAA4IBAQAdAwQpntpgUWUxCTk/Pw2+w5v+VxMM +K6QWhm9JdRn3XKQnKrFexVRso/x8TA8V50EUGwQwbnKApNXvJsV2jvbP/YwDsG2u +jBxs0DSspjDvbhUTkuWNYufQZIUGYMyccHap+CKD4rD2loMkmwbh5rII3SGEzUFE +rOY4VhqDjGCcILbChiY/QMA6Uyb6jLGxTARhgblWi9RWr9LuKv7raaUcnAIz1GO8 +z559kUnOKbsB46RZKRa0uIumz9qqXqxnVLWnIwT3DinpXsnzcPqNyyhTk6XR+W5o +0AuUCyT1WKlejrfMmmV6hRNHbT4x7cQrx4EjNf5hM00mN++F+QdGMa/G +-----END CERTIFICATE----- diff --git a/test/simulator-group/mr/cert/key.crt b/test/simulator-group/mr/cert/key.crt new file mode 100644 index 00000000..105ee75b --- /dev/null +++ b/test/simulator-group/mr/cert/key.crt @@ -0,0 +1,30 @@ +-----BEGIN ENCRYPTED PRIVATE KEY----- +MIIFHzBJBgkqhkiG9w0BBQ0wPDAbBgkqhkiG9w0BBQwwDgQIpz2Uxhl1+ZwCAggA +MB0GCWCGSAFlAwQBKgQQu1or54X1Bk5IMPGoDrdxkASCBNCBKcePejHXlG0fb2qt +TtQrpEr8UR60iFOaeUQ2Lc1zK0wzFCXAIXEWEcaozv75mJ5ReemkBMCyuzPJnoiM +LTeKuoUw8l48S9arB9l+/vVgUnMY0fm+QDsnPffkXKxC2kNwwFgGCT7tIGezuo/e +a9a5JJY707YEnkhUKWAQI2Oz/I95tbeYu64d/WtSN2OLu5JVLsCGAhV4cqcShjEb +pFlfgOHrT0z+qK7YXVR9P74qAZtGsH2ydUrtPtdvddKRpOAm4LzDNmox4Bs6e9nr +jY56sVRiHGhqeeqW04qRks5ReZF7zuwEgUSzGNlAcbbHn6FNJPOZKuN0e8KYexEM +y0G04rSNW8qppMsvez6txsou62CeIZ5LyAumwaJJYzwkob0nCmWYcZl5tSpkXZly +HsQKI2UlO3tiRKd057a46/kxcK85Pwav3Il+FaRXJkzl2rkU3DSy9SjaGL0ROD0U +1EaZCjeDdzN2GmqRQ1WhN5ivowQyWVf6H/mrxtkWZ3qLKmpa1JmvUgOybPcbqqQr +tqjj3Oj0zvLFZDqBjfIlTAAimXPgh6qLHH+qUGrI62pMpaldNZNy/swnpPuTX2sF +TUxFZvnGOmG3qHyvPm91+PypbdVSMb0PeB75XQFqWmajwnua7xfWrH8PLSijp5xQ +aLyiJ1jjFqXWE9D2v7JhB2BNCYlHxP98UI8kHxh7Fw5y0EKT5pCcbrg2nuLzMrCz +D4QaxZRuiIiPgy21kowk3WbHLYAjG7f9cIcbbX6Khc/3ulbB8xJ24WNRuzv4EHeh +TATHqk8nIgpkn1zmvPsKILdWzqZh70IlSctSzoIGzI6C2J76ycSZmcKtar2BZya9 +f1coUlFgXMvdmrf4bt4j2u/biA48OJaVlWBYVfIXUbliFTAQ8biRZFC2n3Xg+W8t +U2xqW14lZWBOIQFJp27foG6Z4JzyL2WZgQ0PWe0m0+tDaKA/LSWB2Qpwt4o2n0cb +RCs++c0eFCeOgErEfmmeburMhzQsfkUqpsL+J/ZMaRSiuTCpYM8qbz+KKT/Z6zbl +2cHWxSFRIqRKAMsj2a61IANjNIdwi2uBHZrWH1HMVVXAbGUJQFKZhxdpn5PBrXqg +vHRa9u0MQFCjs9NcQAGnBQDS6u+pUVO02WT4MvTker+hbu+f6NPU9FMLu+QbQUEP +SUdEZL4W9ZuBTdS3n/fTHEL8wKRB5yEW/CS5JuD+8YinZZXrsd3n3Oky05fdk6Bk +QH9cjMXdsd0Sb0Epw3CWGtXZ6YTHlVWqjdTNlOQdzQ7qfzktgcKujGwvQK0Mgd8x +nmG+f/HWMOss0JEL3ZR+K9Rr50u8/R+W5+e4VE57yw1fg9Jpq2/sVe2Pt8S7isFK +qDLoFZtF5RXi1O9KcA9BpnQX1ihPSC1RoY1pGXoF2D4KkV9U4/4j2qM6MGxjQ6lw +MN0qJ/N70Lti3YWqvYiTymLwVJr8FqoMQsV19MB8012Xd51Bvy6igddhrO83wuuV +b8PlUzl3Tl7yOviYqxiJ0xd8qw+Hs4+FkHbZIFJcUzTHVbb4SlPUE3wn6nrrIcfK +rT4wsYhK3afrlvK3ILi6kzzazS1dK+Hv9+mNozNf5u5nNBFQ+7MhtttzLWIaiV6D +ilLpOwcoO0X0qrzXKR7a+rQ/Dw== +-----END ENCRYPTED PRIVATE KEY----- diff --git a/test/simulator-group/mr/docker-compose.yml b/test/simulator-group/mr/docker-compose.yml index 887b2162..3a714538 100644 --- a/test/simulator-group/mr/docker-compose.yml +++ b/test/simulator-group/mr/docker-compose.yml @@ -28,3 +28,6 @@ services: image: ${MRSTUB_IMAGE} ports: - ${MR_EXTERNAL_PORT}:${MR_INTERNAL_PORT} + - ${MR_EXTERNAL_SECURE_PORT}:${MR_INTERNAL_SECURE_PORT} + volumes: + - ${MR_CERT_MOUNT_DIR}:/usr/src/app/cert:ro diff --git a/test/simulator-group/policy_agent/.gitignore b/test/simulator-group/policy_agent/.gitignore new file mode 100644 index 00000000..4aa3a7ae --- /dev/null +++ b/test/simulator-group/policy_agent/.gitignore @@ -0,0 +1,2 @@ +.tmp.json +.dockererr \ No newline at end of file diff --git a/test/simulator-group/policy_agent/docker-compose.yml b/test/simulator-group/policy_agent/docker-compose.yml index f349249c..506c7161 100644 --- a/test/simulator-group/policy_agent/docker-compose.yml +++ b/test/simulator-group/policy_agent/docker-compose.yml @@ -23,9 +23,12 @@ services: image: ${POLICY_AGENT_IMAGE} container_name: ${POLICY_AGENT_APP_NAME} networks: - - default + default: + aliases: + - ${POLICY_AGENT_APP_NAME_ALIAS} ports: - ${POLICY_AGENT_EXTERNAL_PORT}:${POLICY_AGENT_INTERNAL_PORT} + - ${POLICY_AGENT_EXTERNAL_SECURE_PORT}:${POLICY_AGENT_INTERNAL_SECURE_PORT} environment: - CONSUL_HOST=${CONSUL_HOST} - CONSUL_PORT=${CONSUL_INTERNAL_PORT} diff --git a/test/simulator-group/ric/.gitignore b/test/simulator-group/ric/.gitignore index 2eea525d..c0c4339a 100644 --- a/test/simulator-group/ric/.gitignore +++ b/test/simulator-group/ric/.gitignore @@ -1 +1,4 @@ -.env \ No newline at end of file +.tmp.json +.dockererr +.env +fakedir \ No newline at end of file diff --git a/test/simulator-group/ric/cert/cert.crt b/test/simulator-group/ric/cert/cert.crt new file mode 100644 index 00000000..51e37a79 --- /dev/null +++ b/test/simulator-group/ric/cert/cert.crt @@ -0,0 +1,16 @@ +-----BEGIN CERTIFICATE----- +MIICljCCAX4CCQDVlvlNzxH9FzANBgkqhkiG9w0BAQsFADANMQswCQYDVQQGEwJT +RTAeFw0yMDA0MjgxOTE2MTNaFw00NzA5MTMxOTE2MTNaMA0xCzAJBgNVBAYTAlNF +MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqpnXP5VmOvMPOTWaxWvm +zfSBRvnioEFHoriGld+pW+vvvrma9UiWfxX3GaGFItxuwbwLwqwvR2LDo6wQQpbl +SaNhg89DYD/NZvlRlLNcYOL218LjfFf4xaKVQGBHfT0Ts9JGTbTD/zcR2VS+3DUR +lvLzbNpQ+Rdvwls7wsL1ZblR+1lry9HMGKCrtsYDSOMSyGqE40u1bOYAw1+VMrfp +cK14u9toNPIbvk+HDP5yYnjC4FEp0ai07s3T6YDWHvp0WNIFJHCVFYzYQgS79/2b +8zg4H7ZMQ5XjxcenU6f8Q97nN0VMk46LIutGe/7rYO0uYKrHcJz1qUu1ui96zOVC +DQIDAQABMA0GCSqGSIb3DQEBCwUAA4IBAQBGvmFRHuUESpwijkekR0WFBuW6UNE5 +J7cZ9CXm7Mz06jeTAZWoCWVAZjYnpQ/MjvyzFglD9wL+A6LblIU+yNctYwtfspAq +xDYmBKlhsKzlgZ3fyBUlfrM5BFxZR2uu1/4bUU4geEQrI2rYzif3Flj0a55EIeSa +37fa7Acc+nNfy47mAa8Dsog6LHMs+FXGmuMS31c9lc70c9v4jCArctdDn/zKg9A7 +HCwd0+icgyDD+9U9eBhcFreBWyA1tPREWyx0qbhlw43OsVMpB6VM4exLGs/v1e0x +/Nmmsis1o54eu2cLGjr5EYlDmdFD3Dn458r0zFkxg4CE23lRUtFz8d6F +-----END CERTIFICATE----- diff --git a/test/simulator-group/ric/cert/key.crt b/test/simulator-group/ric/cert/key.crt new file mode 100644 index 00000000..380e145b --- /dev/null +++ b/test/simulator-group/ric/cert/key.crt @@ -0,0 +1,30 @@ +-----BEGIN ENCRYPTED PRIVATE KEY----- +MIIFHzBJBgkqhkiG9w0BBQ0wPDAbBgkqhkiG9w0BBQwwDgQIoefVgflG3OYCAggA +MB0GCWCGSAFlAwQBKgQQEaJvnbiOIkAwGcyqi6eYCQSCBNDnK9PT/NdGvZAriJAg +VYbqJiCxrqfrfRDAKU4Z4GWFnodzLt2+Xe6iEeOmCkCfs/oVaWx+yIMFzZKY2sq/ +jMmiihJggV+R+hIEXBsVnvqL/nqbchQ7ckhJK8ofXMcpdUdCd8CHylRPNmNNfMsu +o3BbDjKEdCtWMmBWuMWI3DtF0U5Tu5d+nH2ZHpl7YtA7U+N5w3nWBlxoPVXmqsEH +YE8cL0C/b+nFNs81FXKlbIPGNSv51c5YPjS0WQneci2Vj9JMPHWT6VMCaxVlv3js +droG6AxzHH+UpB1Lx4BfVunHR79nmhzmH9mo74rWCiYZ+Kh7DnC26WHrJW/tqJX8 +AvDPIEyVsQ8JQH7omBviVs6NCwoDCwS7jX0NUTy2aWgd4feI+BLwt9SDpEIzyQHt +YXZnwREd2ymDhS0ewvC4fjV82PJHc/yGBlNnXTh4er8hpUPjxTIuNZGaaWP7fcYP +qqPuyfTZvTkKtzHKYsrOk6Fq7M5kMGjFBrGWK3dCNptCXM/R8gaxRqcOvEOb9G5g +ISlC+TZy5T/EUZXJUJEK3gGMrQY4LYCxGm71Wnwe89zmC6bK/z/2XvNts867YKU+ +pODWHcxntJhwlzBRLL56dn2T0OhJEiynUMtpm45O3bHBtRkMjlQ5BhNic0Tog6fb +757gJnbnSNFB5mCSkB09iPt8LEEamQGYUGbXE+0mPTdqwaAaKbz4Gh1yV3T9alh+ +AxJu/YaB52mmf2KdFVUuPBVzSMawYvp6hXHIgzJ6tb/GmYFI7P21RBQfVR/fKuJx +pQMgRclNdYCAC0VCqHxSZdO0Lu7Sd/SWybCCNbfw+0tEO1fDlZwWbVQiF79AL62J +VvaWX3pX8IF227astnyMxkCH6MB4fvu7CSZKTYgdkXekP81Ck5ZxStRcSj4jOvYj +xuMqIvGzy16JRG1aGE1jpzunYBdDKiKKOIphH+jBK3NPk3b7wkTLxi7IkdS4MUf1 +e5E50W/Xx3wUlfyBvuc1TQy/1Moh+HvXIIG3JHU9MjfPkYwHvDITWIdXJb1vSEAE +opi+zNt7C5A+mC1/CC2MCjHk+g+cqpLcSFmv9MXnhg8bHmuhSjaXWChD8sj/S7H4 +Kazc87gikvQguxFv+bFiVQ6+GdPcGvsrnh+UFn/kfHUM8wt2AWnrKc8OLWXbs8Ge +0bCqXo1uy2sZEv558BGRKI35c/F4sovf0FLe8+M+UHPqOeYVaxSt9accXTHK2ajN +IEEKuL5v0BDNTQqo0uDw0HJyKW+L55UpJQ9nNSdVjtQUnPJtbWlVg0V2Q7mnVOSF +GRMqBtu+U9sejR03odkURjDFULntSw80M+U0LC+ceOrESLkO0AK2Yub1+IhR3OBh +jICv3eTZbqZ27ltZrsyDTAYoRVnTvPQwSZoUJ6cQS6XgLa3QitDcj+Zqch9z7sV2 +ydkEHEbLXPIt/sQyASluKm5j1tHJVtzwezb5GO54WYwdpy3MmZ3VhXsagJc9oLHX +MtsDGZR0hXMgzPp49leBhcieWW6fWXAZKt2oa64eI/12i2wSTjNsxPfsu45tJYXO +GAPL0OYBKeVLi1Pfa3kCLqlMDAyC4GzTScWXad5/FEeo189JU1aGcJn7Gn7Ao805 +wuOOs1TQk+KHvAFDEGkkJEM0lg== +-----END ENCRYPTED PRIVATE KEY----- diff --git a/test/simulator-group/ric/docker-compose.yml b/test/simulator-group/ric/docker-compose.yml index 17ef5aa4..fd8fc00d 100644 --- a/test/simulator-group/ric/docker-compose.yml +++ b/test/simulator-group/ric/docker-compose.yml @@ -29,22 +29,31 @@ services: networks: - default ports: - - ${RIC_SIM_INTERNAL_PORT}/tcp + - ${RIC_SIM_PORT}/tcp environment: - A1_VERSION=${G1_A1_VERSION} + - REMOTE_HOSTS_LOGGING=1 + volumes: + - ${RIC_SIM_CERT_MOUNT_DIR}:/usr/src/app/cert:ro g2: image: ${RIC_SIM_IMAGE} networks: - default ports: - - ${RIC_SIM_INTERNAL_PORT}/tcp + - ${RIC_SIM_PORT}/tcp environment: - A1_VERSION=${G2_A1_VERSION} + - REMOTE_HOSTS_LOGGING=1 + volumes: + - ${RIC_SIM_CERT_MOUNT_DIR}:/usr/src/app/cert:ro g3: image: ${RIC_SIM_IMAGE} networks: - default ports: - - ${RIC_SIM_INTERNAL_PORT}/tcp + - ${RIC_SIM_PORT}/tcp environment: - - A1_VERSION=${G3_A1_VERSION} \ No newline at end of file + - A1_VERSION=${G3_A1_VERSION} + - REMOTE_HOSTS_LOGGING=1 + volumes: + - ${RIC_SIM_CERT_MOUNT_DIR}:/usr/src/app/cert:ro \ No newline at end of file diff --git a/test/simulator-group/sdnc/.gitignore b/test/simulator-group/sdnc/.gitignore new file mode 100644 index 00000000..4aa3a7ae --- /dev/null +++ b/test/simulator-group/sdnc/.gitignore @@ -0,0 +1,2 @@ +.tmp.json +.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 new file mode 100644 index 00000000..0415d342 --- /dev/null +++ b/test/simulator-group/sdnc_onap/docker-compose.yml @@ -0,0 +1,65 @@ +# ================================================================================== +# Modifications Copyright (c) 2019 Nordix Foundation. +# +# 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. +# ================================================================================== +version: '2.1' + +networks: + default: + driver: bridge + name: ${DOCKER_SIM_NWNAME} + +services: + db: + image: ${SDNC_ONAP_DB_IMAGE} + container_name: ${SDNC_ONAP_DB_APP_NAME} + networks: + - default + ports: + - "3306" + environment: + - MYSQL_ROOT_PASSWORD=openECOMP1.0 + - MYSQL_ROOT_HOST=% + logging: + driver: "json-file" + options: + max-size: "30m" + max-file: "5" + + a1-controller: + image: ${SDNC_ONAP_A1_ADAPTER_IMAGE} + depends_on : + - db + container_name: ${SDNC_ONAP_APP_NAME} + networks: + - default + entrypoint: ["/opt/onap/sdnc/bin/startODL.sh"] + ports: + - ${SDNC_ONAP_EXTERNAL_PORT}:${SDNC_ONAP_INTERNAL_PORT} + links: + - db:dbhost + - db:sdnctldb01 + - db:sdnctldb02 + environment: + - MYSQL_ROOT_PASSWORD=openECOMP1.0 + - SDNC_CONFIG_DIR=/opt/onap/sdnc/data/properties + dns: + - ${DNS_IP_ADDR-10.0.100.1} + logging: + driver: "json-file" + options: + max-size: "30m" + max-file: "5" + extra_hosts: + aaf.osaaf.org: 10.12.6.214 diff --git a/test/simulator-group/sim-monitor.js b/test/simulator-group/sim-monitor.js index da71a9e3..76739f35 100644 --- a/test/simulator-group/sim-monitor.js +++ b/test/simulator-group/sim-monitor.js @@ -21,10 +21,14 @@ // Presents a web page on localhost:9999/mon var LOCALHOST="http://127.0.0.1:" +var LOCALHOSTSECURE="https://127.0.0.1:" +//This var may switch between LOCALHOST and LOCALHOSTSECURE +var SIM_LOCALHOST=LOCALHOST var MRSTUB_PORT="3905" var AGENT_PORT="8081" var CR_PORT="8090" var http = require('http'); +var https = require('https'); var express = require('express'); var app = express(); @@ -38,28 +42,37 @@ app.get("/",function(req, res){ }) //Get parameter valuue from other server -function getSimCtr(url, index, cb) { +function getSimCtr(httpx, url, index, cb) { var data = ''; - http.get(url, (resp) => { - // A chunk of data has been recieved. - resp.on('data', (chunk) => { - data += chunk; - }); - - // The whole response has been received. - resp.on('end', () => { - var code=resp.statusCode - if (code > 199 && code < 300) { - cb(data, index); - } else { - cb("not found", index); - } - }); + var http_type=http + if (httpx=="https") { + http_type=https + } + console.log("URL: "+ url + " - " + httpx) + try { + http_type.get(url, (resp) => { + // A chunk of data has been recieved. + resp.on('data', (chunk) => { + data += chunk; + }); + + // The whole response has been received. + resp.on('end', () => { + var code=resp.statusCode + if (code > 199 && code < 300) { + cb(data, index); + } else { + cb("not found", index); + } + }); - }).on("error", (err) => { - console.log("Error: " + err.message); - cb("no response", index); - }); + }).on("error", (err) => { + console.log("Error: " + err.message); + cb("no response", index); + }); + } catch(err) { + cb("no response", index); + } }; @@ -144,11 +157,17 @@ var simvar1=[] var simvar2=[] var simvar3=[] var simvar4=[] +var simvar5=[] //Counts the number of get request for the html page var getCtr=0 -var refreshInterval=2000 +var refreshInterval=4000 + +//Ignore self signed cert +process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = 0; + +var sim_http_type="http" function fetchAllMetrics() { setTimeout(() => { @@ -178,60 +197,84 @@ function fetchAllMetrics() { //Get metric values from the simulators for(var index=0;index"+padding("",55,"=")+"
" - + htmlStr=htmlStr+padding("Instances", 10," ")+"
" + htmlStr=htmlStr+padding("",55,"=")+"
" for(var simIndex=0;simIndex"; } + htmlStr=htmlStr+"
"; + htmlStr=htmlStr+padding("Near-RT RIC Simulator name", 35," ") + htmlStr=htmlStr+padding("Remote hosts", 50," ")+"
" + htmlStr=htmlStr+padding("",90,"=")+"
" + for(simIndex=0;simIndex"; + } + htmlStr=htmlStr+ "" + ""; -- 2.16.6