#App names to include in the test, space separated list
INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM SDNC"
+#SUPPORTED TEST ENV FILE
+SUPPORTED_PROFILES="ONAP-MASTER ONAP-GUILIN"
+
. ../common/testcase_common.sh $@
. ../common/agent_api_functions.sh
. ../common/ricsimulator_api_functions.sh
+. ../common/cr_api_functions.sh
#### TEST BEGIN ####
echo "#####################################################################"
echo "#####################################################################"
+ # Clean container and start all needed containers #
+ clean_containers
+
+ if [ $__httpx == "HTTPS" ]; then
+ use_agent_rest_https
+ else
+ use_agent_rest_http
+ fi
+
+ start_policy_agent
+
+ set_agent_trace
+
+ # Create service to be able to receive events when rics becomes available
+ # Must use rest towards the agent since dmaap is not configured yet
+ api_put_service 201 "ric-registration" 0 "$CR_PATH/ric-registration"
if [ $__httpx == "HTTPS" ]; then
- CR_PATH="https://$CR_APP_NAME:$CR_EXTERNAL_SECURE_PORT/callbacks"
use_cr_https
use_simulator_https
use_mr_https
use_agent_rest_https
fi
else
- CR_PATH="http://$CR_APP_NAME:$CR_EXTERNAL_PORT/callbacks"
use_cr_http
use_simulator_http
use_mr_http
fi
fi
- # Clean container and start all needed containers #
- clean_containers
-
start_ric_simulators ricsim_g1 1 OSC_2.1.0
start_ric_simulators ricsim_g2 1 STD_1.1.3
if [ "$PMS_VERSION" == "V2" ]; then
start_cr
+ start_control_panel
+
start_consul_cbs
if [[ $interface = *"SDNC"* ]]; then
consul_config_app ".consul_config.json"
- start_control_panel
-
- start_policy_agent
-
- set_agent_debug
- set_agent_trace
-
- cr_equal received_callbacks 0
mr_equal requests_submitted 0
sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json
if [ "$PMS_VERSION" == "V2" ]; then
api_equal json:rics 3 60
- #api_equal json:policy_schemas 2 120
-
api_equal json:policy-types 2 120
api_equal json:policies 0
- api_equal json:policy_instances 0
+ api_equal json:policy-instances 0
+
+ cr_equal received_callbacks 3 120
+
+ cr_api_check_all_sync_events 200 ric-registration ricsim_g1_1 ricsim_g2_1 ricsim_g3_1
+
else
api_equal json:rics 2 60
api_put_service 201 "serv1" 1000 "$CR_PATH/1"
- api_get_service_ids 200 "serv1"
+ api_get_service_ids 200 "serv1" "ric-registration"
api_put_services_keepalive 200 "serv1"
echo "############################################"
if [ "$PMS_VERSION" == "V2" ]; then
- notificationurl="http://localhost:80"
+ notificationurl=$CR_PATH"/test"
else
notificationurl=""
fi
if [ "$PMS_VERSION" == "V2" ]; then
api_equal json:policies 0
- api_equal json:policy_instances 0
+ api_equal json:policy-instances 0
else
api_equal json:policies 0
api_equal json:policy_ids 0
fi
- cr_equal received_callbacks 0
+ if [ "$PMS_VERSION" == "V2" ]; then
+ cr_equal received_callbacks 3
+ fi
if [[ $interface = *"DMAAP"* ]]; then
VAL=11 # Number of Agent API calls over DMAAP
check_policy_agent_logs
check_control_panel_logs
+ if [[ $interface = *"SDNC"* ]]; then
+ check_sdnc_logs
+ fi
+
store_logs "${__httpx}__${interface}"
done
#App names to include in the test, space separated list
INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM"
+#SUPPORTED TEST ENV FILE
+SUPPORTED_PROFILES="ONAP-MASTER ONAP-GUILIN ORAN-MASTER"
+
. ../common/testcase_common.sh $@
. ../common/agent_api_functions.sh
. ../common/ricsimulator_api_functions.sh
generate_uuid
-#Local vars in test script
-##########################
-# Path to callback receiver
-CR_PATH="http://$CR_APP_NAME:$CR_EXTERNAL_PORT/callbacks"
-
-use_cr_http
use_simulator_http
use_mr_http
use_agent_rest_http
start_mr
-start_cr
-
start_consul_cbs
prepare_consul_config NOSDNC ".consul_config.json"
# Create policies
if [ "$PMS_VERSION" == "V2" ]; then
- notificationurl="http://localhost:80"
+ notificationurl=$CR_PATH"/test"
else
notificationurl=""
fi
api_get_services 404 "service1"
-
-
check_policy_agent_logs
#### TEST COMPLETE ####
#App names to include in the test, space separated list
INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM SDNC"
+
+#SUPPORTED TEST ENV FILE
+SUPPORTED_PROFILES="ONAP-MASTER ONAP-GUILIN"
+
. ../common/testcase_common.sh $@
. ../common/agent_api_functions.sh
. ../common/ricsimulator_api_functions.sh
+. ../common/cr_api_functions.sh
#### TEST BEGIN ####
echo "#####################################################################"
echo "#####################################################################"
+ # Clean container and start all needed containers #
+ clean_containers
+
+ if [ $__httpx == "HTTPS" ]; then
+ use_agent_rest_https
+ else
+ use_agent_rest_http
+ fi
+
+ start_policy_agent
+
+ set_agent_trace
+
+ # Create service to be able to receive events when rics becomes available
+ # Must use rest towards the agent since dmaap is not configured yet
+ api_put_service 201 "ric-registration" 0 "$CR_PATH/ric-registration"
+
+
if [ $__httpx == "HTTPS" ]; then
- CR_PATH="https://$CR_APP_NAME:$CR_EXTERNAL_SECURE_PORT/callbacks"
use_cr_https
use_simulator_https
use_mr_https
use_agent_rest_https
fi
else
- CR_PATH="http://$CR_APP_NAME:$CR_EXTERNAL_PORT/callbacks"
use_cr_http
use_simulator_http
use_mr_http
fi
fi
- # Clean container and start all needed containers #
- clean_containers
-
start_ric_simulators ricsim_g1 1 OSC_2.1.0
start_ric_simulators ricsim_g2 1 STD_1.1.3
if [ "$PMS_VERSION" == "V2" ]; then
start_cr
+ start_control_panel
+
start_consul_cbs
if [[ $interface = *"SDNC"* ]]; then
consul_config_app ".consul_config.json"
- start_control_panel
-
- start_policy_agent
-
- set_agent_debug
-
- cr_equal received_callbacks 0
- mr_equal requests_submitted 0
-
sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json
sim_put_policy_type 201 ricsim_g1_1 2 testdata/OSC/sim_2.json
if [ "$PMS_VERSION" == "V2" ]; then
api_equal json:rics 3 60
- #api_equal json:policy-schemas 3 120
-
api_equal json:policy-types 3 120
api_equal json:policies 0
- api_equal json:policy_instances 0
+ api_equal json:policy-instances 0
else
api_equal json:rics 2 60
api_equal json:policy_ids 0
fi
+ if [ "$PMS_VERSION" == "V2" ]; then
+ cr_equal received_callbacks 3 120
+ cr_api_check_all_sync_events 200 ric-registration ricsim_g1_1 ricsim_g2_1 ricsim_g3_1
+ fi
+ mr_equal requests_submitted 0
+
echo "############################################"
echo "############## Health check ################"
api_get_services 200 "service1" "service1" 2000 "$CR_PATH/1"
- api_get_service_ids 200 "service1" "service2"
+ api_get_service_ids 200 "service1" "service2" "ric-registration"
api_put_service 201 "service3" 5000 "$CR_PATH/3"
- api_get_service_ids 200 "service1" "service2" "service3"
+ api_get_service_ids 200 "service1" "service2" "service3" "ric-registration"
api_get_services 200 "service1" "service1" 2000 "$CR_PATH/1"
- api_get_services 200 NOSERVICE "service1" 2000 "$CR_PATH/1" "service2" 300 "ftp://localhost:80/test" "service3" 5000 "$CR_PATH/3"
+ api_get_services 200 NOSERVICE "service1" 2000 "$CR_PATH/1" "service2" 300 "ftp://localhost:80/test" "service3" 5000 "$CR_PATH/3" "ric-registration" 0 "$CR_PATH/ric-registration"
api_get_services 200
api_put_services_keepalive 404 "service5"
- api_get_service_ids 200 "service1" "service2" "service3"
+ api_get_service_ids 200 "service1" "service2" "service3" "ric-registration"
api_delete_services 204 "service1"
- api_get_service_ids 200 "service2" "service3"
+ api_get_service_ids 200 "service2" "service3" "ric-registration"
api_put_service 201 "service1" 50 "$CR_PATH/1"
- api_get_service_ids 200 "service1" "service2" "service3"
+ api_get_service_ids 200 "service1" "service2" "service3" "ric-registration"
api_delete_services 204 "service1"
api_delete_services 204 "service3"
- api_equal json:services 1
+ api_equal json:services 2
api_delete_services 204 "service2"
- api_equal json:services 0
+ api_equal json:services 1
echo "############################################"
api_put_service 201 "service10" 3600 "$CR_PATH/1"
if [ "$PMS_VERSION" == "V2" ]; then
- notificationurl="http://localhost:80"
+ notificationurl=$CR_PATH"/test"
else
notificationurl=""
fi
#api_equal json:policy_ids 2
#Allow 3 for now
if [ "$PMS_VERSION" == "V2" ]; then
- api_equal json:policy_instances 3
+ api_equal json:policy-instances 3
else
api_equal json:policy_ids 3
fi
api_equal json:policies 1
if [ "$PMS_VERSION" == "V2" ]; then
- api_equal json:policy_instances 1
+ api_equal json:policy-instances 1
else
api_equal json:policy_ids 1
fi
api_equal json:policies 0
if [ "$PMS_VERSION" == "V2" ]; then
- api_equal json:policy_instances 0
+ api_equal json:policy-instances 0
else
api_equal json:policy_ids 0
fi
- cr_equal received_callbacks 0
+ if [ "$PMS_VERSION" == "V2" ]; then
+ cr_equal received_callbacks 3
+ fi
if [[ $interface = *"DMAAP"* ]]; then
mr_greater requests_submitted 0
check_policy_agent_logs
check_control_panel_logs
+ if [[ $interface = *"SDNC"* ]]; then
+ check_sdnc_logs
+ fi
+
store_logs "${__httpx}__${interface}"
done
#App names to include in the test, space separated list
INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM"
+#SUPPORTED TEST ENV FILE
+SUPPORTED_PROFILES="ONAP-MASTER ONAP-GUILIN"
+
. ../common/testcase_common.sh $@
. ../common/agent_api_functions.sh
. ../common/ricsimulator_api_functions.sh
+. ../common/cr_api_functions.sh
generate_uuid
-#Local vars in test script
-##########################
-# Path to callback receiver
-CR_PATH="http://$CR_APP_NAME:$CR_EXTERNAL_PORT/callbacks"
-
use_cr_http
use_simulator_http
use_mr_http
set_agent_debug
-#Verify no callbacks or dmaap messages has been sent
-cr_equal received_callbacks 0
mr_equal requests_submitted 0
#Check agent alive
fi
if [ "$PMS_VERSION" == "V2" ]; then
- notificationurl="http://localhost:80"
+ notificationurl=$CR_PATH"/test"
else
notificationurl=""
fi
api_get_service_ids 200
-deviation "TR18 Agents sends callback with empty body"
-deviation "TR18 Unclear when callbacks are sent...."
-#cr_equal received_callbacks 8
mr_equal requests_submitted 0
check_policy_agent_logs
#App names to include in the test, space separated list
INCLUDED_IMAGES="RICSIM SDNC"
+#SUPPORTED TEST ENV FILE
+SUPPORTED_PROFILES="ONAP-MASTER ONAP-GUILIN"
+
. ../common/testcase_common.sh $@
. ../common/controller_api_functions.sh
. ../common/ricsimulator_api_functions.sh
#App names to include in the test, space separated list
INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM SDNC"
+#SUPPORTED TEST ENV FILE
+SUPPORTED_PROFILES="ONAP-MASTER ONAP-GUILIN"
+
. ../common/testcase_common.sh $@
. ../common/agent_api_functions.sh
. ../common/ricsimulator_api_functions.sh
echo "#####################################################################"
if [ $__httpx == "HTTPS" ]; then
- CR_PATH="https://$CR_APP_NAME:$CR_EXTERNAL_SECURE_PORT/callbacks"
use_cr_https
use_simulator_https
use_mr_https
use_agent_rest_https
fi
else
- CR_PATH="http://$CR_APP_NAME:$CR_EXTERNAL_PORT/callbacks"
use_cr_http
use_simulator_http
use_mr_http
api_put_service 201 "serv1" 3600 "$CR_PATH/1"
START_ID=2000
- NUM_POLICIES=10000
+ NUM_POLICIES=10000 # Must be at least 100
if [ "$PMS_VERSION" == "V2" ]; then
- notificationurl="http://localhost:80"
+ notificationurl=$CR_PATH"/test"
else
notificationurl=""
fi
api_equal json:policies $(($NUM_POLICIES-2+$NUM_POLICIES-3))
check_policy_agent_logs
+ if [[ $interface = *"SDNC"* ]]; then
+ check_sdnc_logs
+ fi
store_logs "${__httpx}__${interface}"
TC_ONELINE_DESCR="Resync of RIC via changes in the consul config"
#App names to include in the test, space separated list
-INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM SDNC"
+INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM"
+
+#SUPPORTED TEST ENV FILE
+SUPPORTED_PROFILES="ONAP-MASTER ONAP-GUILIN"
. ../common/testcase_common.sh $@
. ../common/agent_api_functions.sh
. ../common/ricsimulator_api_functions.sh
-. ../common/controller_api_functions.sh
+. ../common/cr_api_functions.sh
#### TEST BEGIN ####
# Clean container and start all needed containers #
clean_containers
+start_policy_agent
+
+set_agent_trace
+
+# Create service to be able to receive events when rics becomes available
+# Must use rest towards the agent since dmaap is not configured yet
+api_put_service 201 "ric-registration" 0 "$CR_PATH/ric-registration"
+
# Start one RIC of each type
start_ric_simulators ricsim_g1 1 OSC_2.1.0
start_ric_simulators ricsim_g2 1 STD_1.1.3
start_consul_cbs
+start_control_panel
+
prepare_consul_config NOSDNC ".consul_config.json"
consul_config_app ".consul_config.json"
-start_control_panel
-
-start_policy_agent
-
if [ "$PMS_VERSION" == "V2" ]; then
api_equal json:rics 3 120
+
+ cr_equal received_callbacks 3 120
+
+ cr_api_check_all_sync_events 200 ric-registration ricsim_g1_1 ricsim_g2_1 ricsim_g3_1
else
api_equal json:rics 2 120
fi
-
# Add an STD RIC and check
start_ric_simulators ricsim_g2 2 STD_1.1.3
if [ "$PMS_VERSION" == "V2" ]; then
api_equal json:rics 4 120
+
+ cr_equal received_callbacks 4 120
+
+ cr_api_check_all_sync_events 200 ric-registration ricsim_g2_2
else
api_equal json:rics 3 120
fi
if [ "$PMS_VERSION" == "V2" ]; then
api_equal json:rics 3 120
+
+ cr_equal received_callbacks 4 120
else
api_equal json:rics 2 120
fi
#App names to include in the test, space separated list
INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM SDNC"
+#SUPPORTED TEST ENV FILE
+SUPPORTED_PROFILES="ONAP-MASTER ONAP-GUILIN"
+
. ../common/testcase_common.sh $@
. ../common/agent_api_functions.sh
. ../common/ricsimulator_api_functions.sh
+. ../common/cr_api_functions.sh
#### TEST BEGIN ####
generate_uuid
-#Local vars in test script
-##########################
-# Path to callback receiver
-CR_PATH="http://$CR_APP_NAME:$CR_EXTERNAL_PORT/callbacks"
use_cr_http
NUM_RICS=10
start_consul_cbs
+ # Create first config
if [[ $interface = *"SDNC"* ]]; then
start_sdnc
- prepare_consul_config SDNC ".consul_config_2.json"
+ prepare_consul_config SDNC ".consul_config_initial.json"
else
- prepare_consul_config NOSDNC ".consul_config_2.json"
+ prepare_consul_config NOSDNC ".consul_config_initial.json"
fi
- consul_config_app ".consul_config_2.json"
-
-
# Create 2nd config and save for later
start_ric_simulators ricsim_g1 $NUM_RICS OSC_2.1.0
start_policy_agent
- set_agent_debug
set_agent_trace
api_get_status 200
+ # Create service to be able to receive events when rics becomes available
+ # Must use rest towards the agent since dmaap is not configured yet
+ api_put_service 201 "ric-registration" 0 "$CR_PATH/ric-registration"
+
+ #Load first config
+ consul_config_app ".consul_config_initial.json"
+
for ((i=1; i<=${NUM_RICS}; i++))
do
sim_print ricsim_g1_$i interface
# All sims running but 2 are not configured in consul
api_equal json:rics 8 120
+ if [ "$PMS_VERSION" == "V2" ]; then
+ cr_equal received_callbacks?id=ric-registration 8 120
+ cr_api_check_all_sync_events 200 ric-registration ricsim_g1_1 ricsim_g1_2 ricsim_g1_3 ricsim_g1_4 ricsim_g1_5 ricsim_g1_6 ricsim_g1_7 ricsim_g1_8
+ fi
+
api_get_rics 200 NOTYPE "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:NOTYPE:???? \
ricsim_g1_2:me1_ricsim_g1_2,me2_ricsim_g1_2:NOTYPE:???? \
ricsim_g1_3:me1_ricsim_g1_3,me2_ricsim_g1_3:NOTYPE:???? \
sim_put_policy_type 201 ricsim_g1_6 5 testdata/OSC/sim_5.json
sim_put_policy_type 201 ricsim_g1_7 5 testdata/OSC/sim_5.json
sim_put_policy_type 201 ricsim_g1_8 5 testdata/OSC/sim_5.json
- sim_put_policy_type 201 ricsim_g1_9 5 testdata/OSC/sim_5.json
if [ "$PMS_VERSION" == "V2" ]; then
api_equal json:policy-types 5 120
ricsim_g1_7:me1_ricsim_g1_7,me2_ricsim_g1_7:3,4,5:???? \
ricsim_g1_8:me1_ricsim_g1_8,me2_ricsim_g1_8:4,5:???? "
+ if [ "$PMS_VERSION" == "V2" ]; then
+ cr_equal received_callbacks?id=ric-registration 16 120
+ cr_api_check_all_sync_events 200 ric-registration ricsim_g1_1 ricsim_g1_2 ricsim_g1_3 ricsim_g1_4 ricsim_g1_5 ricsim_g1_6 ricsim_g1_7 ricsim_g1_8
+ fi
#Load config with all rics
consul_config_app ".consul_config_all.json"
api_equal json:rics 10 120
+ if [ "$PMS_VERSION" == "V2" ]; then
+ cr_equal received_callbacks?id=ric-registration 18 120
+ cr_api_check_all_sync_events 200 ric-registration ricsim_g1_9 ricsim_g1_10
+ fi
+
+ sim_put_policy_type 201 ricsim_g1_9 5 testdata/OSC/sim_5.json
+
if [ "$PMS_VERSION" == "V2" ]; then
echo "Check the number of types in the agent for each ric"
ricsim_g1_9:me1_ricsim_g1_9,me2_ricsim_g1_9:5:???? \
ricsim_g1_10:me1_ricsim_g1_10,me2_ricsim_g1_10:NOTYPE:???? "
+ if [ "$PMS_VERSION" == "V2" ]; then
+ cr_equal received_callbacks?id=ric-registration 19 120
+ cr_api_check_all_sync_events 200 ric-registration ricsim_g1_9
+ fi
#No policy type in sim #10
api_put_service 201 "serv1" 3600 "$CR_PATH/serv1"
if [ "$PMS_VERSION" == "V2" ]; then
- notificationurl="http://localhost:80"
+ notificationurl=$CR_PATH"/test"
else
notificationurl=""
fi
- api_put_policy 201 "serv1" ricsim_g1_9 5 2000 NOTRANSIENT $notificationurl testdata/OSC/pi5_template.json 1
-
- if [ "$PMS_VERSION" == "V2" ]; then
- api_equal json:policy_instances 1
- else
- api_equal json:policy_ids 1
- fi
-
- sim_equal ricsim_g1_9 num_instances 1
-
-
# Load config with reduced number of rics
- consul_config_app ".consul_config_2.json"
+ consul_config_app ".consul_config_initial.json"
api_equal json:rics 8 120
+ if [ "$PMS_VERSION" == "V2" ]; then
+ cr_equal received_callbacks?id=ric-registration 19 120
+ cr_api_check_all_sync_events 200 ric-registration EMPTY
+ fi
+
if [ "$PMS_VERSION" == "V2" ]; then
echo "Check the number of types in the agent for each ric"
api_equal json:policy-types?ric_id=ricsim_g1_1 1 120
sleep_wait 120
if [ "$PMS_VERSION" == "V2" ]; then
- api_equal json:policy_instances 0
+ api_equal json:policy-instances 0
else
api_equal json:policy_ids 0
fi
api_get_policy_types 404 ricsim_g1_9
- sim_equal ricsim_g1_9 num_instances 0
-
- api_delete_policy 404 2000
-
# Load config with all rics
consul_config_app ".consul_config_all.json"
sleep_wait 120
if [ "$PMS_VERSION" == "V2" ]; then
- api_equal json:policy_instances 0
+ api_equal json:policy-instances 0
else
api_equal json:policy_ids 0
fi
check_policy_agent_logs
+ if [[ $interface = *"SDNC"* ]]; then
+ check_sdnc_logs
+ fi
+
store_logs ${interface}
done
-
-
-
#### TEST COMPLETE ####
#App names to include in the test, space separated list
INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM SDNC"
+#SUPPORTED TEST ENV FILE
+SUPPORTED_PROFILES="ONAP-MASTER ONAP-GUILIN"
+
. ../common/testcase_common.sh $@
. ../common/agent_api_functions.sh
. ../common/ricsimulator_api_functions.sh
+. ../common/cr_api_functions.sh
#### TEST BEGIN ####
echo "#####################################################################"
if [ $__httpx == "HTTPS" ]; then
- # Path to callback receiver
- CR_PATH="https://$CR_APP_NAME:$CR_EXTERNAL_SECURE_PORT/callbacks"
use_cr_https
use_simulator_https
use_mr_https
use_agent_rest_https
else
- # Path to callback receiver
- CR_PATH="http://$CR_APP_NAME:$CR_EXTERNAL_PORT/callbacks"
use_cr_http
use_simulator_http
use_mr_http
set_agent_debug
- cr_equal received_callbacks 0
mr_equal requests_submitted 0
api_put_service 201 "serv1" 3600 "$CR_PATH/1"
if [ "$PMS_VERSION" == "V2" ]; then
- notificationurl="http://localhost:80"
+ notificationurl=$CR_PATH"/test"
else
notificationurl=""
fi
fi
check_policy_agent_logs
+ if [[ $interface = *"SDNC"* ]]; then
+ check_sdnc_logs
+ fi
store_logs "${__httpx}__${interface}"
done
#App names to include in the test, space separated list
INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM SDNC"
+#SUPPORTED TEST ENV FILE
+SUPPORTED_PROFILES="ONAP-MASTER ONAP-GUILIN"
+
. ../common/testcase_common.sh $@
. ../common/agent_api_functions.sh
. ../common/ricsimulator_api_functions.sh
+. ../common/cr_api_functions.sh
#### TEST BEGIN ####
HTTPX=HTTPS
if [ $HTTPX == "HTTP" ]; then
- # Path to callback receiver
- CR_PATH="http://$CR_APP_NAME:$CR_EXTERNAL_PORT/callbacks"
use_cr_http
use_agent_rest_http
use_sdnc_http
use_simulator_http
else
- # Path to callback receiver
- CR_PATH="https://$CR_APP_NAME:$CR_EXTERNAL_SECURE_PORT/callbacks"
use_cr_https
use_agent_rest_https
use_sdnc_https
MR_MESSAGES=0
if [ "$PMS_VERSION" == "V2" ]; then
- notificationurl="http://localhost:80"
+ notificationurl=$CR_PATH"/test"
else
notificationurl=""
fi
done
if [ "$PMS_VERSION" == "V2" ]; then
- api_equal json:policy_instances $INSTANCES
+ api_equal json:policy-instances $INSTANCES
else
api_equal json:policy_ids $INSTANCES
fi
done
if [ "$PMS_VERSION" == "V2" ]; then
- api_equal json:policy_instances $INSTANCES
+ api_equal json:policy-instances $INSTANCES
else
api_equal json:policy_ids $INSTANCES
fi
done
if [ "$PMS_VERSION" == "V2" ]; then
- api_equal json:policy_instances $INSTANCES
+ api_equal json:policy-instances $INSTANCES
else
api_equal json:policy_ids $INSTANCES
fi
done
if [ "$PMS_VERSION" == "V2" ]; then
- api_equal json:policy_instances $INSTANCES
+ api_equal json:policy-instances $INSTANCES
else
api_equal json:policy_ids $INSTANCES
fi
- cr_equal received_callbacks 0
-
mr_equal requests_submitted $MR_MESSAGES
mr_equal requests_fetched $MR_MESSAGES
mr_equal responses_submitted $MR_MESSAGES
done
check_policy_agent_logs
+check_sdnc_logs
#### TEST COMPLETE ####
#App names to include in the test, space separated list
INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM SDNC"
+#SUPPORTED TEST ENV FILE
+SUPPORTED_PROFILES="ONAP-MASTER ONAP-GUILIN"
+
. ../common/testcase_common.sh $@
. ../common/agent_api_functions.sh
. ../common/ricsimulator_api_functions.sh
generate_uuid
if [ "$PMS_VERSION" == "V2" ]; then
- notificationurl="http://localhost:80"
+ notificationurl=$CR_PATH"/test"
else
notificationurl=""
fi
echo "#####################################################################"
if [ $__httpx == "HTTPS" ]; then
- CR_PATH="https://$CR_APP_NAME:$CR_EXTERNAL_SECURE_PORT/callbacks"
use_cr_https
use_simulator_https
use_mr_https
fi
use_agent_rest_https
else
- CR_PATH="http://$CR_APP_NAME:$CR_EXTERNAL_PORT/callbacks"
use_cr_http
use_simulator_http
use_mr_http
start_mr # Not used, but removes error messages from the agent log
+ start_cr
+
start_control_panel
start_policy_agent
done
check_policy_agent_logs
+ if [[ $interface = *"SDNC"* ]]; then
+ check_sdnc_logs
+ fi
store_logs "${__httpx}__${interface}"
#App names to include in the test, space separated list
INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM"
+#SUPPORTED TEST ENV FILE
+SUPPORTED_PROFILES="ONAP-MASTER ONAP-GUILIN"
+
. ../common/testcase_common.sh $@
. ../common/agent_api_functions.sh
. ../common/ricsimulator_api_functions.sh
#### TEST BEGIN ####
-#Local vars in test script
-##########################
-# Path to callback receiver
-CR_PATH="http://$CR_APP_NAME:$CR_EXTERNAL_PORT/callbacks"
-use_cr_http
-
clean_containers
OSC_NUM_RICS=6
api_put_service 201 "Emergency-response-app" 0 "$CR_PATH/1"
if [ "$PMS_VERSION" == "V2" ]; then
- notificationurl="http://localhost:80"
+ notificationurl=$CR_PATH"/test"
else
notificationurl=""
fi
#App names to include in the test, space separated list
INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM SDNC"
+#SUPPORTED TEST ENV FILE
+SUPPORTED_PROFILES="ONAP-MASTER ONAP-GUILIN"
+
. ../common/testcase_common.sh $@
. ../common/agent_api_functions.sh
. ../common/ricsimulator_api_functions.sh
#Local vars in test script
##########################
-# Path to callback receiver
-CR_PATH="http://$CR_APP_NAME:$CR_EXTERNAL_PORT/callbacks"
if [ "$PMS_VERSION" == "V2" ]; then
- notificationurl="http://localhost:80"
+ notificationurl=$CR_PATH"/test"
else
notificationurl=""
fi
-use_cr_http
-use_agent_rest_http
-use_sdnc_http
-use_simulator_http
+use_agent_rest_https
+use_sdnc_https
+use_simulator_https
clean_containers
start_ric_simulators $RIC_SIM_PREFIX"_g2" $STD_NUM_RICS STD_1.1.3
+if [ "$PMS_VERSION" == "V2" ]; then
+ start_ric_simulators $RIC_SIM_PREFIX"_g3" $STD_NUM_RICS STD_2.0.0
+fi
+
start_mr #Just to prevent errors in the agent log...
start_control_panel
-CR_PATH="https://$CR_APP_NAME:$CR_EXTERNAL_SECURE_PORT/callbacks"
-use_cr_http
+start_control_panel
start_sdnc
start_policy_agent
+set_agent_trace
+
api_get_status 200
# Print the A1 version for OSC
done
-# Print the A1 version for STD
+# Print the A1 version for STD 1.X
for ((i=1; i<=$STD_NUM_RICS; i++))
do
sim_print $RIC_SIM_PREFIX"_g2_"$i interface
done
+if [ "$PMS_VERSION" == "V2" ]; then
+ # Print the A1 version for STD 2.X
+ for ((i=1; i<=$STD_NUM_RICS; i++))
+ do
+ sim_print $RIC_SIM_PREFIX"_g3_"$i interface
+ done
+fi
+
# Load the polictypes in osc
for ((i=1; i<=$OSC_NUM_RICS; i++))
#Check the number of schemas and the individual schemas in OSC
if [ "$PMS_VERSION" == "V2" ]; then
+
api_equal json:policy-types 3 120
for ((i=1; i<=$OSC_NUM_RICS; i++))
fi
+
+
+if [ "$PMS_VERSION" == "V2" ]; then
+
+ # Load the polictypes in std
+ for ((i=1; i<=$STD_NUM_RICS; i++))
+ do
+ sim_put_policy_type 201 $RIC_SIM_PREFIX"_g3_"$i STD_QOS_0_2_0 demo-testdata/STD2/sim_qos.json
+ sim_put_policy_type 201 $RIC_SIM_PREFIX"_g3_"$i STD_QOS2_0.1.0 demo-testdata/STD2/sim_qos2.json
+ done
+
+ #Check the number of schemas and the individual schemas in STD
+ api_equal json:policy-types 5 120
+
+ for ((i=1; i<=$STD_NUM_RICS; i++))
+ do
+ api_equal json:policy-types?ric_id=$RIC_SIM_PREFIX"_g3_"$i 2 120
+ done
+
+ # Check the schemas in STD
+ for ((i=1; i<=$STD_NUM_RICS; i++))
+ do
+ api_get_policy_type 200 STD_QOS_0_2_0 demo-testdata/STD2/qos-agent-modified.json
+ api_get_policy_type 200 'STD_QOS2_0.1.0' demo-testdata/STD2/qos2-agent-modified.json
+ done
+fi
+
+#Check the number of schemas and the individual schemas in OSC
+if [ "$PMS_VERSION" == "V2" ]; then
+ api_equal json:policy-types 5 120
+else
+ api_equal json:policy_types 3 120
+fi
+
+
# Create policies
use_agent_rest_http
do
generate_uuid
api_put_policy 201 "Emergency-response-app" $RIC_SIM_PREFIX"_g2_"$i NOTYPE $((2100+$i)) NOTRANSIENT $notificationurl demo-testdata/STD/pi1_template.json 1
+ if [ "$PMS_VERSION" == "V2" ]; then
+ generate_uuid
+ api_put_policy 201 "Emergency-response-app" $RIC_SIM_PREFIX"_g3_"$i STD_QOS_0_2_0 $((2300+$i)) NOTRANSIENT $notificationurl demo-testdata/STD2/pi1_template.json 1
+ generate_uuid
+ api_put_policy 201 "Emergency-response-app" $RIC_SIM_PREFIX"_g3_"$i 'STD_QOS2_0.1.0' $((2400+$i)) NOTRANSIENT $notificationurl demo-testdata/STD2/pi1_template.json 1
+ fi
done
for ((i=1; i<=$STD_NUM_RICS; i++))
do
sim_equal $RIC_SIM_PREFIX"_g2_"$i num_instances 1
+ if [ "$PMS_VERSION" == "V2" ]; then
+ sim_equal $RIC_SIM_PREFIX"_g3_"$i num_instances 2
+ fi
done
check_policy_agent_logs
+check_sdnc_logs
#### TEST COMPLETE ####
--- /dev/null
+{
+ "scope": {
+ "ueId": "ueXXX",
+ "qosId": "qosXXX"
+ },
+ "qosObjectives": {
+ "priorityLevel": XXX
+ }
+}
\ No newline at end of file
--- /dev/null
+{
+ "$schema": "http://json-schema.org/draft-07/schema#",
+ "description": "STD QOS policy type",
+ "title": "STD_QOS_0_2_0",
+ "type": "object",
+ "properties": {
+ "qosObjectives": {
+ "additionalProperties": false,
+ "type": "object",
+ "properties": {
+ "priorityLevel": {
+ "type": "number"
+ }
+ },
+ "required": [
+ "priorityLevel"
+ ]
+ },
+ "scope": {
+ "additionalProperties": false,
+ "type": "object",
+ "properties": {
+ "qosId": {
+ "type": "string"
+ },
+ "ueId": {
+ "type": "string"
+ }
+ },
+ "required": [
+ "ueId",
+ "qosId"
+ ]
+ }
+ }
+ }
\ No newline at end of file
--- /dev/null
+{
+ "$schema": "http://json-schema.org/draft-07/schema#",
+ "description": "STD QOS2 policy type",
+ "title": "STD_QOS2_0.1.0",
+ "type": "object",
+ "properties": {
+ "qosObjectives": {
+ "additionalProperties": false,
+ "type": "object",
+ "properties": {
+ "priorityLevel": {
+ "type": "number"
+ }
+ },
+ "required": [
+ "priorityLevel"
+ ]
+ },
+ "scope": {
+ "additionalProperties": false,
+ "type": "object",
+ "properties": {
+ "qosId": {
+ "type": "string"
+ },
+ "ueId": {
+ "type": "string"
+ }
+ },
+ "required": [
+ "ueId",
+ "qosId"
+ ]
+ }
+ }
+}
\ No newline at end of file
--- /dev/null
+{
+ "policySchema": {
+ "$schema": "http://json-schema.org/draft-07/schema#",
+ "title": "STD_QOS_0_2_0",
+ "description": "STD QOS policy type",
+ "type": "object",
+ "properties": {
+ "scope": {
+ "type": "object",
+ "properties": {
+ "ueId": {
+ "type": "string"
+ },
+ "qosId": {
+ "type": "string"
+ }
+ },
+ "additionalProperties": false,
+ "required": [
+ "ueId",
+ "qosId"
+ ]
+ },
+ "qosObjectives": {
+ "type": "object",
+ "properties": {
+ "priorityLevel": {
+ "type": "number"
+ }
+ },
+ "additionalProperties": false,
+ "required": [
+ "priorityLevel"
+ ]
+ }
+ }
+ },
+ "statusSchema": {
+ "$schema": "http://json-schema.org/draft-07/schema#",
+ "title": "STD_QOS_0.2.0",
+ "description": "STD QOS policy type status",
+ "type": "object",
+ "properties": {
+ "enforceStatus": {
+ "type": "string"
+ },
+ "enforceReason": {
+ "type": "string"
+ },
+ "additionalProperties": false,
+ "required": [
+ "enforceStatus"
+ ]
+ }
+ }
+ }
\ No newline at end of file
--- /dev/null
+{
+ "policySchema": {
+ "$schema": "http://json-schema.org/draft-07/schema#",
+ "title": "STD_QOS2_0.1.0",
+ "description": "STD QOS2 policy type",
+ "type": "object",
+ "properties": {
+ "scope": {
+ "type": "object",
+ "properties": {
+ "ueId": {
+ "type": "string"
+ },
+ "qosId": {
+ "type": "string"
+ }
+ },
+ "additionalProperties": false,
+ "required": [
+ "ueId",
+ "qosId"
+ ]
+ },
+ "qosObjectives": {
+ "type": "object",
+ "properties": {
+ "priorityLevel": {
+ "type": "number"
+ }
+ },
+ "additionalProperties": false,
+ "required": [
+ "priorityLevel"
+ ]
+ }
+ }
+ },
+ "statusSchema": {
+ "$schema": "http://json-schema.org/draft-07/schema#",
+ "title": "STD_QOS_0.2.0",
+ "description": "STD QOS policy type status",
+ "type": "object",
+ "properties": {
+ "enforceStatus": {
+ "type": "string"
+ },
+ "enforceReason": {
+ "type": "string"
+ },
+ "additionalProperties": false,
+ "required": [
+ "enforceStatus"
+ ]
+ }
+ }
+ }
\ No newline at end of file
Common functions for running two or more auto test scripts as a suite.
`api_curl.sh` \
-A common curl based function for the agent and ecs apis.
+A common curl based function for the agent and ecs apis. Also partly used for the Callback receiver api.
`agent_api_functions.sh` \
Contains functions for adapting towards the Policy Agent API, also via dmaap (using a message-router stub interface)
`do_curl_function.sh`
A script for executing a curl call with a specific url and optional payload. It also compare the response with an expected result in terms of response code and optional returned payload. Intended to be used by test script (for example basic test scripts of other components)
+`cr_api_functions.sh` \
+Contains functions for adapting towards the Callback receiver for checking received callback event.
# Description of functions in testcase_common.sh #
|--|
| None |
+## Function: restart_ecs ##
+Restart the ECS container.
+| arg list |
+|--|
+| None |
+
## Function: use_ecs_rest_http ##
Use http for all API calls to the ECS. This is the default protocol.
| arg list |
| `<logfile-prefix>` | Log file prefix |
-## Function: cr_equal ##
-Tests if a variable value in the Callback Receiver (CR) simulator is equal to a target value.
-Without the timeout, the test sets pass or fail immediately depending on if the variable is equal to the target or not.
-With the timeout, the test waits up to the timeout seconds before setting pass or fail depending on if the variable value becomes equal to the target value or not.
-See the 'cr' dir for more details.
-| arg list |
-|--|
-| `<variable-name> <target-value> [ <timeout-in-sec> ]` |
-
-| parameter | description |
-| --------- | ----------- |
-| `<variable-name>` | Variable name in the CR |
-| `<target-value>` | Target value for the variable |
-| `<timeout-in-sec>` | Max time to wait for the variable to reach the target value |
-
## Function: mr_equal ##
Tests if a variable value in the Message Router (MR) simulator is equal to a target value.
Without the timeout, the test sets pass or fail immediately depending on if the variable is equal to the target or not.
| `<timeout-in-sec>` | Max time to wait for the length to reach the target value |
## Function: api_get_policies() ##
-Test of GET '/policies' or V2 GET '/v2/policy_instances' and optional check of the array of returned policies.
+Test of GET '/policies' or V2 GET '/v2/policy-instances' and optional check of the array of returned policies.
To test the response code only, provide the response code parameter as well as the following three parameters.
To also test the response payload add the 'NOID' for an expected empty array or repeat the last five/seven parameters for each expected policy.
| `<target-value>` | Target value for the variable |
| `<timeout-in-sec>` | Max time to wait for the variable to reach the target value |
+# Description of functions in cr_api_function.sh #
+
+
+
+## Function: cr_equal ##
+Tests if a variable value in the Callback Receiver (CR) simulator is equal to a target value.
+Without the timeout, the test sets pass or fail immediately depending on if the variable is equal to the target or not.
+With the timeout, the test waits up to the timeout seconds before setting pass or fail depending on if the variable value becomes equal to the target value or not.
+See the 'cr' dir for more details.
+| arg list |
+|--|
+| `<variable-name> <target-value> [ <timeout-in-sec> ]` |
+
+| parameter | description |
+| --------- | ----------- |
+| `<variable-name>` | Variable name in the CR |
+| `<target-value>` | Target value for the variable |
+| `<timeout-in-sec>` | Max time to wait for the variable to reach the target value |
+
+## Function: cr_api_check_all_sync_events() ##
+Check the contents of all ric events received for a callback id.
+
+| arg list |
+|--|
+| `<response-code> <id> [ EMPTY | ( <ric-id> )+ ]` |
+
+| parameter | description |
+| --------- | ----------- |
+| `<response-code>` | Expected http response code |
+| `<id>` | Id of the callback destination |
+| `EMPTY` | Indicator for an empty list |
+| `<ric-id>` | Id of the ric |
+
## License
return 1
}
-# API Test function: GET /policies and V2 GET /v2/policy_instances
+# API Test function: GET /policies and V2 GET /v2/policy-instances
# args: <response-code> <ric-id>|NORIC <service-id>|NOSERVICE <policy-type-id>|NOTYPE [ NOID | [<policy-id> <ric-id> <service-id> EMPTY|<policy-type-id> <template-file>]*]
# args(V2): <response-code> <ric-id>|NORIC <service-id>|NOSERVICE <policy-type-id>|NOTYPE [ NOID | [<policy-id> <ric-id> <service-id> EMPTY|<policy-type-id> <transient> <notification-url> <template-file>]*]
# (Function for test scripts)
fi
fi
- query="/v2/policy_instances"$queryparams
+ query="/v2/policy-instances"$queryparams
res="$(__do_curl_to_api PA GET $query)"
status=${res:${#res}-3}
if [ "$targetJson" != "[" ]; then
targetJson=$targetJson","
fi
- targetJson=$targetJson"{\"policy_id\":\"$UUID${arr[$i]}\",\"ric_id\":\"${arr[$i+1]}\",\"service_id\":\"${arr[$i+2]}\",\"policy_type_id\":"
+ targetJson=$targetJson"{\"policy_id\":\"$UUID${arr[$i]}\",\"ric_id\":\"${arr[$i+1]}\",\"service_id\":\"${arr[$i+2]}\",\"policytype_id\":"
if [ "${arr[$i+3]}" == "EMPTY" ]; then
targetJson=$targetJson"\"\","
else
targetJson=$targetJson", \"transient\":$7"
fi
if [ $6 != "NOTYPE" ]; then
- targetJson=$targetJson", \"policy_type_id\":\"$6\""
+ targetJson=$targetJson", \"policytype_id\":\"$6\""
else
- targetJson=$targetJson", \"policy_type_id\":\"\""
+ targetJson=$targetJson", \"policytype_id\":\"\""
fi
if [ $8 != "NOURL" ]; then
targetJson=$targetJson", \"status_notification_uri\":\"$8\""
inputJson=$inputJson", \"transient\":$trans"
fi
if [ $pt != "NOTYPE" ]; then
- inputJson=$inputJson", \"policy_type_id\":$pt"
+ inputJson=$inputJson", \"policytype_id\":\"$pt\""
else
- inputJson=$inputJson", \"policy_type_id\":\"\""
+ inputJson=$inputJson", \"policytype_id\":\"\""
fi
if [ $noti != "NOURL" ]; then
inputJson=$inputJson", \"status_notification_uri\":\"$noti\""
inputJson=$inputJson", \"transient\":$trans"
fi
if [ $pt != "NOTYPE" ]; then
- inputJson=$inputJson", \"policy_type_id\":$pt"
+ inputJson=$inputJson", \"policytype_id\":\"$pt\""
else
- inputJson=$inputJson", \"policy_type_id\":\"\""
+ inputJson=$inputJson", \"policytype_id\":\"\""
fi
if [ $noti != "NOURL" ]; then
inputJson=$inputJson", \"status_notification_uri\":\"$noti\""
else
res=${tmp:0:1}
if [ $res == "0" ]; then
- echo " Process $i : OK"
+ echo " Process $i : OK - "${tmp:1}
else
echo " Process $i : failed - "${tmp:1}
msg="failed"
else
res=${tmp:0:1}
if [ $res == "0" ]; then
- echo " Process $i : OK"
+ echo " Process $i : OK - "${tmp:1}
else
echo " Process $i : failed - "${tmp:1}
msg="failed"
targetJson=$targetJson"]"
if [ "$PMS_VERSION" == "V2" ]; then
- targetJson="{\"policy_type_ids\": $targetJson }"
+ targetJson="{\"policytype_ids\": $targetJson }"
fi
echo "TARGET JSON: $targetJson" >> $HTTPLOG
res=$(python3 ../common/compare_json.py "$targetJson" "$body")
__RESTBASE=$ECS_RESTBASE
__RESTBASE_SECURE=$ECS_RESTBASE_SECURE
__RETRY_CODES=$ECS_RETRY_CODES
+ elif [ $1 == "CR" ]; then
+ __ADAPTER=$CR_ADAPTER
+ __RESTBASE=$CR_RESTBASE
+ __RESTBASE_SECURE=$CR_RESTBASE_SECURE
+ __RETRY_CODES=""
else
paramError=1
fi
if [ $paramError -eq 1 ]; then
((RES_CONF_FAIL++))
- echo "-Incorrect number of parameters to __do_curl_agent " $@ >> $HTTPLOG
+ echo "-Incorrect number of parameters to __do_curl_to_api " $@ >> $HTTPLOG
echo "-Expected: (PA|ECS GET|PUT|POST|DELETE|GET_BATCH|PUT_BATCH|POST_BATCH|DELETE_BATCH <url> [<file>]) | (PA|ECS RESPONSE <correlation-id>)" >> $HTTPLOG
echo "-Returning response 000" >> $HTTPLOG
echo "-000"
payload="$(cat $4 | tr -d '\n' | tr -d ' ' )"
echo "payload: "$payload >> $HTTPLOG
file=" --data-binary "$payload
+ elif [ $# -eq 4 ]; then
+ echo " FILE: $(cat $4)" >> $HTTPLOG
fi
#urlencode the request url since it will be carried by send-request url
requestUrl=$(python3 -c "from __future__ import print_function; import urllib.parse, sys; print(urllib.parse.quote(sys.argv[1]))" "$3")
import sys
import requests
import traceback
+from time import sleep
# disable warning about unverified https requests
from requests.packages import urllib3
start=start
stop=count*num_rics+start
+ total_retry_count=0
+
for i in range(start,stop):
if (i%pids == (pid_id-1)):
payload=template.replace("XXX",str(i))
ric_id=(i%num_rics)+1
ric=ric_base+str(ric_id)
- try:
- headers = {'Content-type': 'application/json'}
- if ("/v2/" in baseurl):
- url=baseurl
-
- data={}
- data["ric_id"]=ric
- data["policy_id"]=uuid+str(i)
- data["service_id"]=serv
- if (trans != "NOTRANSIENT"):
- data["transient"]=trans
- if (pt != "NOTYPE"):
- data["policy_type_id"]=pt
+ retry_cnt=5
+ while(retry_cnt>0):
+ try:
+ headers = {'Content-type': 'application/json'}
+ if ("/v2/" in baseurl):
+ url=baseurl
+
+ data={}
+ data["ric_id"]=ric
+ data["policy_id"]=uuid+str(i)
+ data["service_id"]=serv
+ if (trans != "NOTRANSIENT"):
+ data["transient"]=trans
+ if (pt != "NOTYPE"):
+ data["policytype_id"]=pt
+ else:
+ data["policytype_id"]=""
+ if (noti != "NOURL"):
+ data["status_notification_uri"]=noti
+ data["policy_data"]=json.loads(payload)
+
+ url_out=url
+ data_out=json.dumps(data)
else:
- data["policy_type_id"]=""
- if (noti != "NOURL"):
- data["status_notification_uri"]=noti
- data["policy_data"]=json.loads(payload)
+ url=baseurl+"&id="+uuid+str(i)+"&ric="+str(ric)
+ url_out=url
+ data_out=json.dumps(json.loads(payload))
- url_out=url
- data_out=json.dumps(data)
resp=requests.put(url, data_out, headers=headers, verify=False, timeout=90)
+ except Exception as e1:
+ print("1Put failed for id:"+uuid+str(i)+ ", "+str(e1) + " "+traceback.format_exc())
+ sys.exit()
+
+ if (resp.status_code == None):
+ print("1Put failed for id:"+uuid+str(i)+ ", expected response code: "+str(responsecode)+", got: None")
+ sys.exit()
+
+ if (resp.status_code != responsecode):
+ if (resp.status_code == 503 ) and (retry_cnt > 1):
+ sleep(0.1)
+ retry_cnt -= 1
+ total_retry_count += 1
+ else:
+ print("1Put failed for id:"+uuid+str(i)+ ", expected response code: "+str(responsecode)+", got: "+str(resp.status_code))
+ print(url_out)
+ print(str(data_out))
+ sys.exit()
else:
- url=baseurl+"&id="+uuid+str(i)+"&ric="+str(ric)
- url_out=url
- data_out=json.dumps(json.loads(payload))
- resp=requests.put(url, data_out, headers=headers, verify=False, timeout=90)
- except Exception as e1:
- print("1Put failed for id:"+uuid+str(i)+ ", "+str(e1) + " "+traceback.format_exc())
- sys.exit()
- if (resp.status_code == None):
- print("1Put failed for id:"+uuid+str(i)+ ", expected response code: "+str(responsecode)+", got: None")
- sys.exit()
- if (resp.status_code != responsecode):
- print("1Put failed for id:"+uuid+str(i)+ ", expected response code: "+str(responsecode)+", got: "+str(resp.status_code))
- print(url_out)
- print(str(data_out))
- sys.exit()
-
- print("0")
+ retry_cnt=-1
+
+ if (total_retry_count > 0):
+ print("0 retries:"+str(total_retry_count))
+ else:
+ print("0")
sys.exit()
except Exception as e:
if (api_version == "V2"):
param_ric='ric_id'
param_me='managed_element_ids'
- param_policy_type='policy_type_ids'
+ param_policy_type='policytype_ids'
param_state='state'
else:
param_ric='ricName'
if uuid == "NOUUID":
uuid=""
+ total_retry_count=0
+
stop=count*num_rics+start
for i in range(start,stop):
if (i%pids == (pid_id-1)):
- if ("/v2/policies/" in baseurl):
- url=str(baseurl+uuid+str(i))
- else:
- url=str(baseurl+"?id="+uuid+str(i))
- try:
- resp=requests.delete(url, verify=False, timeout=90)
- except Exception as e1:
- print("1Delete failed for id:"+uuid+str(i)+ ", "+str(e1) + " "+traceback.format_exc())
- sys.exit()
- if (resp.status_code == None):
- print("1Delete failed for id:"+uuid+str(i)+ ", expected response code: "+str(responsecode)+", got: None")
- sys.exit()
- if (resp.status_code != responsecode):
- print("1Delete failed for id:"+uuid+str(i)+ ", expected response code: "+str(responsecode)+", got: "+str(resp.status_code))
- sys.exit()
+ retry_cnt=5
+ while(retry_cnt>0):
+ if ("/v2/policies/" in baseurl):
+ url=str(baseurl+uuid+str(i))
+ else:
+ url=str(baseurl+"?id="+uuid+str(i))
+ try:
+ resp=requests.delete(url, verify=False, timeout=90)
+ except Exception as e1:
+ print("1Delete failed for id:"+uuid+str(i)+ ", "+str(e1) + " "+traceback.format_exc())
+ sys.exit()
+ if (resp.status_code == None):
+ print("1Delete failed for id:"+uuid+str(i)+ ", expected response code: "+str(responsecode)+", got: None")
+ sys.exit()
+ if (resp.status_code != responsecode):
+ if (resp.status_code == 503 ) and (retry_cnt > 1):
+ sleep(0.1)
+ retry_cnt -= 1
+ total_retry_count += 1
+ else:
+ print("1Delete failed for id:"+uuid+str(i)+ ", expected response code: "+str(responsecode)+", got: "+str(resp.status_code))
+ sys.exit()
+ else:
+ retry_cnt=-1
- print("0")
+ if (total_retry_count > 0):
+ print("0 retries:"+str(total_retry_count))
+ else:
+ print("0")
sys.exit()
except Exception as e:
echo " RESP: $res" >> $HTTPLOG
retcode=$?
if [ $retcode -ne 0 ]; then
+ ((RES_CONF_FAIL++))
echo " RETCODE: "$retcode
echo -e $RED" FAIL - fatal error when executing curl."$ERED
return 1
return 0
fi
echo -e $RED" FAIL - expected http response: "$1" but got http response: "$status $ERED
+ ((RES_CONF_FAIL++))
return 1
}
return $?
}
-# DSimulator API: Delete a policy type in a ric
+# Simulator API: Delete a policy type in a ric
# <response-code> <ric-id> <policy-type-id>
# (Function for test scripts)
sim_delete_policy_type() {
# ============LICENSE_END=================================================
#
+TEST_ENV_PROFILE="ONAP-GUILIN"
+
# Set up the image and tags for the test. Do not add the image tag to the image names.
# NOTE: A env var for each container is created by the test script.
# ============LICENSE_END=================================================
#
+TEST_ENV_PROFILE="ONAP-MASTER"
+
# Set up the image and tags for the test. Do not add the image tag to the image names.
# NOTE: A env var for each container is created by the test script.
export ECS_APP_NAME="ecs" # Name for ECS container
ECS_LOGPATH="/var/log/enrichment-coordinator-service/application.log" # Path the application log in the ECS container
export ECS_APP_NAME_ALIAS="enrichment-service-container" # Alias name, name used by the control panel
+export ECS_HOST_MNT_DIR="./mnt" # Mounted dir, relative to compose file, on the host
+export ECS_CONTAINER_MNT_DIR="/var/enrichment-coordinator-service" # Mounted dir in the container
export MR_EXTERNAL_PORT=3905 # MR stub container external port (host -> container)
export MR_INTERNAL_PORT=3905 # MR stub container internal port (container -> container)
export CR_EXTERNAL_SECURE_PORT=8091 # Callback receiver container external secure port (host -> container)
export CR_INTERNAL_SECURE_PORT=8091 # Callback receiver container internal secure port (container -> container)
export CR_APP_NAME="callback-receiver" # Name for the Callback receiver
+export CR_APP_CALLBACK="/callbacks" # Url for callbacks
export PROD_STUB_EXTERNAL_PORT=8092 # Producer stub container external port (host -> container)
export PROD_STUB_INTERNAL_PORT=8092 # Producer stub container internal port (container -> container)
ECS_DMAAPBASE="http://localhost:"$MR_EXTERNAL_PORT # Base url to the Dmaap adapter, http
ECS_DMAAPBASE_SECURE="https://localhost:"$MR_EXTERNAL_SECURE_PORT # Base url to the Dmaap adapter, https
ECS_ADAPTER=$ECS_RESTBASE # Adapter holds the address the ECS R-APP interface (REST OR DMAAP)
- # The values of this var is swiched between the four base url when needed
\ No newline at end of file
+ # The values of this var is swiched between the four base url when needed
+
+CR_RESTBASE="http://localhost:"$CR_EXTERNAL_PORT # Base url to the Callback receiver REST interface
+CR_RESTBASE_SECURE="https://localhost:"$CR_EXTERNAL_SECURE_PORT # Base url to the secure Callback receiver REST interface
+CR_ADAPTER=$CR_RESTBASE # Adapter holds the address the CR admin interface (REST only)
+ # The values of this var is swiched between the two base url when needed
\ No newline at end of file
# ============LICENSE_END=================================================
#
+TEST_ENV_PROFILE="ORAN-MASTER"
+
# Set up the image and tags for the test. Do not add the image tag to the image names.
# NOTE: A env var for each container is created by the test script.
export ECS_APP_NAME="ecs" # Name for ECS container
ECS_LOGPATH="/var/log/enrichment-coordinator-service/application.log" # Path the application log in the ECS container
export ECS_APP_NAME_ALIAS="enrichment-service-container" # Alias name, name used by the control panel
+export ECS_HOST_MNT_DIR="./mnt" # Mounted dir, relative to compose file, on the host
+export ECS_CONTAINER_MNT_DIR="/var/enrichment-coordinator-service" # Mounted dir in the container
export MR_EXTERNAL_PORT=3905 # MR stub container external port (host -> container)
export MR_INTERNAL_PORT=3905 # MR stub container internal port (container -> container)
export CR_EXTERNAL_SECURE_PORT=8091 # Callback receiver container external secure port (host -> container)
export CR_INTERNAL_SECURE_PORT=8091 # Callback receiver container internal secure port (container -> container)
export CR_APP_NAME="callback-receiver" # Name for the Callback receiver
+export CR_APP_CALLBACK="/callbacks" # Url for callbacks
export PROD_STUB_EXTERNAL_PORT=8092 # Producer stub container external port (host -> container)
export PROD_STUB_INTERNAL_PORT=8092 # Producer stub container internal port (container -> container)
ECS_DMAAPBASE="http://localhost:"$MR_EXTERNAL_PORT # Base url to the Dmaap adapter, http
ECS_DMAAPBASE_SECURE="https://localhost:"$MR_EXTERNAL_SECURE_PORT # Base url to the Dmaap adapter, https
ECS_ADAPTER=$ECS_RESTBASE # Adapter holds the address the ECS R-APP interface (REST OR DMAAP)
- # The values of this var is swiched between the four base url when needed
\ No newline at end of file
+ # The values of this var is swiched between the four base url when needed
+
+CR_RESTBASE="http://localhost:"$CR_EXTERNAL_PORT # Base url to the Callback receiver REST interface
+CR_RESTBASE_SECURE="https://localhost:"$CR_EXTERNAL_SECURE_PORT # Base url to the secure Callback receiver REST interface
+CR_ADAPTER=$CR_RESTBASE # Adapter holds the address the CR admin interface (REST only)
+ # The values of this var is swiched between the two base url when needed
\ No newline at end of file
# Create a log dir for the test case
mkdir -p $TESTLOGS/$ATC
+# Save create for current logs
+mkdir -p $TESTLOGS/$ATC/previous
+
+rm $TESTLOGS/$ATC/previous/*.log &> /dev/null
+rm $TESTLOGS/$ATC/previous/*.txt &> /dev/null
+rm $TESTLOGS/$ATC/previous/*.json &> /dev/null
+
+mv $TESTLOGS/$ATC/*.log $TESTLOGS/$ATC/previous &> /dev/null
+mv $TESTLOGS/$ATC/*.txt $TESTLOGS/$ATC/previous &> /dev/null
+mv $TESTLOGS/$ATC/*.txt $TESTLOGS/$ATC/previous &> /dev/null
+
# Clear the log dir for the test case
rm $TESTLOGS/$ATC/*.log &> /dev/null
rm $TESTLOGS/$ATC/*.txt &> /dev/null
if [ -f "$TEST_ENV_VAR_FILE" ]; then
echo -e $BOLD"Sourcing env vars from: "$TEST_ENV_VAR_FILE$EBOLD
. $TEST_ENV_VAR_FILE
+
+ if [ -z "$TEST_ENV_PROFILE" ] || [ -z "$SUPPORTED_PROFILES" ]; then
+ echo -e $YELLOW"This test case may no work with selected test env file. TEST_ENV_PROFILE is missing in test_env file or SUPPORTED_PROFILES is missing in test case file"$EYELLOW
+ else
+ if [[ "$SUPPORTED_PROFILES" == *"$TEST_ENV_PROFILE"* ]]; then
+ echo -e $GREEN"Test case support the selected test env file"$EGREEN
+ else
+ echo -e $RED"Test case does not support the selected test env file"$ERED
+ echo -e $RED"Exiting...."$ERED
+ exit 1
+ fi
+ fi
else
echo -e $RED"Selected env var file does not exist: "$TEST_ENV_VAR_FILE$ERED
echo " Select one of following env var file matching the intended target of the test"
export CR_HTTPX="http"
export CR_PORT=$CR_INTERNAL_PORT
export CR_LOCAL_PORT=$CR_EXTERNAL_PORT #When CR is running outside the docker net
+export CR_PATH="$CR_HTTPX://$CR_APP_NAME:$CR_PORT$CR_APP_CALLBACK"
export PROD_STUB_HTTPX="http"
export PROD_STUB_PORT=$PROD_STUB_INTERNAL_PORT
((RES_CONF_FAIL++))
echo ""
echo -e $RED" Container $BOLD${appname}$EBOLD could not be started"$ERED
- return 1
+ echo -e $RED" Stopping script..."$ERED
+ exit 1
fi
if [ $localport -eq 0 ]; then
while [ $localport -eq 0 ]; do
else
TS_TMP=$SECONDS
while [ $(($TS_TMP+$i)) -gt $SECONDS ]; do
- echo -ne " Waiting for container ${appname} service status...retrying in $(($TS_TMP+$i-$SECONDS)) seconds ${SAMELINE}"
+ echo -ne " Waiting for container ${appname} service status...$(($SECONDS-$TSTART)) seconds, retrying in $(($TS_TMP+$i-$SECONDS)) seconds ${SAMELINE}"
sleep 1
done
fi
if [ "$pa_st" = "false" ]; then
((RES_CONF_FAIL++))
- echo -e $RED" Container ${appname} did not respond to service status"$ERED
+ echo -e $RED" Container ${appname} did not respond to service status in $(($SECONDS-$TSTART)) seconds"$ERED
return 0
fi
if [ $? -ne 0 ]; then
echo -e $RED"Problem to launch container(s) with docker-compose"$ERED
cat .dockererr
+ echo -e $RED"Stopping script...."$ERED
+ exit 1
fi
elif [ "$2" == "STANDALONE" ]; then
echo "Skipping docker-compose"
if [ $? -ne 0 ]; then
echo -e $RED"Problem to launch container(s) with docker-compose"$ERED
cat .dockererr
+ echo -e $RED"Stopping script...."$ERED
+ exit 1
fi
fi
app_prefix=""
export CR_HTTPX="http"
export CR_PORT=$CR_INTERNAL_PORT
export CR_LOCAL_PORT=$CR_EXTERNAL_PORT
+ export CR_PATH="$CR_HTTPX://$CR_APP_NAME:$CR_PORT$CR_APP_CALLBACK"
echo ""
}
export CR_HTTPX="https"
export CR_PORT=$CR_INTERNAL_SECURE_PORT
export CR_LOCAL_PORT=$CR_EXTERNAL_SECURE_PORT
+ export CR_PATH="$CR_HTTPX://$CR_APP_NAME:$CR_PORT$CR_APP_CALLBACK"
echo ""
}
# args: -
# (Function for test scripts)
use_agent_dmaap_https() {
- echo -e "Using $BOLD https $EBOLD and $BOLD REST $EBOLD towards the agent"
+ echo -e "Using $BOLD https $EBOLD and $BOLD DMAAP $EBOLD towards the agent"
export ADAPTER=$DMAAPBASE_SECURE
echo ""
return 0
__start_container ecs NODOCKERARGS $ECS_APP_NAME $ECS_EXTERNAL_PORT "/status" "http"
}
+# Restart ECS
+# args: -
+# (Function for test scripts)
+restart_ecs() {
+ docker restart $ECS_APP_NAME &> ./tmp/.dockererr
+ if [ $? -ne 0 ]; then
+ __print_err "Could restart $ECS_APP_NAME" $@
+ cat ./tmp/.dockererr
+ ((RES_CONF_FAIL++))
+ return 1
+ fi
+
+ __check_container_start $ECS_APP_NAME $ECS_EXTERNAL_PORT "/status" "http"
+ echo ""
+ return 0
+}
+
# All calls to ECS will be directed to the ECS REST interface from now on
# args: -
# (Function for test scripts)
__print_err "need one arg, <file-prefix>" $@
exit 1
fi
- echo -e $BOLD"Storing all container logs using prefix: "$1$EBOLD
+ echo -e $BOLD"Storing all container logs in $TESTLOGS/$ATC using prefix: "$1$EBOLD
docker stats --no-stream > $TESTLOGS/$ATC/$1_docker_stats.log 2>&1
### Generic test cases for varaible checking
-# Tests if a variable value in the CR is equal to a target value and and optional timeout.
-# Arg: <variable-name> <target-value> - This test set pass or fail depending on if the variable is
-# equal to the target or not.
-# Arg: <variable-name> <target-value> <timeout-in-sec> - This test waits up to the timeout seconds
-# before setting pass or fail depending on if the variable value becomes equal to the target
-# value or not.
-# (Function for test scripts)
-cr_equal() {
- if [ $# -eq 2 ] || [ $# -eq 3 ]; then
- __var_test "CR" "$LOCALHOST$CR_EXTERNAL_PORT/counter/" $1 "=" $2 $3
- else
- ((RES_CONF_FAIL++))
- __print_err "Wrong args to cr_equal, needs two or three args: <sim-param> <target-value> [ timeout ]" $@
- fi
-}
-
# Tests if a variable value in the MR stub is equal to a target value and and optional timeout.
# Arg: <variable-name> <target-value> - This test set pass or fail depending on if the variable is
# equal to the target or not.
FROM python:3.8-slim-buster
+#install nginx
+RUN apt-get update
+RUN apt-get install -y nginx=1.14.*
+
COPY app/ /usr/src/app/
COPY cert/ /usr/src/app/cert/
RUN chmod +x start.sh
-#install nginx
-RUN apt-get update
-RUN apt-get install -y nginx=1.14.*
-
CMD [ "./start.sh" ]
The callback receiver is intended for function tests to simulate a RAPP.
The callback receiver exposes the read and write urls, used by the agent, as configured in service.
-The callback receiver receives notifications from PMS when synchronization happens between PMS and RICs.
+The callback receiver receives notifications from PMS when synchronization happens between PMS and RICs. However, the callback receiver can be uses to receive any json payload from any source.
# Ports and certificates
>Send a message to CR<br>
This method puts a request message from PMS to notify that sychronization between PMS and certain RIC happens.<br>
-```URI and payload, (PUT or POST): /callbacks/<id> <json array of response messages>```<br><br>
+```URI and payload, (PUT or POST): /callbacks/<id> <json messages>```<br>
```response: OK 200 or 500 for other errors```
+>Fetch one message for an id from CR<br>
+This method fetches the oldes message for an id, and removes the message.<br>
+```URI and payload, (GET): /get-event/<id>```<br>
+```response: <json messages> 200 or 500 for other errors```
+
+>Fetch all messages for an id from CR<br>
+This method fetches all message in an array for an id, and removes all messages.<br>
+```URI and payload, (GET): /get-all-events/<id>```<br>
+```response: <json array of json messages> 200 or 500 for other errors```
+
+>Dump all currently wating callback messages in CR<br>
+This method fetches all message in an array for an id. Messages are left intact in the CR.<br>
+```URI and payload, (GET): /db```<br>
+```response: <json> 200```
+
>Metrics - counters<br>
There are a number of counters that can be read to monitor the message processing. Do a http GET on any of the current counters and an integer value will be returned with http response code 200.
```/counter/received_callbacks``` - The total number of received callbacks<br>
```/counter/fetched_callbacks``` - The total number of fetched callbacks<br>
```/counter/current_messages``` - The current number of callback messages waiting to be fetched<br>
+All counters also support the query parameter "id" to fetch counter for one individual id, eg ```/counter/current_messages?id=my-id```
### Build and start ###
# ============LICENSE_END=================================================
#
-from flask import Flask, request
+from flask import Flask, request, Response
from time import sleep
import time
import datetime
import json
-from flask import Flask
-from flask import Response
import traceback
app = Flask(__name__)
# Metrics vars
cntr_msg_callbacks=0
cntr_msg_fetched=0
+cntr_callbacks={}
# Request and response constants
CALLBACK_URL="/callbacks/<string:id>"
APP_READ_URL="/get-event/<string:id>"
+APP_READ_ALL_URL="/get-all-events/<string:id>"
+DUMP_ALL_URL="/db"
MIME_TEXT="text/plain"
MIME_JSON="application/json"
# Fetch the oldest callback message for an id
# URI and parameter, (GET): /get-event/<id>
-# response: message + 200 or 204
+# response: message + 200 or just 204 or just 500(error)
@app.route(APP_READ_URL,
methods=['GET'])
def receiveresponse(id):
try:
if ((id in msg_callbacks.keys()) and (len(msg_callbacks[id]) > 0)):
cntr_msg_fetched+=1
- msg=str(msg_callbacks[id][0])
- print("Fetching msg for id: "+id+", msg="+msg)
+ cntr_callbacks[id][1]+=1
+ msg=msg_callbacks[id][0]
+ print("Fetching msg for id: "+id+", msg="+str(msg))
del msg_callbacks[id][0]
- return msg,200
+ return json.dumps(msg),200
print("No messages for id: "+id)
except Exception as e:
print(CAUGHT_EXCEPTION+str(e))
+ traceback.print_exc()
+ return "",500
return "",204
+# Fetch all callback message for an id in an array
+# URI and parameter, (GET): /get-all-events/<id>
+# response: message + 200 or just 500(error)
+@app.route(APP_READ_ALL_URL,
+ methods=['GET'])
+def receiveresponse_all(id):
+ global msg_callbacks
+ global cntr_msg_fetched
+
+ try:
+ if ((id in msg_callbacks.keys()) and (len(msg_callbacks[id]) > 0)):
+ cntr_msg_fetched+=len(msg_callbacks[id])
+ cntr_callbacks[id][1]+=len(msg_callbacks[id])
+ msg=msg_callbacks[id]
+ print("Fetching all msgs for id: "+id+", msg="+str(msg))
+ del msg_callbacks[id]
+ return json.dumps(msg),200
+ print("No messages for id: "+id)
+ except Exception as e:
+ print(CAUGHT_EXCEPTION+str(e))
+ traceback.print_exc()
+ return "",500
+
+ msg=[]
+ return json.dumps(msg),200
# Receive a callback message
-# URI and payload, (PUT or POST): /callbacks/<id> <json array of response messages>
+# URI and payload, (PUT or POST): /callbacks/<id> <json messages>
# response: OK 200 or 500 for other errors
@app.route(CALLBACK_URL,
methods=['PUT','POST'])
print("Received callback for id: "+id +", content-type="+request.content_type)
try:
if (request.content_type == MIME_JSON):
- msg = request.json
+ data = request.data
+ msg = json.loads(data)
print("Payload(json): "+str(msg))
- elif (request.content_type == MIME_TEXT):
- msg= request.form
- print("Payload(text): "+str(msg))
else:
- msg="\"\""
- print("Payload(content-type="+request.content_type+"). Setting data to empty, quoted, string")
- except:
- msg="\"\""
- print("(Exception) Payload does not contain any json or text data, setting empty string as payload")
+ msg={}
+ print("Payload(content-type="+request.content_type+"). Setting empty json as payload")
+ except Exception as e:
+ msg={}
+ print("(Exception) Payload does not contain any json, setting empty json as payload")
+ traceback.print_exc()
cntr_msg_callbacks += 1
if (id in msg_callbacks.keys()):
else:
msg_callbacks[id]=[]
msg_callbacks[id].append(msg)
+
+ if (id in cntr_callbacks.keys()):
+ cntr_callbacks[id][0] += 1
+ else:
+ cntr_callbacks[id]=[]
+ cntr_callbacks[id].append(1)
+ cntr_callbacks[id].append(0)
+
except Exception as e:
print(CAUGHT_EXCEPTION+str(e))
- return 'OK',500
+ traceback.print_exc()
+ return 'NOTOK',500
return 'OK',200
+### Functions for test ###
+
+# Dump the whole db of current callbacks
+# URI and parameter, (GET): /db
+# response: message + 200
+@app.route(DUMP_ALL_URL,
+ methods=['GET'])
+def dump_db():
+ return json.dumps(msg_callbacks),200
### Functions for metrics read out ###
@app.route('/counter/received_callbacks',
methods=['GET'])
def requests_submitted():
- return Response(str(cntr_msg_callbacks), status=200, mimetype=MIME_TEXT)
+ req_id = request.args.get('id')
+ if (req_id is None):
+ return Response(str(cntr_msg_callbacks), status=200, mimetype=MIME_TEXT)
+
+ if (req_id in cntr_callbacks.keys()):
+ return Response(str(cntr_callbacks[req_id][0]), status=200, mimetype=MIME_TEXT)
+ else:
+ return Response(str("0"), status=200, mimetype=MIME_TEXT)
@app.route('/counter/fetched_callbacks',
methods=['GET'])
def requests_fetched():
- return Response(str(cntr_msg_fetched), status=200, mimetype=MIME_TEXT)
+ req_id = request.args.get('id')
+ if (req_id is None):
+ return Response(str(cntr_msg_fetched), status=200, mimetype=MIME_TEXT)
+
+ if (req_id in cntr_callbacks.keys()):
+ return Response(str(cntr_callbacks[req_id][1]), status=200, mimetype=MIME_TEXT)
+ else:
+ return Response(str("0"), status=200, mimetype=MIME_TEXT)
@app.route('/counter/current_messages',
methods=['GET'])
def current_messages():
- return Response(str(cntr_msg_callbacks-cntr_msg_fetched), status=200, mimetype=MIME_TEXT)
-
+ req_id = request.args.get('id')
+ if (req_id is None):
+ return Response(str(cntr_msg_callbacks-cntr_msg_fetched), status=200, mimetype=MIME_TEXT)
+
+ if (req_id in cntr_callbacks.keys()):
+ return Response(str(cntr_callbacks[req_id][0]-cntr_callbacks[req_id][1]), status=200, mimetype=MIME_TEXT)
+ else:
+ return Response(str("0"), status=200, mimetype=MIME_TEXT)
### Admin ###
RESULT="OK"
do_curl GET / 200
+echo "=== Reset ==="
+RESULT="*"
+do_curl POST /reset 200
echo "=== Get counter - callbacks ==="
RESULT="0"
RESULT="0"
do_curl GET /counter/current_messages 200
+echo "=== Send a request non json ==="
+RESULT="*"
+#create payload
+echo "DATA" > .tmp.json
+do_curl POST '/callbacks/test' 200 .tmp.json
echo "=== Send a request ==="
RESULT="*"
#create payload
-echo "\"DATA-MSG\"" > .tmp.json
+echo "{\"DATA-MSG\":\"msg\"}" > .tmp.json
do_curl POST '/callbacks/test' 200 .tmp.json
RESULT="*"
do_curl GET '/get-event/wrongid' 204
-
+# Test counters for all ids
echo "=== Get counter - callbacks ==="
-RESULT="1"
+RESULT="2"
do_curl GET /counter/received_callbacks 200
echo "=== Get counter - fetched events ==="
do_curl GET /counter/fetched_callbacks 200
echo "=== Get counter - current events ==="
-RESULT="1"
+RESULT="2"
do_curl GET /counter/current_messages 200
+# Test counter for one id
+echo "=== Get counter - callbacks ==="
+RESULT="2"
+do_curl GET /counter/received_callbacks?id=test 200
+
+echo "=== Get counter - fetched events ==="
+RESULT="0"
+do_curl GET /counter/fetched_callbacks?id=test 200
+
+echo "=== Get counter - current events ==="
+RESULT="2"
+do_curl GET /counter/current_messages?id=test 200
+
+# Test counter for dummy id
+echo "=== Get counter - callbacks ==="
+RESULT="0"
+do_curl GET /counter/received_callbacks?id=dummy 200
+
+echo "=== Get counter - fetched events ==="
+RESULT="0"
+do_curl GET /counter/fetched_callbacks?id=dummy 200
+
+echo "=== Get counter - current events ==="
+RESULT="0"
+do_curl GET /counter/current_messages?id=dummy 200
+
+
+echo "=== Fetch an event ==="
+RESULT="json:{}"
+do_curl GET '/get-event/test' 200
echo "=== Fetch an event ==="
-RESULT="DATA-MSG"
+RESULT="json:{\"DATA-MSG\":\"msg\"}"
do_curl GET '/get-event/test' 200
echo "=== Fetch an event again ==="
do_curl GET '/get-event/test' 204
echo "=== Get counter - callbacks ==="
-RESULT="1"
+RESULT="2"
do_curl GET /counter/received_callbacks 200
echo "=== Get counter - fetched events ==="
-RESULT="1"
+RESULT="2"
+do_curl GET /counter/fetched_callbacks 200
+
+echo "=== Get counter - current events ==="
+RESULT="0"
+do_curl GET /counter/current_messages 200
+
+# Test counter for one id
+echo "=== Get counter - callbacks ==="
+RESULT="2"
+do_curl GET /counter/received_callbacks?id=test 200
+
+echo "=== Get counter - fetched events ==="
+RESULT="2"
+do_curl GET /counter/fetched_callbacks?id=test 200
+
+echo "=== Get counter - current events ==="
+RESULT="0"
+do_curl GET /counter/current_messages?id=test 200
+
+echo "=== Send a request ==="
+RESULT="*"
+#create payload
+echo "{\"DATA-MSG\":\"msg\"}" > .tmp.json
+do_curl POST '/callbacks/test' 200 .tmp.json
+
+echo "=== Send a request ==="
+RESULT="*"
+#create payload
+echo "{\"DATA-MSG2\":\"msg2\"}" > .tmp.json
+do_curl POST '/callbacks/test' 200 .tmp.json
+
+echo "=== Send a request ==="
+RESULT="*"
+#create payload
+echo "{\"DATA-MSG3\":\"msg3\"}" > .tmp.json
+do_curl POST '/callbacks/test1' 200 .tmp.json
+
+echo "=== Get counter - callbacks ==="
+RESULT="5"
+do_curl GET /counter/received_callbacks 200
+
+echo "=== Get counter - fetched events ==="
+RESULT="2"
do_curl GET /counter/fetched_callbacks 200
echo "=== Get counter - current events ==="
+RESULT="3"
+do_curl GET /counter/current_messages 200
+
+# Test counter for one id, test1
+echo "=== Get counter - callbacks ==="
+RESULT="1"
+do_curl GET /counter/received_callbacks?id=test1 200
+
+echo "=== Get counter - fetched events ==="
RESULT="0"
+do_curl GET /counter/fetched_callbacks?id=test1 200
+
+echo "=== Get counter - current events ==="
+RESULT="1"
+do_curl GET /counter/current_messages?id=test1 200
+
+echo "=== Fetch all events ==="
+RESULT="json:[{\"DATA-MSG2\":\"msg2\"},{\"DATA-MSG\":\"msg\"}]"
+do_curl GET '/get-all-events/test' 200
+
+echo "=== Get counter - callbacks ==="
+RESULT="5"
+do_curl GET /counter/received_callbacks 200
+
+echo "=== Get counter - fetched events ==="
+RESULT="4"
+do_curl GET /counter/fetched_callbacks 200
+
+echo "=== Get counter - current events ==="
+RESULT="1"
do_curl GET /counter/current_messages 200
echo "=== CR reset ==="
docker build -t callback-receiver .
-docker run -it -p 8090:8090 -p 8091:8091 callback-receiver
+docker run --rm -it -p 8090:8090 -p 8091:8091 callback-receiver
var http = require('http');
var express = require('express');
+const { POINT_CONVERSION_HYBRID } = require('constants')
var app = express();
var fieldSize=32;
var ps_producer_jobs_arr=new Array(0)
var ps_producer_delivery_arr=new Array(0)
+//Full CR DB
+var cr_db={}
+
//Counts the number of get request for the html page
var getCtr=0
var refreshCount_ecs=-1
+var refreshCount_cr=-1
+
var ricbasename="ricsim"
function fetchAllMetrics_pol() {
}, 500)
}
+function fetchAllMetrics_cr() {
+
+ console.log("Fetching CR DB - timer:" + refreshCount_ecs)
+
+ if (refreshCount_cr < 0) {
+ refreshCount_cr = -1
+ return
+ } else {
+ refreshCount_cr = refreshCount_cr - 1
+ }
+ setTimeout(() => {
+
+ if (checkFunctionFlag("cr_stat")) {
+ getSimCtr(LOCALHOST+CR_PORT+"/db", 0, function(data, index) {
+ ecs4=""
+ try {
+ cr_db=JSON.parse(data);
+ }
+ catch (err) {
+ cr_db={}
+ }
+ });
+ clearFlag("cr_stat")
+ }
+ fetchAllMetrics_cr();
+ }, 500)
+}
+
+// Monitor for CR db
+app.get("/mon3",function(req, res){
+
+ console.log("Creating CR DB page - timer: " + refreshCount_ecs)
+
+ if (refreshCount_cr < 0) {
+ refreshCount_cr=5
+ fetchAllMetrics_cr()
+ }
+ refreshCount_cr=5
+ var json_str=JSON.stringify(cr_db, null, 1)
+ var htmlStr = "<!DOCTYPE html>" +
+ "<html>" +
+ "<head>" +
+ "<meta http-equiv=\"refresh\" content=\"2\">"+ //2 sec auto refresh
+ "<title>CR DB dump</title>"+
+ "</head>" +
+ "<body style=\"white-space: pre-wrap\">" +
+ json_str +
+ "</body>" +
+ "</html>";
+ res.send(htmlStr);
+})
+
// Monitor for ECS
app.get("/mon2",function(req, res){
httpServer.listen(httpPort);
console.log("Simulator monitor listening (http) at "+httpPort);
console.log("Open the web page on localhost:9999/mon to view the policy statistics page.")
-console.log("Open the web page on localhost:9999/mon2 to view the enrichment statistics page.")
\ No newline at end of file
+console.log("Open the web page on localhost:9999/mon2 to view the enrichment statistics page.")
+console.log("Open the web page on localhost:9999/mon3 to view CR DB in json.")
\ No newline at end of file