From bf3700b1064ec3526af205cab454bd1964ce8650 Mon Sep 17 00:00:00 2001 From: BjornMagnussonXA Date: Mon, 5 Oct 2020 08:39:40 +0200 Subject: [PATCH] Restructure test cases and upgraded test environment Issue-ID: NONRTRIC-290 Signed-off-by: BjornMagnussonXA Change-Id: Ifeba6c7a25030b86c6b163be3d2803d10613fc3d --- test/auto-test/DEMO.sh | 147 +++++ test/auto-test/FTC1.sh | 81 +-- test/auto-test/FTC10.sh | 7 +- test/auto-test/FTC100.sh | 84 +-- test/auto-test/FTC110.sh | 10 +- test/auto-test/FTC1100.sh | 76 +++ test/auto-test/FTC150.sh | 2 +- test/auto-test/FTC300.sh | 66 +-- test/auto-test/FTC310.sh | 2 +- test/auto-test/FTC350.sh | 12 +- test/auto-test/FTC800.sh | 54 +- test/auto-test/FTC810.sh | 2 +- test/auto-test/FTC850.sh | 37 +- test/auto-test/FTC900.sh | 2 +- .../demo-testdata/OSC/hw-agent-modified.json | 13 + .../auto-test/demo-testdata/OSC/pihw_template.json | 3 + .../demo-testdata/OSC/piqos_template.json | 9 + .../demo-testdata/OSC/pitsa_template.json | 3 + .../demo-testdata/OSC/qos-agent-modified.json | 40 ++ test/auto-test/demo-testdata/OSC/sim_hw.json | 18 + test/auto-test/demo-testdata/OSC/sim_qos.json | 45 ++ test/auto-test/demo-testdata/OSC/sim_tsa.json | 18 + .../demo-testdata/OSC/tsa-agent-modified.json | 13 + test/auto-test/demo-testdata/STD/pi1_template.json | 9 + test/common/README.md | 14 +- test/common/agent_api_functions.sh | 259 ++------- test/common/api_curl.sh | 223 ++++++++ test/common/ecs_api_functions.sh | 484 +++++++++++++++++ test/common/test_env.sh | 50 +- test/common/testcase_common.sh | 603 +++++++++++++-------- test/common/testsuite_common.sh | 7 +- test/simulator-group/.gitignore | 3 +- test/simulator-group/ecs/.gitignore | 2 + test/simulator-group/ecs/docker-compose.yml | 34 ++ test/simulator-group/sdnc_onap/.gitignore | 1 - test/simulator-group/sdnc_onap/docker-compose.yml | 63 --- 36 files changed, 1698 insertions(+), 798 deletions(-) create mode 100755 test/auto-test/DEMO.sh create mode 100755 test/auto-test/FTC1100.sh create mode 100644 test/auto-test/demo-testdata/OSC/hw-agent-modified.json create mode 100644 test/auto-test/demo-testdata/OSC/pihw_template.json create mode 100644 test/auto-test/demo-testdata/OSC/piqos_template.json create mode 100644 test/auto-test/demo-testdata/OSC/pitsa_template.json create mode 100644 test/auto-test/demo-testdata/OSC/qos-agent-modified.json create mode 100644 test/auto-test/demo-testdata/OSC/sim_hw.json create mode 100644 test/auto-test/demo-testdata/OSC/sim_qos.json create mode 100644 test/auto-test/demo-testdata/OSC/sim_tsa.json create mode 100644 test/auto-test/demo-testdata/OSC/tsa-agent-modified.json create mode 100644 test/auto-test/demo-testdata/STD/pi1_template.json create mode 100644 test/common/api_curl.sh create mode 100644 test/common/ecs_api_functions.sh create mode 100644 test/simulator-group/ecs/.gitignore create mode 100644 test/simulator-group/ecs/docker-compose.yml delete mode 100644 test/simulator-group/sdnc_onap/.gitignore delete mode 100644 test/simulator-group/sdnc_onap/docker-compose.yml diff --git a/test/auto-test/DEMO.sh b/test/auto-test/DEMO.sh new file mode 100755 index 00000000..7c0ba476 --- /dev/null +++ b/test/auto-test/DEMO.sh @@ -0,0 +1,147 @@ +#!/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="Preparation demo setup - populating a number of ric simulators with types and instances" + +#App names to exclude checking pulling images for, space separated list +EXCLUDED_IMAGES="ECS" + +. ../common/testcase_common.sh $@ +. ../common/agent_api_functions.sh +. ../common/ricsimulator_api_functions.sh + +#### TEST BEGIN #### + +#Local vars in test script +########################## +# Path to callback receiver +CR_PATH="http://$CR_APP_NAME:$CR_EXTERNAL_PORT/callbacks" +use_cr_http +use_agent_rest_http +use_sdnc_http +use_simulator_http + +clean_containers + +OSC_NUM_RICS=6 +STD_NUM_RICS=5 + +start_ric_simulators $RIC_SIM_PREFIX"_g1" $OSC_NUM_RICS OSC_2.1.0 + +start_ric_simulators $RIC_SIM_PREFIX"_g2" $STD_NUM_RICS STD_1.1.3 + +start_mr #Just to prevent errors in the agent log... + +start_control_panel + +CR_PATH="https://$CR_APP_NAME:$CR_EXTERNAL_SECURE_PORT/callbacks" +use_cr_http + +start_sdnc + +start_consul_cbs + +prepare_consul_config SDNC ".consul_config.json" +consul_config_app ".consul_config.json" + +start_policy_agent + +api_get_status 200 + +# Print the A1 version for OSC +for ((i=1; i<=$OSC_NUM_RICS; i++)) +do + sim_print $RIC_SIM_PREFIX"_g1_"$i interface +done + + +# Print the A1 version for STD +for ((i=1; i<=$STD_NUM_RICS; i++)) +do + sim_print $RIC_SIM_PREFIX"_g2_"$i interface +done + + +# Load the polictypes in osc +for ((i=1; i<=$OSC_NUM_RICS; i++)) +do + sim_put_policy_type 201 $RIC_SIM_PREFIX"_g1_"$i 100 demo-testdata/OSC/sim_qos.json + sim_put_policy_type 201 $RIC_SIM_PREFIX"_g1_"$i 20008 demo-testdata/OSC/sim_tsa.json +done + + +#Check the number of schemas and the individual schemas in OSC +api_equal json:policy_types 3 120 + +for ((i=1; i<=$OSC_NUM_RICS; i++)) +do + api_equal json:policy_types?ric=$RIC_SIM_PREFIX"_g1_"$i 2 120 +done + +# Check the schemas in OSC +for ((i=1; i<=$OSC_NUM_RICS; i++)) +do + api_get_policy_schema 200 100 demo-testdata/OSC/qos-agent-modified.json + api_get_policy_schema 200 20008 demo-testdata/OSC/tsa-agent-modified.json +done + + +# Create policies +use_agent_rest_http + +api_put_service 201 "Emergency-response-app" 0 "$CR_PATH/1" + +# Create policies in OSC +for ((i=1; i<=$OSC_NUM_RICS; i++)) +do + generate_uuid + api_put_policy 201 "Emergency-response-app" $RIC_SIM_PREFIX"_g1_"$i 100 $((3000+$i)) NOTRANSIENT demo-testdata/OSC/piqos_template.json 1 + generate_uuid + api_put_policy 201 "Emergency-response-app" $RIC_SIM_PREFIX"_g1_"$i 20008 $((4000+$i)) NOTRANSIENT demo-testdata/OSC/pitsa_template.json 1 +done + + +# Check the number of policies in OSC +for ((i=1; i<=$OSC_NUM_RICS; i++)) +do + sim_equal $RIC_SIM_PREFIX"_g1_"$i num_instances 2 +done + + +# Create policies in STD +for ((i=1; i<=$STD_NUM_RICS; i++)) +do + generate_uuid + api_put_policy 201 "Emergency-response-app" $RIC_SIM_PREFIX"_g2_"$i NOTYPE $((2100+$i)) NOTRANSIENT demo-testdata/STD/pi1_template.json 1 +done + + +# Check the number of policies in STD +for ((i=1; i<=$STD_NUM_RICS; i++)) +do + sim_equal $RIC_SIM_PREFIX"_g2_"$i num_instances 1 +done + +check_policy_agent_logs + +#### TEST COMPLETE #### + +store_logs END + +print_result diff --git a/test/auto-test/FTC1.sh b/test/auto-test/FTC1.sh index 413b22e4..39b6e6d5 100755 --- a/test/auto-test/FTC1.sh +++ b/test/auto-test/FTC1.sh @@ -21,7 +21,7 @@ TC_ONELINE_DESCR="Sanity test, create service and then create,update and delete a policy using http/https and Agent REST/DMAAP with/without SDNC controller" #App names to exclude checking pulling images for, space separated list -EXCLUDED_IMAGES="SDNC_ONAP" +EXCLUDED_IMAGES="ECS" . ../common/testcase_common.sh $@ . ../common/agent_api_functions.sh @@ -45,61 +45,49 @@ for __httpx in $TESTED_PROTOCOLS ; do echo "#####################################################################" echo "#####################################################################" - #Local vars in test script - ########################## if [ $__httpx == "HTTPS" ]; then - # Path to callback receiver CR_PATH="https://$CR_APP_NAME:$CR_EXTERNAL_SECURE_PORT/callbacks" use_cr_https + use_simulator_https + use_mr_https + if [[ $interface = *"SDNC"* ]]; then + use_sdnc_https + fi + if [[ $interface = *"DMAAP"* ]]; then + use_agent_dmaap_https + else + use_agent_rest_https + fi else - # Path to callback receiver CR_PATH="http://$CR_APP_NAME:$CR_EXTERNAL_PORT/callbacks" use_cr_http + use_simulator_http + use_mr_http + if [[ $interface = *"SDNC"* ]]; then + use_sdnc_http + fi + if [[ $interface = *"DMAAP"* ]]; then + use_agent_dmaap_http + else + use_agent_rest_http + fi fi # Clean container and start all needed containers # clean_containers - if [ $__httpx == "HTTPS" ]; then - #"Using secure ports towards simulators" - use_simulator_https - else - #"Using non-secure ports towards simulators" - use_simulator_http - fi - start_ric_simulators ricsim_g1 1 OSC_2.1.0 start_ric_simulators ricsim_g2 1 STD_1.1.3 start_mr - if [ $__httpx == "HTTPS" ]; then - #echo "Using secure ports between agent and MR" - use_mr_https - else - #"Using non-secure ports between agent and MR" - use_mr_http - fi - start_cr - if [ $interface == "REST+SDNC" ] || [ $interface == "DMAAP+SDNC" ]; then - - start_sdnc - - if [ $__httpx == "HTTPS" ]; then - # "Using secure ports towards SDNC" - use_sdnc_https - else - #"Using non-secure ports towards SDNC" - use_sdnc_http - fi - fi - start_consul_cbs - if [ $interface == "REST+SDNC" ] || [ $interface == "DMAAP+SDNC" ]; then + if [[ $interface = *"SDNC"* ]]; then + start_sdnc prepare_consul_config SDNC ".consul_config.json" else prepare_consul_config NOSDNC ".consul_config.json" @@ -113,25 +101,6 @@ for __httpx in $TESTED_PROTOCOLS ; do set_agent_debug - if [ $interface == "DMAAP" ] || [ $interface == "DMAAP+SDNC" ]; then - if [ $__httpx == "HTTPS" ]; then - echo "Using secure ports towards dmaap" - use_agent_dmaap_https - else - echo "Using non-secure ports towards dmaap" - use_agent_dmaap_http - fi - 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 @@ -189,7 +158,7 @@ for __httpx in $TESTED_PROTOCOLS ; do cr_equal received_callbacks 0 - if [ $interface == "DMAAP" ] || [ $interface == "DMAAP+SDNC" ]; then + if [[ $interface = *"DMAAP"* ]]; then VAL=11 # Number of Agent API calls over DMAAP mr_equal requests_fetched $VAL mr_equal responses_submitted $VAL @@ -200,7 +169,7 @@ for __httpx in $TESTED_PROTOCOLS ; do mr_equal requests_submitted 0 fi - if [ $interface == "REST+SDNC" ] || [ $interface == "DMAAP+SDNC" ]; then + if [[ $interface = *"SDNC"* ]]; then sim_contains_str ricsim_g1_1 remote_hosts "a1-controller" sim_contains_str ricsim_g2_1 remote_hosts "a1-controller" else diff --git a/test/auto-test/FTC10.sh b/test/auto-test/FTC10.sh index 2e627fc8..754260e1 100755 --- a/test/auto-test/FTC10.sh +++ b/test/auto-test/FTC10.sh @@ -20,7 +20,7 @@ TC_ONELINE_DESCR="Basic use case, register service, create/update policy, delete policy, de-register service using both STD and OSC interface while mixing REST and Dmaap" #App names to exclude checking pulling images for, space separated list -EXCLUDED_IMAGES="SDNC SDNC_ONAP" +EXCLUDED_IMAGES="SDNC ECS" . ../common/testcase_common.sh $@ . ../common/agent_api_functions.sh @@ -34,7 +34,12 @@ generate_uuid ########################## # Path to callback receiver CR_PATH="http://$CR_APP_NAME:$CR_EXTERNAL_PORT/callbacks" + use_cr_http +use_simulator_http +use_mr_http +use_agent_rest_http + clean_containers diff --git a/test/auto-test/FTC100.sh b/test/auto-test/FTC100.sh index 728252d0..929f3f2d 100755 --- a/test/auto-test/FTC100.sh +++ b/test/auto-test/FTC100.sh @@ -21,7 +21,7 @@ TC_ONELINE_DESCR="Full agent API walk through using agent REST/DMAAP and with/without SDNC A1 Controller" #App names to exclude checking pulling images for, space separated list -EXCLUDED_IMAGES="SDNC_ONAP" +EXCLUDED_IMAGES="ECS" . ../common/testcase_common.sh $@ . ../common/agent_api_functions.sh @@ -44,61 +44,48 @@ for __httpx in $TESTED_PROTOCOLS ; do echo "#####################################################################" echo "#####################################################################" - #Local vars in test script - ########################## - if [ $__httpx == "HTTPS" ]; then - # Path to callback receiver CR_PATH="https://$CR_APP_NAME:$CR_EXTERNAL_SECURE_PORT/callbacks" use_cr_https + use_simulator_https + use_mr_https + if [[ $interface = *"SDNC"* ]]; then + use_sdnc_https + fi + if [[ $interface = *"DMAAP"* ]]; then + use_agent_dmaap_https + else + use_agent_rest_https + fi else - # Path to callback receiver CR_PATH="http://$CR_APP_NAME:$CR_EXTERNAL_PORT/callbacks" use_cr_http + use_simulator_http + use_mr_http + if [[ $interface = *"SDNC"* ]]; then + use_sdnc_http + fi + if [[ $interface = *"DMAAP"* ]]; then + use_agent_dmaap_http + else + use_agent_rest_http + fi fi # Clean container and start all needed containers # clean_containers - if [ $__httpx == "HTTPS" ]; then - #"Using secure ports towards simulators" - use_simulator_https - else - #"Using non-secure ports towards simulators" - use_simulator_http - fi - start_ric_simulators ricsim_g1 1 OSC_2.1.0 start_ric_simulators ricsim_g2 1 STD_1.1.3 start_mr - if [ $__httpx == "HTTPS" ]; then - #echo "Using secure ports between agent and MR" - use_mr_https - else - #"Using non-secure ports between agent and MR" - use_mr_http - fi - start_cr - if [ $interface == "REST+SDNC" ] || [ $interface == "DMAAP+SDNC" ]; then - - start_sdnc - - if [ $__httpx == "HTTPS" ]; then - # "Using secure ports towards SDNC" - use_sdnc_https - else - #"Using non-secure ports towards SDNC" - use_sdnc_http - fi - fi - start_consul_cbs - if [ $interface == "REST+SDNC" ] || [ $interface == "DMAAP+SDNC" ]; then + if [[ $interface = *"SDNC"* ]]; then + start_sdnc prepare_consul_config SDNC ".consul_config.json" else prepare_consul_config NOSDNC ".consul_config.json" @@ -112,25 +99,6 @@ for __httpx in $TESTED_PROTOCOLS ; do set_agent_debug - if [ $interface == "DMAAP" ] || [ $interface == "DMAAP+SDNC" ]; then - if [ $__httpx == "HTTPS" ]; then - echo "Using secure ports towards dmaap" - use_agent_dmaap_https - else - echo "Using non-secure ports towards dmaap" - use_agent_dmaap_http - fi - else - if [ $__httpx == "HTTPS" ]; then - #"Using secure ports towards the agent" - use_agent_rest_https - else - #"Using non-secure ports towards the agent" - use_agent_rest_http - fi - fi - - cr_equal received_callbacks 0 mr_equal requests_submitted 0 @@ -148,8 +116,6 @@ for __httpx in $TESTED_PROTOCOLS ; do api_equal json:policy_ids 0 - - echo "############################################" echo "############## Health check ################" echo "############################################" @@ -388,7 +354,7 @@ for __httpx in $TESTED_PROTOCOLS ; do cr_equal received_callbacks 0 - if [ $interface == "DMAAP" ] || [ $interface == "DMAAP+SDNC" ]; then + if [[ $interface = *"DMAAP"* ]]; then mr_greater requests_submitted 0 VAL=$(mr_read requests_submitted) mr_equal requests_fetched $VAL @@ -400,7 +366,7 @@ for __httpx in $TESTED_PROTOCOLS ; do mr_equal requests_submitted 0 fi - if [ $interface == "REST+SDNC" ] || [ $interface == "DMAAP+SDNC" ]; then + if [[ $interface = *"SDNC"* ]]; then sim_contains_str ricsim_g1_1 remote_hosts "a1-controller" sim_contains_str ricsim_g2_1 remote_hosts "a1-controller" else diff --git a/test/auto-test/FTC110.sh b/test/auto-test/FTC110.sh index d6894b50..90b78270 100755 --- a/test/auto-test/FTC110.sh +++ b/test/auto-test/FTC110.sh @@ -21,7 +21,7 @@ TC_ONELINE_DESCR="Testing of service registration timeouts and keepalive" #App names to exclude checking pulling images for, space separated list -EXCLUDED_IMAGES="SDMC SDNC_ONAP" +EXCLUDED_IMAGES="SDNC ECS" . ../common/testcase_common.sh $@ . ../common/agent_api_functions.sh @@ -33,7 +33,11 @@ generate_uuid ########################## # Path to callback receiver CR_PATH="http://$CR_APP_NAME:$CR_EXTERNAL_PORT/callbacks" + use_cr_http +use_simulator_http +use_mr_http +use_agent_rest_http #### TEST BEGIN #### @@ -57,8 +61,6 @@ start_policy_agent set_agent_debug -use_agent_rest_http - #Verify no callbacks or dmaap messages has been sent cr_equal received_callbacks 0 mr_equal requests_submitted 0 @@ -187,7 +189,7 @@ sim_equal ricsim_g1_1 num_instances 0 api_get_service_ids 200 deviation "TR18 Agents sends callback with empty body" -cr_equal received_callbacks 0 +cr_equal received_callbacks 4 mr_equal requests_submitted 0 check_policy_agent_logs diff --git a/test/auto-test/FTC1100.sh b/test/auto-test/FTC1100.sh new file mode 100755 index 00000000..0d3371a8 --- /dev/null +++ b/test/auto-test/FTC1100.sh @@ -0,0 +1,76 @@ +#!/bin/bash + +# ============LICENSE_START=============================================== +# Copyright (C) 2020 Nordix Foundation. All rights reserved. +# ======================================================================== +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END================================================= +# + + +TC_ONELINE_DESCR="Experimental ECS test case" + +#App names to exclude checking pulling images for, space separated list +EXCLUDED_IMAGES="SDNC PA CP CR MR RICSIM CONSUL CBS" + +. ../common/testcase_common.sh $@ +. ../common/ecs_api_functions.sh + +#### TEST BEGIN #### + +clean_containers + +use_ecs_rest_https + +use_ecs_rest_https + +start_ecs + +set_ecs_debug + + + + +ecs_api_a1_get_job_ids 200 +ecs_api_a1_get_type 200 +ecs_api_a1_get_type_ids 200 +ecs_api_a1_get_job_status 200 +ecs_api_a1_get_job 200 +ecs_api_a1_delete_job 200 +ecs_api_a1_put_job 200 +ecs_api_edp_get_type_ids 200 +ecs_api_edp_get_producer_status 200 +ecs_api_edp_get_producer_ids 200 NOID +ecs_api_edp_get_type 200 +ecs_api_edp_get_producer 200 +ecs_api_edp_delete_producer 200 +ecs_api_edp_put_producer 200 +ecs_api_edp_get_producer_jobs 200 +ecs_api_sim_post_job_delete_error 200 +ecs_api_sim_get_producer_supervision 200 +ecs_api_sim_post_job_deleted 200 +ecs_api_get_producer_supervision_error 200 +ecs_api_sim_get_job_created_error 200 +ecs_api_sim_get_job_created 200 +ecs_api_service_status 200 + + + +store_logs END + +#### TEST COMPLETE #### + + +print_result + +auto_clean_containers diff --git a/test/auto-test/FTC150.sh b/test/auto-test/FTC150.sh index 3e13bf53..042765c8 100755 --- a/test/auto-test/FTC150.sh +++ b/test/auto-test/FTC150.sh @@ -21,7 +21,7 @@ TC_ONELINE_DESCR="Sample tests of the SDNC A1 controller restconf API using http/https (no agent)" #App names to exclude checking pulling images for, space separated list -EXCLUDED_IMAGES="PA CP SDNC_ONAP" +EXCLUDED_IMAGES="PA CP ECS" . ../common/testcase_common.sh $@ . ../common/controller_api_functions.sh diff --git a/test/auto-test/FTC300.sh b/test/auto-test/FTC300.sh index 13647c9f..9907dd67 100755 --- a/test/auto-test/FTC300.sh +++ b/test/auto-test/FTC300.sh @@ -20,7 +20,7 @@ TC_ONELINE_DESCR="Resync 10000 policies using OSC interface over REST" #App names to exclude checking pulling images for, space separated list -EXCLUDED_IMAGES="SDNC_ONAP" +EXCLUDED_IMAGES="ECS" . ../common/testcase_common.sh $@ . ../common/agent_api_functions.sh @@ -43,34 +43,37 @@ for __httpx in $TESTED_PROTOCOLS ; do echo "#####################################################################" echo "#####################################################################" - #Local vars in test script - ########################## - if [ $__httpx == "HTTPS" ]; then - # Path to callback receiver CR_PATH="https://$CR_APP_NAME:$CR_EXTERNAL_SECURE_PORT/callbacks" use_cr_https + use_simulator_https + use_mr_https + if [[ $interface = *"SDNC"* ]]; then + use_sdnc_https + fi + if [[ $interface = *"DMAAP"* ]]; then + use_agent_dmaap_https + else + use_agent_rest_https + fi else - # Path to callback receiver CR_PATH="http://$CR_APP_NAME:$CR_EXTERNAL_PORT/callbacks" use_cr_http + use_simulator_http + use_mr_http + if [[ $interface = *"SDNC"* ]]; then + use_sdnc_http + fi + if [[ $interface = *"DMAAP"* ]]; then + use_agent_dmaap_http + else + use_agent_rest_http + fi fi # Clean container and start all needed containers # clean_containers - if [ $__httpx == "HTTPS" ]; then - #echo "Using secure ports between agent and MR" - use_mr_https - echo "Using secure ports towards simulators" - use_simulator_https - else - #"Using non-secure ports between agent and MR" - use_mr_http - echo "Using non-secure ports towards simulators" - use_simulator_http - fi - start_ric_simulators ricsim_g1 4 OSC_2.1.0 start_ric_simulators ricsim_g2 4 STD_1.1.3 @@ -83,14 +86,7 @@ for __httpx in $TESTED_PROTOCOLS ; do if [[ $interface = *"SDNC"* ]]; then start_sdnc - if [ $__httpx == "HTTPS" ]; then - # "Using secure ports towards SDNC" - use_sdnc_https - else - #"Using non-secure ports towards SDNC" - use_sdnc_http - fi - prepare_consul_config SDNC ".consul_config.json" + prepare_consul_config SDNC ".consul_config.json" else prepare_consul_config NOSDNC ".consul_config.json" fi @@ -103,24 +99,6 @@ for __httpx in $TESTED_PROTOCOLS ; do set_agent_debug - if [[ $interface == *"DMAAP"* ]]; then - if [ $__httpx == "HTTPS" ]; then - echo "Using secure ports towards dmaap" - use_agent_dmaap_https - else - echo "Using non-secure ports towards dmaap" - use_agent_dmaap_http - fi - 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 - api_get_status 200 sim_print ricsim_g1_1 interface diff --git a/test/auto-test/FTC310.sh b/test/auto-test/FTC310.sh index 7eb3c19b..aa6c9e93 100755 --- a/test/auto-test/FTC310.sh +++ b/test/auto-test/FTC310.sh @@ -21,7 +21,7 @@ TC_ONELINE_DESCR="Resync of RIC via changes in the consul config" #App names to exclude checking pulling images for, space separated list -EXCLUDED_IMAGES="SDNC_ONAP" +EXCLUDED_IMAGES="ECS" . ../common/testcase_common.sh $@ . ../common/agent_api_functions.sh diff --git a/test/auto-test/FTC350.sh b/test/auto-test/FTC350.sh index 692d9b56..a4858a17 100755 --- a/test/auto-test/FTC350.sh +++ b/test/auto-test/FTC350.sh @@ -20,7 +20,7 @@ TC_ONELINE_DESCR="Change supported policy types and reconfigure rics" #App names to exclude checking pulling images for, space separated list -EXCLUDED_IMAGES="SDNC_ONAP" +EXCLUDED_IMAGES="ECS" . ../common/testcase_common.sh $@ . ../common/agent_api_functions.sh @@ -78,7 +78,6 @@ for interface in $TESTED_VARIANTS ; do start_ric_simulators ricsim_g1 $NUM_RICS OSC_2.1.0 if [[ $interface = *"SDNC"* ]]; then - start_sdnc prepare_consul_config SDNC ".consul_config_all.json" else prepare_consul_config NOSDNC ".consul_config_all.json" @@ -226,13 +225,13 @@ for interface in $TESTED_VARIANTS ; do ricsim_g1_7:me1_ricsim_g1_7,me2_ricsim_g1_7:3,4,5:???? \ ricsim_g1_8:me1_ricsim_g1_8,me2_ricsim_g1_8:4,5:???? " - sleep 120 + sleep_wait 120 api_equal json:policy_ids 0 api_get_policy_types 404 ricsim_g1_9 - sim_equal ricsim_g1_9 num_instances 1 + sim_equal ricsim_g1_9 num_instances 0 api_delete_policy 404 2000 @@ -264,7 +263,7 @@ for interface in $TESTED_VARIANTS ; do ricsim_g1_9:me1_ricsim_g1_9,me2_ricsim_g1_9:5:???? \ ricsim_g1_10:me1_ricsim_g1_10,me2_ricsim_g1_10:NOTYPE:???? " - sleep 120 + sleep_wait 120 api_equal json:policy_ids 0 @@ -276,7 +275,7 @@ for interface in $TESTED_VARIANTS ; do sim_delete_policy_type 204 ricsim_g1_6 4 sim_delete_policy_type 204 ricsim_g1_7 4 - sleep 120 + sleep_wait 120 api_equal json:policy_types?ric=ricsim_g1_1 1 120 api_equal json:policy_types?ric=ricsim_g1_2 2 120 @@ -319,6 +318,7 @@ for interface in $TESTED_VARIANTS ; do check_policy_agent_logs store_logs ${interface} + done diff --git a/test/auto-test/FTC800.sh b/test/auto-test/FTC800.sh index b1e9f53f..92af3966 100755 --- a/test/auto-test/FTC800.sh +++ b/test/auto-test/FTC800.sh @@ -20,7 +20,7 @@ TC_ONELINE_DESCR="Create 10000 policies in sequence using http/https and Agent REST/DMAAP with/without SDNC controller" #App names to exclude checking pulling images for, space separated list -EXCLUDED_IMAGES="SDNC_ONAP" +EXCLUDED_IMAGES="ECS" . ../common/testcase_common.sh $@ . ../common/agent_api_functions.sh @@ -49,17 +49,20 @@ for __httpx in $TESTED_PROTOCOLS ; do echo "#####################################################################" echo "#####################################################################" - #Local vars in test script - ########################## - if [ $__httpx == "HTTPS" ]; then # Path to callback receiver CR_PATH="https://$CR_APP_NAME:$CR_EXTERNAL_SECURE_PORT/callbacks" use_cr_https + use_simulator_https + use_mr_https + use_agent_rest_https else # Path to callback receiver CR_PATH="http://$CR_APP_NAME:$CR_EXTERNAL_PORT/callbacks" use_cr_http + use_simulator_http + use_mr_http + use_agent_rest_http fi # Policy instance start id @@ -67,50 +70,22 @@ for __httpx in $TESTED_PROTOCOLS ; do clean_containers - if [ $__httpx == "HTTPS" ]; then - #"Using secure ports towards simulators" - use_simulator_https - else - #"Using non-secure ports towards simulators" - use_simulator_http - fi - start_ric_simulators ricsim_g1 1 OSC_2.1.0 start_ric_simulators ricsim_g2 1 STD_1.1.3 start_mr - if [ $__httpx == "HTTPS" ]; then - #echo "Using secure ports between agent and MR" - use_mr_https - else - #"Using non-secure ports between agent and MR" - use_mr_http - fi - start_cr - if [ $interface == "SDNC" ]; then - + if [[ $interface == "SDNC" ]]; then start_sdnc - - if [ $__httpx == "HTTPS" ]; then - # "Using secure ports towards SDNC" - use_sdnc_https - else - #"Using non-secure ports towards SDNC" - use_sdnc_http - fi - fi - - start_consul_cbs - - if [ $interface == "SDNC" ]; then prepare_consul_config SDNC ".consul_config.json" else prepare_consul_config NOSDNC ".consul_config.json" fi + start_consul_cbs + consul_config_app ".consul_config.json" start_control_panel @@ -119,15 +94,6 @@ for __httpx in $TESTED_PROTOCOLS ; do set_agent_debug - if [ $__httpx == "HTTPS" ]; then - # "Using secure ports towards the agent" - use_agent_rest_https - else - # "Using non-secure ports towards the agent" - use_agent_rest_http - fi - - cr_equal received_callbacks 0 mr_equal requests_submitted 0 diff --git a/test/auto-test/FTC810.sh b/test/auto-test/FTC810.sh index 7fa5ea6e..460fb8ee 100755 --- a/test/auto-test/FTC810.sh +++ b/test/auto-test/FTC810.sh @@ -20,7 +20,7 @@ TC_ONELINE_DESCR="Repeatedly create and delete policies in each RICs for 24h (or configured number of days). Via agent REST/DMAAP/DMAAP_BATCH and SDNC using http or https" #App names to exclude checking pulling images for, space separated list -EXCLUDED_IMAGES="SDNC_ONAP" +EXCLUDED_IMAGES="ECS" . ../common/testcase_common.sh $@ . ../common/agent_api_functions.sh diff --git a/test/auto-test/FTC850.sh b/test/auto-test/FTC850.sh index b5c991c3..d6cc0013 100755 --- a/test/auto-test/FTC850.sh +++ b/test/auto-test/FTC850.sh @@ -20,7 +20,7 @@ TC_ONELINE_DESCR="Create/delete policies in parallel over a number of ric using a number of child process" #App names to exclude checking pulling images for, space separated list -EXCLUDED_IMAGES="SDNC_ONAP" +EXCLUDED_IMAGES="ECS" . ../common/testcase_common.sh $@ . ../common/agent_api_functions.sh @@ -51,32 +51,29 @@ for __httpx in $TESTED_PROTOCOLS ; do echo "#####################################################################" echo "#####################################################################" - #Local vars in test script - ########################## - if [ $__httpx == "HTTPS" ]; then - # Path to callback receiver CR_PATH="https://$CR_APP_NAME:$CR_EXTERNAL_SECURE_PORT/callbacks" use_cr_https + use_simulator_https + use_mr_https + if [[ $interface = *"SDNC"* ]]; then + use_sdnc_https + fi + use_agent_rest_https else - # Path to callback receiver CR_PATH="http://$CR_APP_NAME:$CR_EXTERNAL_PORT/callbacks" use_cr_http + use_simulator_http + use_mr_http + if [[ $interface = *"SDNC"* ]]; then + use_sdnc_http + fi + use_agent_rest_http fi # Clean container and start all needed containers # clean_containers - if [ $__httpx == "HTTPS" ]; then - echo "Using secure ports towards simulators and sdnc" - use_simulator_https - use_sdnc_https - else - echo "Using non-secure ports towards simulators and sdnc" - use_simulator_http - use_sdnc_http - fi - start_ric_simulators ricsim_g1 $NUM_RICS OSC_2.1.0 start_consul_cbs @@ -98,14 +95,6 @@ for __httpx in $TESTED_PROTOCOLS ; do set_agent_debug - 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 - api_get_status 200 for ((i=1; i<=$NUM_RICS; i++)) diff --git a/test/auto-test/FTC900.sh b/test/auto-test/FTC900.sh index c483504d..abe648b9 100755 --- a/test/auto-test/FTC900.sh +++ b/test/auto-test/FTC900.sh @@ -20,7 +20,7 @@ TC_ONELINE_DESCR="Preparation for test of the Control Panel and the Health Check app - populating a number of ric simulators with types and instances" #App names to exclude checking pulling images for, space separated list -EXCLUDED_IMAGES="SDNC SDNC_ONAP" +EXCLUDED_IMAGES="SDNC ECS" . ../common/testcase_common.sh $@ . ../common/agent_api_functions.sh diff --git a/test/auto-test/demo-testdata/OSC/hw-agent-modified.json b/test/auto-test/demo-testdata/OSC/hw-agent-modified.json new file mode 100644 index 00000000..5ea5802a --- /dev/null +++ b/test/auto-test/demo-testdata/OSC/hw-agent-modified.json @@ -0,0 +1,13 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "2", + "description": "Hello World policy type", + "type": "object", + "properties": { + "threshold": { + "type": "integer", + "default": 0 + } + }, + "additionalProperties": false + } \ No newline at end of file diff --git a/test/auto-test/demo-testdata/OSC/pihw_template.json b/test/auto-test/demo-testdata/OSC/pihw_template.json new file mode 100644 index 00000000..75749959 --- /dev/null +++ b/test/auto-test/demo-testdata/OSC/pihw_template.json @@ -0,0 +1,3 @@ +{ + "threshold": XXX +} \ No newline at end of file diff --git a/test/auto-test/demo-testdata/OSC/piqos_template.json b/test/auto-test/demo-testdata/OSC/piqos_template.json new file mode 100644 index 00000000..4446ac5b --- /dev/null +++ b/test/auto-test/demo-testdata/OSC/piqos_template.json @@ -0,0 +1,9 @@ +{ + "scope": { + "ueId": "0x349d230330ea60XXX", + "qosId": "4" + }, + "qosObjectives": { + "priorityLevel": 30 + } + } \ No newline at end of file diff --git a/test/auto-test/demo-testdata/OSC/pitsa_template.json b/test/auto-test/demo-testdata/OSC/pitsa_template.json new file mode 100644 index 00000000..75749959 --- /dev/null +++ b/test/auto-test/demo-testdata/OSC/pitsa_template.json @@ -0,0 +1,3 @@ +{ + "threshold": XXX +} \ No newline at end of file diff --git a/test/auto-test/demo-testdata/OSC/qos-agent-modified.json b/test/auto-test/demo-testdata/OSC/qos-agent-modified.json new file mode 100644 index 00000000..3a012cd8 --- /dev/null +++ b/test/auto-test/demo-testdata/OSC/qos-agent-modified.json @@ -0,0 +1,40 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "100", + "description": "Quality of Service policy type", + "type": "object", + "properties": { + "scope": { + "type": "object", + "properties": { + "ueId": { + "type": "string" + }, + "qosId": { + "type": "string" + } + }, + "additionalProperties": false, + "required": [ + "ueId", + "qosId" + ] + }, + "qosObjectives": { + "type": "object", + "properties": { + "priorityLevel": { + "type": "number" + } + }, + "additionalProperties": false, + "required": [ + "priorityLevel" + ] + } + }, + "additionalProperties": false, + "required": [ + "scope", "qosObjectives" + ] + } diff --git a/test/auto-test/demo-testdata/OSC/sim_hw.json b/test/auto-test/demo-testdata/OSC/sim_hw.json new file mode 100644 index 00000000..47e0ae05 --- /dev/null +++ b/test/auto-test/demo-testdata/OSC/sim_hw.json @@ -0,0 +1,18 @@ +{ + "name": "hwpolicy", + "description": "Hellow World policy type", + "policy_type_id": 2, + "create_schema": { + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "HW Policy", + "description": "Hello World policy type", + "type": "object", + "properties": { + "threshold": { + "type": "integer", + "default": 0 + } + }, + "additionalProperties": false + } + } \ No newline at end of file diff --git a/test/auto-test/demo-testdata/OSC/sim_qos.json b/test/auto-test/demo-testdata/OSC/sim_qos.json new file mode 100644 index 00000000..92eaa6ff --- /dev/null +++ b/test/auto-test/demo-testdata/OSC/sim_qos.json @@ -0,0 +1,45 @@ +{ + "name": "pt1", + "description": "pt1 policy type", + "policy_type_id": 100, + "create_schema": { + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "OSC_Type1_1.0.0", + "description": "Quality of Service policy type", + "type": "object", + "properties": { + "scope": { + "type": "object", + "properties": { + "ueId": { + "type": "string" + }, + "qosId": { + "type": "string" + } + }, + "additionalProperties": false, + "required": [ + "ueId", + "qosId" + ] + }, + "qosObjectives": { + "type": "object", + "properties": { + "priorityLevel": { + "type": "number" + } + }, + "additionalProperties": false, + "required": [ + "priorityLevel" + ] + } + }, + "additionalProperties": false, + "required": [ + "scope", "qosObjectives" + ] + } +} diff --git a/test/auto-test/demo-testdata/OSC/sim_tsa.json b/test/auto-test/demo-testdata/OSC/sim_tsa.json new file mode 100644 index 00000000..9227b5ea --- /dev/null +++ b/test/auto-test/demo-testdata/OSC/sim_tsa.json @@ -0,0 +1,18 @@ +{ + "name": "tsapolicy", + "description": "tsa parameters", + "policy_type_id": 20008, + "create_schema": { + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "TS Policy", + "description": "Traffic Steering - High prio traffic - policy type", + "type": "object", + "properties": { + "threshold": { + "type": "integer", + "default": 0 + } + }, + "additionalProperties": false + } +} \ No newline at end of file diff --git a/test/auto-test/demo-testdata/OSC/tsa-agent-modified.json b/test/auto-test/demo-testdata/OSC/tsa-agent-modified.json new file mode 100644 index 00000000..d9426c79 --- /dev/null +++ b/test/auto-test/demo-testdata/OSC/tsa-agent-modified.json @@ -0,0 +1,13 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "20008", + "description": "Traffic Steering - High prio traffic - policy type", + "type": "object", + "properties": { + "threshold": { + "type": "integer", + "default": 0 + } + }, + "additionalProperties": false + } \ No newline at end of file diff --git a/test/auto-test/demo-testdata/STD/pi1_template.json b/test/auto-test/demo-testdata/STD/pi1_template.json new file mode 100644 index 00000000..e06b0316 --- /dev/null +++ b/test/auto-test/demo-testdata/STD/pi1_template.json @@ -0,0 +1,9 @@ +{ + "scope": { + "ueId": "ueXXX", + "qosId": "qosXXX" + }, + "qosObjectives": { + "priorityLevel": XXX + } +} \ No newline at end of file diff --git a/test/common/README.md b/test/common/README.md index 09e8e220..b35966a3 100644 --- a/test/common/README.md +++ b/test/common/README.md @@ -159,7 +159,7 @@ Function to prepare a Consul config based on the previously configured (and star | parameter | description | | --------- | ----------- | -| `SDNC|SDNC_ONAP|NOSDNC` | Configure based on a1-controller (SNDC), a1-adapter (SDNC_ONAP) or without a controller/adapter (NOSDNC) | +| `SDNC|NOSDNC` | Configure based on a1-controller (SNDC) or without a controller/adapter (NOSDNC) | | `` | The path to the json output file containing the prepared config. This file is used in 'consul_config_app' | #### Function: start_consul_cbs #### @@ -216,18 +216,6 @@ Use https for all API calls towards the SDNC A1 Controller. Note that this funct |--| | None | -#### Function: start_sdnc_onap #### -Start the SDNC A1 Adapter container and its database container -| arg list | -|--| -| None | - -#### Function: config_sdnc_onap #### -Configure the SDNC A1 adapter - Not implemented -| arg list | -|--| -| None | - #### Function: start_mr #### Start the Message Router stub interface container | arg list | diff --git a/test/common/agent_api_functions.sh b/test/common/agent_api_functions.sh index 2091d65a..8ec8fdbc 100644 --- a/test/common/agent_api_functions.sh +++ b/test/common/agent_api_functions.sh @@ -21,196 +21,7 @@ ### API functiond towards the Policy Agent -# Generic function to query the agent via the REST or DMAAP interface. -# Used by all other agent api test functions -# If operation prefix is '_BATCH' the the send and get response is split in two sequences, -# one for sending the requests and one for receiving the response -# but only when using the DMAAP interface -# REST or DMAAP is controlled of the base url of $ADAPTER -# arg: (GET|PUT|POST|DELETE|GET_BATCH|PUT_BATCH|POST_BATCH|DELETE_BATCH []) | (RESPONSE ) -# (Not for test scripts) -__do_curl_to_agent() { - echo "(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG - paramError=0 - - if [ $# -lt 2 ] || [ $# -gt 3 ]; then - paramError=1 - else - timeout="" - oper="" - file='' - httpcode=" -sw %{http_code}" - accept='' - content='' - batch=0 - if [[ $1 == *"_BATCH" ]]; then - batch=1 - fi - if [ $# -gt 2 ]; then - content=" -H Content-Type:application/json" - fi - if [ $1 == "GET" ] || [ $1 == "GET_BATCH" ]; then - oper="GET" - if [ $# -ne 2 ]; then - paramError=1 - fi - elif [ $1 == "PUT" ] || [ $1 == "PUT_BATCH" ]; then - oper="PUT" - if [ $# -eq 3 ]; then - file=" --data-binary @$3" - fi - accept=" -H accept:application/json" - elif [ $1 == "POST" ] || [ $1 == "POST_BATCH" ]; then - oper="POST" - accept=" -H accept:*/*" - if [ $# -ne 2 ]; then - paramError=1 - fi - elif [ $1 == "DELETE" ] || [ $1 == "DELETE_BATCH" ]; then - oper="DELETE" - if [ $# -ne 2 ]; then - paramError=1 - fi - elif [ $1 == "RESPONSE" ]; then - oper="RESPONSE" - if [ $# -ne 2 ]; then - paramError=1 - fi - if [ $ADAPTER == $RESTBASE ] || [ $ADAPTER == $RESTBASE_SECURE ]; then - paramError=1 - fi - else - paramError=1 - fi - fi - - if [ $paramError -eq 1 ]; then - ((RES_CONF_FAIL++)) - echo "-Incorrect number of parameters to __do_curl_agent " $@ >> $HTTPLOG - echo "-Expected: (GET|PUT|POST|DELETE|GET_BATCH|PUT_BATCH|POST_BATCH|DELETE_BATCH []) | (RESPONSE ) []" >> $HTTPLOG - echo "-Returning response 000" >> $HTTPLOG - echo "-000" - return 1 - fi - - if [ $ADAPTER == $RESTBASE ] || [ $ADAPTER == $RESTBASE_SECURE ]; then - url=" "${ADAPTER}${2} - oper=" -X "$oper - curlString="curl -k "${oper}${timeout}${httpcode}${accept}${content}${url}${file} - echo " CMD: "$curlString >> $HTTPLOG - if [ $# -eq 3 ]; then - echo " FILE: $(<$3)" >> $HTTPLOG - fi - - # Do retry for configured response codes, otherwise only one attempt - maxretries=5 - while [ $maxretries -ge 0 ]; do - - let maxretries=maxretries-1 - res=$($curlString) - retcode=$? - if [ $retcode -ne 0 ]; then - echo " RETCODE: "$retcode >> $HTTPLOG - echo "000" - return 1 - fi - retry=0 - echo " RESP: "$res >> $HTTPLOG - status=${res:${#res}-3} - if [ ! -z "${AGENT_RETRY_CODES}" ]; then - for retrycode in $AGENT_RETRY_CODES; do - if [ $retrycode -eq $status ]; then - echo -e $RED" Retrying (according to set codes for retry), got status $status....."$ERED >> $HTTPLOG - sleep 1 - retry=1 - fi - done - fi - if [ $retry -eq 0 ]; then - maxretries=-1 - fi - done - echo $res - return 0 - else - if [ $oper != "RESPONSE" ]; then - requestUrl=$2 - if [ $1 == "PUT" ] && [ $# -eq 3 ]; then - payload="$(cat $3 | tr -d '\n' | tr -d ' ' )" - echo "payload: "$payload >> $HTTPLOG - file=" --data-binary "$payload - fi - #urlencode the request url since it will be carried by send-request url - requestUrl=$(python3 -c "from __future__ import print_function; import urllib.parse, sys; print(urllib.parse.quote(sys.argv[1]))" "$2") - url=" "${ADAPTER}"/send-request?url="${requestUrl}"&operation="${oper} - curlString="curl -k -X POST${timeout}${httpcode}${content}${url}${file}" - echo " CMD: "$curlString >> $HTTPLOG - res=$($curlString) - retcode=$? - if [ $retcode -ne 0 ]; then - echo " RETCODE: "$retcode >> $HTTPLOG - echo "000" - return 1 - fi - echo " RESP: "$res >> $HTTPLOG - status=${res:${#res}-3} - if [ $status -ne 200 ]; then - echo "000" - return 1 - fi - cid=${res:0:${#res}-3} - if [[ $batch -eq 1 ]]; then - echo $cid"200" - return 0 - fi - fi - if [ $oper == "RESPONSE" ] || [ $batch -eq 0 ]; then - if [ $oper == "RESPONSE" ]; then - cid=$2 - fi - url=" "${ADAPTER}"/receive-response?correlationid="${cid} - curlString="curl -k -X GET"${timeout}${httpcode}${url} - echo " CMD: "$curlString >> $HTTPLOG - res=$($curlString) - retcode=$? - if [ $retcode -ne 0 ]; then - echo " RETCODE: "$retcode >> $HTTPLOG - echo "000" - return 1 - fi - echo " RESP: "$res >> $HTTPLOG - status=${res:${#res}-3} - TS=$SECONDS - # wait of the reply from the agent... - while [ $status -eq 204 ]; do - if [ $(($SECONDS - $TS)) -gt 90 ]; then - echo " RETCODE: (timeout after 90s)" >> $HTTPLOG - echo "000" - return 1 - fi - sleep 0.01 - echo " CMD: "$curlString >> $HTTPLOG - res=$($curlString) - if [ $retcode -ne 0 ]; then - echo " RETCODE: "$retcode >> $HTTPLOG - echo "000" - return 1 - fi - echo " RESP: "$res >> $HTTPLOG - status=${res:${#res}-3} - done - if [ $status -eq 200 ]; then - body=${res:0:${#res}-3} - echo $body - return 0 - fi - echo "Status not 200, returning response 000" >> $HTTPLOG - echo "0000" - return 1 - fi - fi -} - +. ../common/api_curl.sh ######################################################### #### Test case functions A1 Policy management service @@ -274,7 +85,7 @@ api_get_policies() { fi query="/policies"$queryparams - res="$(__do_curl_to_agent GET $query)" + res="$(__do_curl_to_api PA GET $query)" status=${res:${#res}-3} if [ $status -ne $1 ]; then @@ -342,7 +153,7 @@ api_get_policy() { fi query="/policy?id=$UUID$2" - res="$(__do_curl_to_agent GET $query)" + res="$(__do_curl_to_api PA GET $query)" status=${res:${#res}-3} if [ $status -ne $1 ]; then @@ -410,11 +221,11 @@ api_put_policy() { file=".p.json" sed 's/XXX/'${pid}'/g' $7 > $file - res="$(__do_curl_to_agent PUT $query $file)" + res="$(__do_curl_to_api PA PUT $query $file)" status=${res:${#res}-3} - echo -ne " Creating "$count"("$max")${SAMELINE}" + echo -ne " Executing "$count"("$max")${SAMELINE}" if [ $status -ne $1 ]; then - echo " Created "$count"?("$max")" + echo " Executed "$count"?("$max")" echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED ((RES_FAIL++)) __check_stop_at_error @@ -423,7 +234,7 @@ api_put_policy() { let pid=$pid+1 let count=$count+1 - echo -ne " Created "$count"("$max")${SAMELINE}" + echo -ne " Executed "$count"("$max")${SAMELINE}" done echo "" @@ -469,9 +280,9 @@ api_put_policy_batch() { file=".p.json" sed 's/XXX/'${pid}'/g' $7 > $file - res="$(__do_curl_to_agent PUT_BATCH $query $file)" + res="$(__do_curl_to_api PA PUT_BATCH $query $file)" status=${res:${#res}-3} - echo -ne " Requested(batch) "$count"("$max")${SAMELINE}" + echo -ne " Requesting(batch) "$count"("$max")${SAMELINE}" if [ $status -ne 200 ]; then echo " Requested(batch) "$count"?("$max")" @@ -491,12 +302,12 @@ api_put_policy_batch() { count=0 for cid in $ARR; do - res="$(__do_curl_to_agent RESPONSE $cid)" + res="$(__do_curl_to_api PA RESPONSE $cid)" status=${res:${#res}-3} - echo -ne " Created(batch) "$count"("$max")${SAMELINE}" + echo -ne " Requesting(batch) "$count"("$max")${SAMELINE}" if [ $status -ne $1 ]; then - echo " Created(batch) "$count"?("$max")" + echo " Requested(batch) "$count"?("$max")" echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED ((RES_FAIL++)) __check_stop_at_error @@ -504,7 +315,7 @@ api_put_policy_batch() { fi let count=$count+1 - echo -ne " Created(batch) "$count"("$max")${SAMELINE}" + echo -ne " Requested(batch) "$count"("$max")${SAMELINE}" done echo "" @@ -591,7 +402,7 @@ api_put_policy_parallel() { fi done if [ -z $msg ]; then - echo " $(($count*$num_rics)) policies created/updated" + echo " $(($count*$num_rics)) policy request(s) executed" ((RES_PASS++)) echo -e $GREEN" PASS"$EGREEN return 0 @@ -627,12 +438,12 @@ api_delete_policy() { while [ $count -lt $max ]; do query="/policy?id="$UUID$pid - res="$(__do_curl_to_agent DELETE $query)" + res="$(__do_curl_to_api PA DELETE $query)" status=${res:${#res}-3} - echo -ne " Deleting "$count"("$max")${SAMELINE}" + echo -ne " Executing "$count"("$max")${SAMELINE}" if [ $status -ne $1 ]; then - echo " Deleted "$count"?("$max")" + echo " Executed "$count"?("$max")" echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED ((RES_FAIL++)) __check_stop_at_error @@ -640,7 +451,7 @@ api_delete_policy() { fi let pid=$pid+1 let count=$count+1 - echo -ne " Deleted "$count"("$max")${SAMELINE}" + echo -ne " Executed "$count"("$max")${SAMELINE}" done echo "" @@ -673,9 +484,9 @@ api_delete_policy_batch() { ARR="" while [ $count -lt $max ]; do query="/policy?id="$UUID$pid - res="$(__do_curl_to_agent DELETE_BATCH $query)" + res="$(__do_curl_to_api PA DELETE_BATCH $query)" status=${res:${#res}-3} - echo -ne " Requested(batch) "$count"("$max")${SAMELINE}" + echo -ne " Requesting(batch) "$count"("$max")${SAMELINE}" if [ $status -ne 200 ]; then echo " Requested(batch) "$count"?("$max")" @@ -696,7 +507,7 @@ api_delete_policy_batch() { count=0 for cid in $ARR; do - res="$(__do_curl_to_agent RESPONSE $cid)" + res="$(__do_curl_to_api PA RESPONSE $cid)" status=${res:${#res}-3} echo -ne " Deleted(batch) "$count"("$max")${SAMELINE}" @@ -778,7 +589,7 @@ api_delete_policy_parallel() { fi done if [ -z $msg ]; then - echo " $(($count*$num_rics)) deleted" + echo " $(($count*$num_rics)) policy request(s) executed" ((RES_PASS++)) echo -e $GREEN" PASS"$EGREEN return 0 @@ -825,7 +636,7 @@ api_get_policy_ids() { fi query="/policy_ids"$queryparams - res="$(__do_curl_to_agent GET $query)" + res="$(__do_curl_to_api PA GET $query)" status=${res:${#res}-3} if [ $status -ne $1 ]; then @@ -879,7 +690,7 @@ api_get_policy_schema() { fi query="/policy_schema?id=$2" - res="$(__do_curl_to_agent GET $query)" + res="$(__do_curl_to_api PA GET $query)" status=${res:${#res}-3} if [ $status -ne $1 ]; then @@ -928,7 +739,7 @@ api_get_policy_schemas() { query=$query"?ric="$2 fi - res="$(__do_curl_to_agent GET $query)" + res="$(__do_curl_to_api PA GET $query)" status=${res:${#res}-3} if [ $status -ne $1 ]; then @@ -1003,7 +814,7 @@ api_get_policy_status() { query="/policy_status?id="$UUID$2 - res="$(__do_curl_to_agent GET $query)" + res="$(__do_curl_to_api PA GET $query)" status=${res:${#res}-3} if [ $status -ne $1 ]; then @@ -1050,7 +861,7 @@ api_get_policy_types() { query="/policy_types?ric=$2" fi - res="$(__do_curl_to_agent GET $query)" + res="$(__do_curl_to_api PA GET $query)" status=${res:${#res}-3} if [ $status -ne $1 ]; then @@ -1107,7 +918,7 @@ api_get_status() { return 1 fi query="/status" - res="$(__do_curl_to_agent GET $query)" + res="$(__do_curl_to_api PA GET $query)" status=${res:${#res}-3} if [ $status -ne $1 ]; then @@ -1140,7 +951,7 @@ api_get_ric() { query="/ric?managedElementId="$2 - res="$(__do_curl_to_agent GET $query)" + res="$(__do_curl_to_api PA GET $query)" status=${res:${#res}-3} if [ $status -ne $1 ]; then @@ -1185,7 +996,7 @@ api_get_rics() { query="/rics?policyType="$2 fi - res="$(__do_curl_to_agent GET $query)" + res="$(__do_curl_to_api PA GET $query)" status=${res:${#res}-3} if [ $status -ne $1 ]; then @@ -1242,7 +1053,7 @@ api_put_service() { file=".tmp.json" echo "$json" > $file - res="$(__do_curl_to_agent PUT $query $file)" + res="$(__do_curl_to_api PA PUT $query $file)" status=${res:${#res}-3} if [ $status -ne $1 ]; then @@ -1290,7 +1101,7 @@ api_get_services() { query="/services?name="$2 fi - res="$(__do_curl_to_agent GET $query)" + res="$(__do_curl_to_api PA GET $query)" status=${res:${#res}-3} if [ $status -ne $1 ]; then @@ -1347,7 +1158,7 @@ api_get_service_ids() { fi query="/services" - res="$(__do_curl_to_agent GET $query)" + res="$(__do_curl_to_api PA GET $query)" status=${res:${#res}-3} if [ $status -ne $1 ]; then @@ -1396,7 +1207,7 @@ api_delete_services() { fi query="/services?name="$2 - res="$(__do_curl_to_agent DELETE $query)" + res="$(__do_curl_to_api PA DELETE $query)" status=${res:${#res}-3} if [ $status -ne $1 ]; then @@ -1425,7 +1236,7 @@ api_put_services_keepalive() { fi query="/services/keepalive?name="$2 - res="$(__do_curl_to_agent PUT $query)" + res="$(__do_curl_to_api PA PUT $query)" status=${res:${#res}-3} if [ $status -ne $1 ]; then diff --git a/test/common/api_curl.sh b/test/common/api_curl.sh new file mode 100644 index 00000000..2aff131f --- /dev/null +++ b/test/common/api_curl.sh @@ -0,0 +1,223 @@ +#!/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================================================= +# + +# Generic function to query the agent/ECS via the REST or DMAAP interface. +# Used by all other agent/ECS api test functions +# If operation prefix is '_BATCH' the the send and get response is split in two sequences, +# one for sending the requests and one for receiving the response +# but only when using the DMAAP interface +# REST or DMAAP is controlled of the base url of $ADAPTER +# arg: (PA|ECS GET|PUT|POST|DELETE|GET_BATCH|PUT_BATCH|POST_BATCH|DELETE_BATCH []) | (PA|ECS RESPONSE ) +# (Not for test scripts) +__do_curl_to_api() { + echo "(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG + paramError=0 + + if [ $# -gt 0 ]; then + if [ $1 == "PA" ]; then + __ADAPTER=$ADAPTER + __RESTBASE=$RESTBASE + __RESTBASE_SECURE=$RESTBASE_SECURE + __RETRY_CODES=$AGENT_RETRY_CODES + elif [ $1 == "ECS" ]; then + __ADAPTER=$ECS_ADAPTER + __RESTBASE=$ECS_RESTBASE + __RESTBASE_SECURE=$ECS_RESTBASE_SECURE + __RETRY_CODES=$ECS_RETRY_CODES + else + paramError=1 + fi + fi + if [ $# -lt 3 ] || [ $# -gt 4 ]; then + paramError=1 + else + timeout="" + oper="" + file='' + httpcode=" -sw %{http_code}" + accept='' + content='' + batch=0 + if [[ $2 == *"_BATCH" ]]; then + batch=1 + fi + if [ $# -gt 3 ]; then + content=" -H Content-Type:application/json" + fi + if [ $2 == "GET" ] || [ $2 == "GET_BATCH" ]; then + oper="GET" + if [ $# -ne 3 ]; then + paramError=1 + fi + elif [ $2 == "PUT" ] || [ $2 == "PUT_BATCH" ]; then + oper="PUT" + if [ $# -eq 4 ]; then + file=" --data-binary @$4" + fi + accept=" -H accept:application/json" + elif [ $2 == "POST" ] || [ $2 == "POST_BATCH" ]; then + oper="POST" + accept=" -H accept:*/*" + if [ $# -ne 3 ]; then + paramError=1 + fi + elif [ $2 == "DELETE" ] || [ $2 == "DELETE_BATCH" ]; then + oper="DELETE" + if [ $# -ne 3 ]; then + paramError=1 + fi + elif [ $2 == "RESPONSE" ]; then + oper="RESPONSE" + if [ $# -ne 3 ]; then + paramError=1 + fi + if [ $__ADAPTER == $__RESTBASE ] || [ $__ADAPTER == $__RESTBASE_SECURE ]; then + paramError=1 + fi + else + paramError=1 + fi + fi + + if [ $paramError -eq 1 ]; then + ((RES_CONF_FAIL++)) + echo "-Incorrect number of parameters to __do_curl_agent " $@ >> $HTTPLOG + echo "-Expected: (PA|ECS GET|PUT|POST|DELETE|GET_BATCH|PUT_BATCH|POST_BATCH|DELETE_BATCH []) | (PA|ECS RESPONSE )" >> $HTTPLOG + echo "-Returning response 000" >> $HTTPLOG + echo "-000" + return 1 + fi + + if [ $__ADAPTER == $__RESTBASE ] || [ $__ADAPTER == $__RESTBASE_SECURE ]; then + url=" "${__ADAPTER}${3} + oper=" -X "$oper + curlString="curl -k "${oper}${timeout}${httpcode}${accept}${content}${url}${file} + echo " CMD: "$curlString >> $HTTPLOG + if [ $# -eq 4 ]; then + echo " FILE: $(<$4)" >> $HTTPLOG + fi + + # Do retry for configured response codes, otherwise only one attempt + maxretries=5 + while [ $maxretries -ge 0 ]; do + + let maxretries=maxretries-1 + res=$($curlString) + retcode=$? + if [ $retcode -ne 0 ]; then + echo " RETCODE: "$retcode >> $HTTPLOG + echo "000" + return 1 + fi + retry=0 + echo " RESP: "$res >> $HTTPLOG + status=${res:${#res}-3} + if [ ! -z "${__RETRY_CODES}" ]; then + for retrycode in $__RETRY_CODES; do + if [ $retrycode -eq $status ]; then + echo -e $RED" Retrying (according to set codes for retry), got status $status....."$ERED >> $HTTPLOG + sleep 1 + retry=1 + fi + done + fi + if [ $retry -eq 0 ]; then + maxretries=-1 + fi + done + echo $res + return 0 + else + if [ $oper != "RESPONSE" ]; then + requestUrl=$3 + if [ $2 == "PUT" ] && [ $# -eq 4 ]; then + payload="$(cat $4 | tr -d '\n' | tr -d ' ' )" + echo "payload: "$payload >> $HTTPLOG + file=" --data-binary "$payload + fi + #urlencode the request url since it will be carried by send-request url + requestUrl=$(python3 -c "from __future__ import print_function; import urllib.parse, sys; print(urllib.parse.quote(sys.argv[1]))" "$3") + url=" "${__ADAPTER}"/send-request?url="${requestUrl}"&operation="${oper} + curlString="curl -k -X POST${timeout}${httpcode}${content}${url}${file}" + echo " CMD: "$curlString >> $HTTPLOG + res=$($curlString) + retcode=$? + if [ $retcode -ne 0 ]; then + echo " RETCODE: "$retcode >> $HTTPLOG + echo "000" + return 1 + fi + echo " RESP: "$res >> $HTTPLOG + status=${res:${#res}-3} + if [ $status -ne 200 ]; then + echo "000" + return 1 + fi + cid=${res:0:${#res}-3} + if [[ $batch -eq 1 ]]; then + echo $cid"200" + return 0 + fi + fi + if [ $oper == "RESPONSE" ] || [ $batch -eq 0 ]; then + if [ $oper == "RESPONSE" ]; then + cid=$3 + fi + url=" "${__ADAPTER}"/receive-response?correlationid="${cid} + curlString="curl -k -X GET"${timeout}${httpcode}${url} + echo " CMD: "$curlString >> $HTTPLOG + res=$($curlString) + retcode=$? + if [ $retcode -ne 0 ]; then + echo " RETCODE: "$retcode >> $HTTPLOG + echo "000" + return 1 + fi + echo " RESP: "$res >> $HTTPLOG + status=${res:${#res}-3} + TS=$SECONDS + # wait of the reply from the agent/ECS... + while [ $status -eq 204 ]; do + if [ $(($SECONDS - $TS)) -gt 90 ]; then + echo " RETCODE: (timeout after 90s)" >> $HTTPLOG + echo "000" + return 1 + fi + sleep 0.01 + echo " CMD: "$curlString >> $HTTPLOG + res=$($curlString) + if [ $retcode -ne 0 ]; then + echo " RETCODE: "$retcode >> $HTTPLOG + echo "000" + return 1 + fi + echo " RESP: "$res >> $HTTPLOG + status=${res:${#res}-3} + done + if [ $status -eq 200 ]; then + body=${res:0:${#res}-3} + echo $body + return 0 + fi + echo "Status not 200, returning response 000" >> $HTTPLOG + echo "0000" + return 1 + fi + fi +} \ No newline at end of file diff --git a/test/common/ecs_api_functions.sh b/test/common/ecs_api_functions.sh new file mode 100644 index 00000000..3c372991 --- /dev/null +++ b/test/common/ecs_api_functions.sh @@ -0,0 +1,484 @@ +#!/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 is a script that contains specific test functions for ECS NB/SB API + +. ../common/api_curl.sh + +############### EXPERIMENTAL ############# + +########################################## +###### Mainly only function skeletons #### +########################################## + +########################################## +### A1-E Enrichment Data Consumer API #### +########################################## +#Function prefix: ecs_api_a1 + +# API Test function: GET /A1-EI​/v1​/eitypes​/{eiTypeId}​/eijobs +# args: +# (Function for test scripts) +ecs_api_a1_get_job_ids() { + echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD + echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG + ((RES_TEST++)) + + if [ $# -lt 1 ]; then + __print_err " []*|NOID" $@ + return 1 + fi + + ((RES_PASS++)) + echo -e $GREEN" PASS"$EGREEN + return 0 +} + +# API Test function: GET ​/A1-EI​/v1​/eitypes​/{eiTypeId} +# args: +# (Function for test scripts) +ecs_api_a1_get_type() { + echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD + echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG + ((RES_TEST++)) + + if [ $# -lt 1 ]; then + __print_err " []*|NOID" $@ + return 1 + fi + + ((RES_PASS++)) + echo -e $GREEN" PASS"$EGREEN + return 0 +} + +# API Test function: GET ​/A1-EI​/v1​/eitypes +# args: +# (Function for test scripts) +ecs_api_a1_get_type_ids() { + echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD + echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG + ((RES_TEST++)) + + if [ $# -lt 1 ]; then + __print_err " []*|NOID" $@ + return 1 + fi + + ((RES_PASS++)) + echo -e $GREEN" PASS"$EGREEN + return 0 +} + +# API Test function: GET ​/A1-EI​/v1​/eitypes​/{eiTypeId}​/eijobs​/{eiJobId}​/status +# args: +# (Function for test scripts) +ecs_api_a1_get_job_status() { + echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD + echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG + ((RES_TEST++)) + + if [ $# -lt 1 ]; then + __print_err " []*|NOID" $@ + return 1 + fi + + ((RES_PASS++)) + echo -e $GREEN" PASS"$EGREEN + return 0 +} + +# API Test function: GET ​/A1-EI​/v1​/eitypes​/{eiTypeId}​/eijobs​/{eiJobId} +# args: +# (Function for test scripts) +ecs_api_a1_get_job() { + echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD + echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG + ((RES_TEST++)) + + if [ $# -lt 1 ]; then + __print_err " []*|NOID" $@ + return 1 + fi + + ((RES_PASS++)) + echo -e $GREEN" PASS"$EGREEN + return 0 +} + +# API Test function: DELETE ​/A1-EI​/v1​/eitypes​/{eiTypeId}​/eijobs​/{eiJobId} +# args: +# (Function for test scripts) +ecs_api_a1_delete_job() { + echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD + echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG + ((RES_TEST++)) + + if [ $# -lt 1 ]; then + __print_err " []*|NOID" $@ + return 1 + fi + + ((RES_PASS++)) + echo -e $GREEN" PASS"$EGREEN + return 0 +} + +# API Test function: PUT ​/A1-EI​/v1​/eitypes​/{eiTypeId}​/eijobs​/{eiJobId} +# args: +# (Function for test scripts) +ecs_api_a1_put_job() { + echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD + echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG + ((RES_TEST++)) + + if [ $# -lt 1 ]; then + __print_err " []*|NOID" $@ + return 1 + fi + + ((RES_PASS++)) + echo -e $GREEN" PASS"$EGREEN + return 0 +} + + +########################################## +#### Enrichment Data Producer API #### +########################################## +# Function prefix: ecs_api_edp + +# API Test function: GET /ei-producer/v1/eitypes +# args: +# (Function for test scripts) +ecs_api_edp_get_type_ids() { + echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD + echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG + ((RES_TEST++)) + + if [ $# -lt 1 ]; then + __print_err " []*|NOID" $@ + return 1 + fi + + ((RES_PASS++)) + echo -e $GREEN" PASS"$EGREEN + return 0 +} + +# API Test function: GET /ei-producer/v1/eiproducers/{eiProducerId}/status +# args: +# (Function for test scripts) +ecs_api_edp_get_producer_status() { + echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD + echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG + ((RES_TEST++)) + + if [ $# -lt 1 ]; then + __print_err " []*|NOID" $@ + return 1 + fi + + ((RES_PASS++)) + echo -e $GREEN" PASS"$EGREEN + return 0 +} + + +# API Test function: GET /ei-producer/v1/eiproducers +# args: []*|NOID +# (Function for test scripts) +ecs_api_edp_get_producer_ids() { + echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD + echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG + ((RES_TEST++)) + + if [ $# -lt 1 ]; then + __print_err " []*|NOID" $@ + return 1 + fi + + query="/ei-producer/v1/eiproducers" + res="$(__do_curl_to_api ECS GET $query)" + status=${res:${#res}-3} + + if [ $status -ne $1 ]; then + echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED + ((RES_FAIL++)) + __check_stop_at_error + return 1 + fi + + if [ $# -gt 1 ]; then + body=${res:0:${#res}-3} + targetJson="[" + + for pid in ${@:2} ; do + if [ "$targetJson" != "[" ]; then + targetJson=$targetJson"," + fi + if [ $pid != "NOID" ]; then + targetJson=$targetJson"\"$pid\"" + fi + done + + targetJson=$targetJson"]" + echo "TARGET JSON: $targetJson" >> $HTTPLOG + res=$(python3 ../common/compare_json.py "$targetJson" "$body") + + if [ $res -ne 0 ]; then + echo -e $RED" FAIL, returned body not correct"$ERED + ((RES_FAIL++)) + __check_stop_at_error + return 1 + fi + fi + + ((RES_PASS++)) + echo -e $GREEN" PASS"$EGREEN + return 0 +} + +# API Test function: GET /ei-producer/v1/eitypes/{eiTypeId} +# args: +# (Function for test scripts) +ecs_api_edp_get_type() { + echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD + echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG + ((RES_TEST++)) + + if [ $# -lt 1 ]; then + __print_err " []*|NOID" $@ + return 1 + fi + + ((RES_PASS++)) + echo -e $GREEN" PASS"$EGREEN + return 0 +} + +# API Test function: GET /ei-producer/v1/eiproducers/{eiProducerId} +# args: +# (Function for test scripts) +ecs_api_edp_get_producer() { + echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD + echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG + ((RES_TEST++)) + + if [ $# -lt 1 ]; then + __print_err " []*|NOID" $@ + return 1 + fi + + ((RES_PASS++)) + echo -e $GREEN" PASS"$EGREEN + return 0 +} + +# API Test function: DELETE /ei-producer/v1/eiproducers/{eiProducerId} +# args: +# (Function for test scripts) +ecs_api_edp_delete_producer() { + echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD + echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG + ((RES_TEST++)) + + if [ $# -lt 1 ]; then + __print_err " []*|NOID" $@ + return 1 + fi + + ((RES_PASS++)) + echo -e $GREEN" PASS"$EGREEN + return 0 +} + +# API Test function: PUT /ei-producer/v1/eiproducers/{eiProducerId} +# args: +# (Function for test scripts) +ecs_api_edp_put_producer() { + echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD + echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG + ((RES_TEST++)) + + if [ $# -lt 1 ]; then + __print_err " []*|NOID" $@ + return 1 + fi + + ((RES_PASS++)) + echo -e $GREEN" PASS"$EGREEN + return 0 +} + +# API Test function: GET /ei-producer/v1/eiproducers/{eiProducerId}/eijobs +# args: +# (Function for test scripts) +ecs_api_edp_get_producer_jobs() { + echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD + echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG + ((RES_TEST++)) + + if [ $# -lt 1 ]; then + __print_err " []*|NOID" $@ + return 1 + fi + + ((RES_PASS++)) + echo -e $GREEN" PASS"$EGREEN + return 0 +} + + +########################################## +#### Producer Simulator #### +########################################## +# Function prefix: ecs_api_sim + +# API Test function: POST ​/producer_simulator​/job_deleted_error +# args: +# (Function for test scripts) +ecs_api_sim_post_job_delete_error() { + echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD + echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG + ((RES_TEST++)) + + if [ $# -lt 1 ]; then + __print_err " []*|NOID" $@ + return 1 + fi + + ((RES_PASS++)) + echo -e $GREEN" PASS"$EGREEN + return 0 +} + +# API Test function: GET /producer_simulator​/supervision +# args: +# (Function for test scripts) +ecs_api_sim_get_producer_supervision() { + echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD + echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG + ((RES_TEST++)) + + if [ $# -lt 1 ]; then + __print_err " []*|NOID" $@ + return 1 + fi + + ((RES_PASS++)) + echo -e $GREEN" PASS"$EGREEN + return 0 +} + +# API Test function: POST /producer_simulator​/job_deleted +# args: +# (Function for test scripts) +ecs_api_sim_post_job_deleted() { + echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD + echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG + ((RES_TEST++)) + + if [ $# -lt 1 ]; then + __print_err " []*|NOID" $@ + return 1 + fi + + ((RES_PASS++)) + echo -e $GREEN" PASS"$EGREEN + return 0 +} + +# API Test function: GET ​/producer_simulator​/supervision_error +# args: +# (Function for test scripts) +ecs_api_get_producer_supervision_error() { + echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD + echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG + ((RES_TEST++)) + + if [ $# -lt 1 ]; then + __print_err " []*|NOID" $@ + return 1 + fi + + ((RES_PASS++)) + echo -e $GREEN" PASS"$EGREEN + return 0 +} + +# API Test function: POST /producer_simulator​/job_created_error +# args: +# (Function for test scripts) +ecs_api_sim_get_job_created_error() { + echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD + echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG + ((RES_TEST++)) + + if [ $# -lt 1 ]; then + __print_err " []*|NOID" $@ + return 1 + fi + + ((RES_PASS++)) + echo -e $GREEN" PASS"$EGREEN + return 0 +} + +# API Test function: POST ​/producer_simulator​/job_created +# args: +# (Function for test scripts) +ecs_api_sim_get_job_created() { + echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD + echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG + ((RES_TEST++)) + + if [ $# -lt 1 ]; then + __print_err " []*|NOID" $@ + return 1 + fi + + ((RES_PASS++)) + echo -e $GREEN" PASS"$EGREEN + return 0 +} + + +########################################## +#### Service status #### +########################################## +# Function prefix: ecs_api_service + +# API Test function: GET ​/status +# args: +# (Function for test scripts) +ecs_api_service_status() { + echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD + echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG + ((RES_TEST++)) + + if [ $# -lt 1 ]; then + __print_err " []*|NOID" $@ + return 1 + fi + + ((RES_PASS++)) + echo -e $GREEN" PASS"$EGREEN + return 0 +} \ No newline at end of file diff --git a/test/common/test_env.sh b/test/common/test_env.sh index 8417ecea..56d75839 100755 --- a/test/common/test_env.sh +++ b/test/common/test_env.sh @@ -30,6 +30,12 @@ POLICY_AGENT_LOCAL_IMAGE_TAG="2.1.0-SNAPSHOT" POLICY_AGENT_REMOTE_IMAGE="nexus3.o-ran-sc.org:10004/o-ran-sc/nonrtric-policy-agent" POLICY_AGENT_REMOTE_IMAGE_TAG="2.1.0" +# Local ECS image and tag +ECS_LOCAL_IMAGE="o-ran-sc/nonrtric-enrichment-coordinator-service" +ECS_LOCAL_IMAGE_TAG="1.0.0-SNAPSHOT" +# Remote ECS image and tag +ECS_REMOTE_IMAGE="nexus3.o-ran-sc.org:10003/o-ran-sc/nonrtric-enrichment-coordinator-service" +ECS_REMOTE_IMAGE_TAG="1.0.0-SNAPSHOT" # Control Panel local image and tag CONTROL_PANEL_LOCAL_IMAGE="o-ran-sc/nonrtric-controlpanel" @@ -53,17 +59,6 @@ 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" @@ -80,7 +75,6 @@ CONSUL_REMOTE_IMAGE_TAG="1.7.2" #CBS remote image and tag CBS_REMOTE_IMAGE="nexus3.onap.org:10001/onap/org.onap.dcaegen2.platform.configbinding.app-app" -CBS_REMOTE_IMAGE="onap/org.onap.dcaegen2.platform.configbinding.app-app" CBS_REMOTE_IMAGE_TAG="2.3.0" #No local image for CBS, remote image always used @@ -107,6 +101,15 @@ export POLICY_AGENT_APP_NAME="policy-agent" # Name for Polic 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 ECS_EXTERNAL_PORT=8082 # ECS container external port (host -> container) +export ECS_INTERNAL_PORT=8082 # ECS container internal port (container -> container) +export ECS_EXTERNAL_SECURE_PORT=8434 # ECS container external secure port (host -> container) +export ECS_INTERNAL_SECURE_PORT=8434 # ECS container internal secure port (container -> container) + +export ECS_APP_NAME="ecs" # Name for ECS container +ECS_LOGPATH="/var/log/ecs/application.log" # Path the application log in the ECS container +export ECS_APP_NAME_ALIAS="ecs-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) @@ -153,30 +156,23 @@ SDNC_API_URL="/restconf/operations/A1-ADAPTER-API:" # Base url path SDNC_ALIVE_URL="/apidoc/explorer/" # Base url path for SNDC API docs (for alive check) SDNC_KARAF_LOG="/opt/opendaylight/data/log/karaf.log" # Path to karaf log -export SDNC_ONAP_APP_NAME="a1-adapter" # Name of the ONAP A1 Adapter container -export SDNC_ONAP_EXTERNAL_PORT=8282 # ONAP A1 Adapter container external port (host -> container) -export SDNC_ONAP_INTERNAL_PORT=8181 # ONAP A1 Adapter container internal port (container -> container) -export SDNC_ONAP_EXTERNAL_SECURE_PORT=8443 # SNDC A1 Adapter container external securee port (host -> container) -export SDNC_ONAP_INTERNAL_SECURE_PORT=8343 # SNDC A1 Adapter container internal secure port (container -> container) -export SDNC_ONAP_DB_APP_NAME="sdnc-onap-db" # Name of the ONAP A1 Adapter DB container -SDNC_ONAP_USER="admin" # ONAP A1 Adapter username -SDNC_ONAP_PWD="Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U" # ONAP A1 Adapter PWD -SDNC_ONAP_API_URL="/restconf/operations/A1-ADAPTER-API:" # Base url path for ONAP A1 Adapter API -SDNC_ONAP_ALIVE_URL="/apidoc/explorer/" # Base url path for ONAP A1 Adapter API docs (for alive check) -SDNC_ONAP_PROPERTIES_FILE="/opt/onap/ccsdk/data/properties/a1-adapter-api-dg.properties" -SDNC_ONAP_KARAF_LOG="/opt/opendaylight/data/log/karaf.log" # Path to karaf log - 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 UUID="" # UUID used as prefix to the policy id to simulate a real UUID - # Testscript need to set the UUID to use other this empty prefix is used + # Testscript need to set the UUID otherwise this empty prefix is used 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, http DMAAPBASE_SECURE="https://localhost:"$MR_EXTERNAL_SECURE_PORT # Base url to the Dmaap adapter, https 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 + # The values of this var is swiched between the four base url when needed +ECS_RESTBASE="http://localhost:"$ECS_EXTERNAL_PORT # Base url to the ECS NB REST interface +ECS_RESTBASE_SECURE="https://localhost:"$ECS_EXTERNAL_SECURE_PORT # Base url to the secure ECS NB REST interface +ECS_DMAAPBASE="http://localhost:"$MR_EXTERNAL_PORT # Base url to the Dmaap adapter, http +ECS_DMAAPBASE_SECURE="https://localhost:"$MR_EXTERNAL_SECURE_PORT # Base url to the Dmaap adapter, https +ECS_ADAPTER=$ECS_RESTBASE # Adapter holds the address the ECS R-APP interface (REST OR DMAAP) + # The values of this var is swiched between the four base url when needed \ No newline at end of file diff --git a/test/common/testcase_common.sh b/test/common/testcase_common.sh index 39a593c8..a90700aa 100755 --- a/test/common/testcase_common.sh +++ b/test/common/testcase_common.sh @@ -21,6 +21,14 @@ # Arg: local|remote|remote-remove [auto-clean] [--stop-at-error] [--ricsim-prefix ] [ --env-file ] [--use-local-image []*] +# Create a test case id, ATC (Auto Test Case), from the name of the test case script. +# FTC1.sh -> ATC == FTC1 +ATC=$(basename "${BASH_SOURCE[$i+1]}" .sh) + +#Create result file (containing '1' for error) for this test case +#Will be replaced with a file containing '0' if all test cases pass +echo "1" > "$PWD/.result$ATC.txt" + #Formatting for 'echo' cmd BOLD="\033[1m" EBOLD="\033[0m" @@ -60,7 +68,10 @@ echo "Test case started as: ${BASH_SOURCE[$i+1]} "$@ #Localhost constant LOCALHOST="http://localhost:" -# Make curl retries for http response codes set in this env var, space separated list of codes +# Make curl retries towards ECS for http response codes set in this env var, space separated list of codes +ECS_RETRY_CODES="" + +# Make curl retries towards the agent for http response codes set in this env var, space separated list of codes AGENT_RETRY_CODES="" # Var to contol if the agent runs in a container (normal = 0) or as application on the local machine ( = 1) @@ -73,11 +84,17 @@ AUTO_CLEAN="" USE_LOCAL_IMAGES="" # List of available apps to override with local image -AVAILABLE_LOCAL_IMAGES_OVERRIDE="PA CP SDNC RICSIM" +AVAILABLE_LOCAL_IMAGES_OVERRIDE="PA ECS CP SDNC RICSIM" # Use this var (STOP_AT_ERROR=1 in the test script) for debugging/trouble shooting to take all logs and exit at first FAIL test case STOP_AT_ERROR=0 +# Function to indent cmd output with one space +indent1() { sed 's/^/ /'; } + +# Function to indent cmd output with two spaces +indent2() { sed 's/^/ /'; } + # Set a description string for the test case if [ -z "$TC_ONELINE_DESCR" ]; then TC_ONELINE_DESCR="" @@ -91,10 +108,6 @@ if [ -f .tmp_tcsuite_ctr ]; then echo $tmpval > .tmp_tcsuite_ctr fi -# Create a test case id, ATC (Auto Test Case), from the name of the test case script. -# FTC1.sh -> ATC == FTC1 -ATC=$(basename "${BASH_SOURCE[$i+1]}" .sh) - # Create the logs dir if not already created in the current dir if [ ! -d "logs" ]; then mkdir logs @@ -105,10 +118,6 @@ TESTLOGS=$PWD/logs HTTPLOG=$PWD"/.httplog_"$ATC".txt" echo "" > $HTTPLOG -#Create result file (containing '1' for error) for this test case -#Will be replaced with a file containing '0' if script is ok - -echo "1" > "$PWD/.result$ATC.txt" # Create a log dir for the test case mkdir -p $TESTLOGS/$ATC @@ -243,7 +252,7 @@ if [ -f "$TEST_ENV_VAR_FILE" ]; then echo -e $BOLD"Sourcing env vars from: "$TEST_ENV_VAR_FILE$EBOLD . $TEST_ENV_VAR_FILE else - echo -e $RED"Selected env var fle does not exist: "$TEST_ENV_VAR_FILE$ERED + echo -e $RED"Selected env var file does not exist: "$TEST_ENV_VAR_FILE$ERED exit 1 fi @@ -282,13 +291,19 @@ image_list_file=".image-list" echo -e " Container\tImage\ttag" > $image_list_file # Check if image env var is set and if so export the env var with image to use (used by docker compose files) -# arg: