.tmp.curl.json
.consul*
.ext.consul*
+.dockererr
. ../common/testcase_common.sh $@
. ../common/agent_api_functions.sh
-
+. ../common/ricsimulator_api_functions.sh
#### TEST BEGIN ####
start_control_panel
-#start_sdnc
-
start_policy_agent
-use_agent_rest
+set_agent_debug
+
+use_agent_rest_http
api_get_status 200
# Create policies
-use_agent_rest
+use_agent_rest_http
-api_put_service 201 "rapp1" 3600 "$CR_PATH/callbacks/1"
+api_put_service 201 "rapp1" 3600 "$CR_PATH/1"
api_put_policy 201 "rapp1" ricsim_g1_1 1 2000 testdata/OSC/pi1_template.json 1
sim_equal ricsim_g1_1 num_instances 2
-use_agent_rest
+use_agent_rest_http
api_put_policy 201 "rapp1" ricsim_g2_1 NOTYPE 2100 testdata/STD/pi1_template.json 1
#Update policies
-use_agent_rest
+use_agent_rest_http
api_put_service 200 "rapp1" 3600 "$CR_PATH/callbacks/1"
sim_equal ricsim_g1_1 num_instances 2
-use_agent_rest
+use_agent_rest_http
api_put_policy 200 "rapp1" ricsim_g2_1 NOTYPE 2100 testdata/STD/pi1_template.json 1
use_agent_dmaap
api_delete_policy 204 2000
-use_agent_rest
+use_agent_rest_http
api_delete_policy 204 3000
use_agent_dmaap
api_delete_policy 204 2100
-use_agent_rest
+use_agent_rest_http
api_delete_policy 204 3100
sim_equal ricsim_g1_1 num_instances 0
sim_equal ricsim_g2_1 num_instances 0
# Check policy removal
-use_agent_rest
+use_agent_rest_http
api_get_policy 404 2000
api_get_policy 404 3000
api_get_policy 404 2100
# Tested variants of REST/DMAAP/SDNC config
TESTED_VARIANTS="REST DMAAP REST+SDNC DMAAP+SDNC"
+#Test agent and simulator protocol versions (others are http only)
+TESTED_PROTOCOLS="HTTP HTTPS"
-for interface in $TESTED_VARIANTS ; do
+for __httpx in $TESTED_PROTOCOLS ; do
+ for interface in $TESTED_VARIANTS ; do
- echo "#####################################################################"
- echo "#####################################################################"
- echo "### Testing agent: "$interface
- echo "#####################################################################"
- echo "#####################################################################"
+ echo "#####################################################################"
+ echo "#####################################################################"
+ echo "### Testing agent: "$interface
+ echo "#####################################################################"
+ echo "#####################################################################"
- # Clean container and start all needed containers #
- clean_containers
+ # Clean container and start all needed containers #
+ clean_containers
- start_ric_simulators ricsim_g1 1 OSC_2.1.0
- start_ric_simulators ricsim_g2 1 STD_1.1.3
+ if [ $__httpx == "HTTPS" ]; then
+ echo "Using secure ports towards simulators"
+ use_simulator_https
+ else
+ echo "Using non-secure ports towards simulators"
+ use_simulator_http
+ fi
- start_mr
+ start_ric_simulators ricsim_g1 1 OSC_2.1.0
+ start_ric_simulators ricsim_g2 1 STD_1.1.3
- start_cr
+ start_mr
- start_consul_cbs
+ start_cr
- if [ $interface == "SDNC" ] || [ $interface == "DMAAP+SDNC" ]; then
- prepare_consul_config SDNC ".consul_config.json"
- else
- prepare_consul_config NOSDNC ".consul_config.json"
- fi
+ start_consul_cbs
- consul_config_app ".consul_config.json"
+ if [ $interface == "REST+SDNC" ] || [ $interface == "DMAAP+SDNC" ]; then
+ prepare_consul_config SDNC ".consul_config.json"
+ else
+ prepare_consul_config NOSDNC ".consul_config.json"
+ fi
- start_control_panel
+ consul_config_app ".consul_config.json"
- if [ $interface == "SDNC" ] || [ $interface == "DMAAP+SDNC" ]; then
- start_sdnc
- fi
+ start_control_panel
- start_policy_agent
+ if [ $interface == "REST+SDNC" ] || [ $interface == "DMAAP+SDNC" ]; then
+ start_sdnc
+ fi
- if [ $interface == "DMAAP" ] || [ $interface == "DMAAP+SDNC" ]; then
- use_agent_dmaap
- else
- use_agent_rest
- fi
+ start_policy_agent
+ if [ $interface == "DMAAP" ] || [ $interface == "DMAAP+SDNC" ]; then
+ use_agent_dmaap
+ else
+ if [ $__httpx == "HTTPS" ]; then
+ echo "Using secure ports towards the agent"
+ use_agent_rest_https
+ else
+ echo "Using non-secure ports towards the agent"
+ use_agent_rest_http
+ fi
+ fi
- cr_equal received_callbacks 0
- mr_equal requests_submitted 0
- sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json
- sim_put_policy_type 201 ricsim_g1_1 2 testdata/OSC/sim_2.json
+ cr_equal received_callbacks 0
+ mr_equal requests_submitted 0
- api_equal json:rics 2 60
+ sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json
+ sim_put_policy_type 201 ricsim_g1_1 2 testdata/OSC/sim_2.json
- api_equal json:policy_schemas 3 120
+ api_equal json:rics 2 60
- api_equal json:policy_types 3
+ api_equal json:policy_schemas 3 120
- api_equal json:policies 0
+ api_equal json:policy_types 3
- api_equal json:policy_ids 0
+ api_equal json:policies 0
+ api_equal json:policy_ids 0
- echo "############################################"
- echo "############## Health check ################"
- echo "############################################"
- api_get_status 200
+ echo "############################################"
+ echo "############## Health check ################"
+ echo "############################################"
- echo "############################################"
- echo "##### Service registry and supervision #####"
- echo "############################################"
+ api_get_status 200
- api_get_services 404 "rapp1"
+ echo "############################################"
+ echo "##### Service registry and supervision #####"
+ echo "############################################"
- api_put_service 201 "rapp1" 1000 "$CR_PATH/1"
+ api_get_services 404 "rapp1"
- api_put_service 200 "rapp1" 2000 "$CR_PATH/1"
+ api_put_service 201 "rapp1" 1000 "$CR_PATH/1"
+ api_put_service 200 "rapp1" 2000 "$CR_PATH/1"
- api_put_service 400 "rapp2" -1 "$CR_PATH/2"
- api_put_service 400 "rapp2" "wrong" "$CR_PATH/2"
+ api_put_service 400 "rapp2" -1 "$CR_PATH/2"
- api_put_service 400 "rapp2" 100 "/test"
+ api_put_service 400 "rapp2" "wrong" "$CR_PATH/2"
- api_put_service 400 "rapp2" 100 "test-path"
+ api_put_service 400 "rapp2" 100 "/test"
- api_put_service 201 "rapp2" 300 "ftp://localhost:80/test"
+ api_put_service 400 "rapp2" 100 "test-path"
- api_get_services 200 "rapp1" "rapp1" 2000 "$CR_PATH/1"
+ api_put_service 201 "rapp2" 300 "ftp://localhost:80/test"
- api_get_service_ids 200 "rapp1" "rapp2"
+ api_get_services 200 "rapp1" "rapp1" 2000 "$CR_PATH/1"
+ api_get_service_ids 200 "rapp1" "rapp2"
- api_put_service 201 "rapp3" 5000 "$CR_PATH/3"
+ api_put_service 201 "rapp3" 5000 "$CR_PATH/3"
- api_get_service_ids 200 "rapp1" "rapp2" "rapp3"
+ api_get_service_ids 200 "rapp1" "rapp2" "rapp3"
- api_get_services 200 "rapp1" "rapp1" 2000 "$CR_PATH/1"
- api_get_services 200 NOSERVICE "rapp1" 2000 "$CR_PATH/1" "rapp2" 300 "ftp://localhost:80/test" "rapp3" 5000 "$CR_PATH/3"
+ api_get_services 200 "rapp1" "rapp1" 2000 "$CR_PATH/1"
- api_get_services 200
+ api_get_services 200 NOSERVICE "rapp1" 2000 "$CR_PATH/1" "rapp2" 300 "ftp://localhost:80/test" "rapp3" 5000 "$CR_PATH/3"
- echo -e $YELLOW"TR2"$EYELLOW
- api_put_services_keepalive 201 "rapp1"
- echo -e $YELLOW"TR2"$EYELLOW
- api_put_services_keepalive 201 "rapp3"
+ api_get_services 200
- api_put_services_keepalive 200 "rapp1"
+ echo -e $YELLOW"TR2"$EYELLOW
+ api_put_services_keepalive 201 "rapp1"
+ echo -e $YELLOW"TR2"$EYELLOW
+ api_put_services_keepalive 201 "rapp3"
- api_put_services_keepalive 200 "rapp3"
+ api_put_services_keepalive 200 "rapp1"
- api_put_services_keepalive 404 "rapp5"
+ api_put_services_keepalive 200 "rapp3"
- api_get_service_ids 200 "rapp1" "rapp2" "rapp3"
+ api_put_services_keepalive 404 "rapp5"
- api_delete_services 204 "rapp1"
+ api_get_service_ids 200 "rapp1" "rapp2" "rapp3"
- api_get_service_ids 200 "rapp2" "rapp3"
+ api_delete_services 204 "rapp1"
+ api_get_service_ids 200 "rapp2" "rapp3"
- api_put_service 201 "rapp1" 50 "$CR_PATH/1"
- api_get_service_ids 200 "rapp1" "rapp2" "rapp3"
+ api_put_service 201 "rapp1" 50 "$CR_PATH/1"
+ api_get_service_ids 200 "rapp1" "rapp2" "rapp3"
- api_delete_services 204 "rapp1"
- api_delete_services 204 "rapp3"
- api_equal json:services 1
+ api_delete_services 204 "rapp1"
+ api_delete_services 204 "rapp3"
- api_delete_services 204 "rapp2"
+ api_equal json:services 1
- api_equal json:services 0
+ api_delete_services 204 "rapp2"
+ api_equal json:services 0
- echo "############################################"
- echo "############## RIC Repository ##############"
- echo "############################################"
- api_get_rics 200 NOTYPE "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1,2:AVAILABLE ricsim_g2_1:me1_ricsim_g2_1,me2_ricsim_g2_1:EMPTYTYPE:AVAILABLE"
+ echo "############################################"
+ echo "############## RIC Repository ##############"
+ echo "############################################"
- api_get_rics 200 1 "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1,2:AVAILABLE"
+ api_get_rics 200 NOTYPE "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1,2:AVAILABLE ricsim_g2_1:me1_ricsim_g2_1,me2_ricsim_g2_1:EMPTYTYPE:AVAILABLE"
- api_get_rics 404 47
+ api_get_rics 200 1 "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1,2:AVAILABLE"
- api_get_rics 404 "test"
+ api_get_rics 404 47
+ api_get_rics 404 "test"
- api_get_ric 200 me1_ricsim_g1_1 ricsim_g1_1
- api_get_ric 200 me2_ricsim_g1_1 ricsim_g1_1
+ api_get_ric 200 me1_ricsim_g1_1 ricsim_g1_1
- api_get_ric 200 me1_ricsim_g2_1 ricsim_g2_1
+ api_get_ric 200 me2_ricsim_g1_1 ricsim_g1_1
- api_get_ric 200 me2_ricsim_g2_1 ricsim_g2_1
+ api_get_ric 200 me1_ricsim_g2_1 ricsim_g2_1
- api_get_ric 404 test
+ api_get_ric 200 me2_ricsim_g2_1 ricsim_g2_1
+ api_get_ric 404 test
- echo "############################################"
- echo "########### A1 Policy Management ###########"
- echo "############################################"
- echo -e $YELLOW"TR9"$EYELLOW
- api_get_policy_schema 200 1 testdata/OSC/1.json
- echo -e $YELLOW"TR9"$EYELLOW
- api_get_policy_schema 200 2 testdata/OSC/2.json
- api_get_policy_schema 404 3
- echo -e $YELLOW"TR9"$EYELLOW
- api_get_policy_schemas 200 NORIC testdata/OSC/1.json testdata/OSC/2.json NOFILE
- echo -e $YELLOW"TR9"$EYELLOW
- api_get_policy_schemas 200 ricsim_g1_1 testdata/OSC/1.json testdata/OSC/2.json
+ echo "############################################"
+ echo "########### A1 Policy Management ###########"
+ echo "############################################"
+ echo -e $YELLOW"TR9"$EYELLOW
+ api_get_policy_schema 200 1 testdata/OSC/1-agent-modified.json
+ echo -e $YELLOW"TR9"$EYELLOW
+ api_get_policy_schema 200 2 testdata/OSC/2-agent-modified.json
- api_get_policy_schemas 200 ricsim_g2_1 NOFILE
+ api_get_policy_schema 404 3
+ echo -e $YELLOW"TR9"$EYELLOW
+ api_get_policy_schemas 200 NORIC testdata/OSC/1-agent-modified.json testdata/OSC/2-agent-modified.json NOFILE
+ echo -e $YELLOW"TR9"$EYELLOW
+ api_get_policy_schemas 200 ricsim_g1_1 testdata/OSC/1-agent-modified.json testdata/OSC/2-agent-modified.json
- api_get_policy_schemas 404 test
+ api_get_policy_schemas 200 ricsim_g2_1 NOFILE
+ api_get_policy_schemas 404 test
- api_get_policy_types 200 NORIC 1 2 EMPTY
- api_get_policy_types 200 ricsim_g1_1 1 2
+ api_get_policy_types 200 NORIC 1 2 EMPTY
- api_get_policy_types 200 ricsim_g2_1 EMPTY
+ api_get_policy_types 200 ricsim_g1_1 1 2
- api_get_policy_types 404 dummy-ric
+ api_get_policy_types 200 ricsim_g2_1 EMPTY
+ api_get_policy_types 404 dummy-ric
- api_put_service 201 "rapp10" 3600 "$CR_PATH/1"
- echo -e $YELLOW"TR10"$EYELLOW
- api_put_policy 400 "unregistered-r-app" ricsim_g1_1 1 2000 testdata/OSC/pi1_template.json
- api_put_policy 201 "rapp10" ricsim_g1_1 1 5000 testdata/OSC/pi1_template.json
- api_put_policy 200 "rapp10" ricsim_g1_1 1 5000 testdata/OSC/pi1_template.json
+ api_put_service 201 "rapp10" 3600 "$CR_PATH/1"
+ echo -e $YELLOW"TR10"$EYELLOW
+ api_put_policy 400 "unregistered-r-app" ricsim_g1_1 1 2000 testdata/OSC/pi1_template.json
- api_put_policy 201 "rapp10" ricsim_g2_1 NOTYPE 5100 testdata/STD/pi1_template.json
- api_put_policy 200 "rapp10" ricsim_g2_1 NOTYPE 5100 testdata/STD/pi1_template.json
+ api_put_policy 201 "rapp10" ricsim_g1_1 1 5000 testdata/OSC/pi1_template.json
+ api_put_policy 200 "rapp10" ricsim_g1_1 1 5000 testdata/OSC/pi1_template.json
- VAL='NOT IN EFFECT'
- api_get_policy_status 200 5000 OSC "$VAL" "false"
- api_get_policy_status 200 5100 STD "UNDEFINED"
+ api_put_policy 201 "rapp10" ricsim_g2_1 NOTYPE 5100 testdata/STD/pi1_template.json
+ api_put_policy 200 "rapp10" ricsim_g2_1 NOTYPE 5100 testdata/STD/pi1_template.json
+ VAL='NOT IN EFFECT'
+ api_get_policy_status 200 5000 OSC "$VAL" "false"
+ api_get_policy_status 200 5100 STD "UNDEFINED"
- echo -e $YELLOW"TR10"$EYELLOW
- api_equal json:policies 2
- echo -e $YELLOW"TR10"$EYELLOW
- api_equal json:policy_ids 2
- echo -e $YELLOW"TR10"$EYELLOW
- api_get_policy_ids 200 NORIC NOSERVICE NOTYPE 5000 5100
- echo -e $YELLOW"TR10"$EYELLOW
- api_get_policy_ids 200 ricsim_g1_1 NOSERVICE NOTYPE 5000
- api_get_policy_ids 200 ricsim_g2_1 NOSERVICE NOTYPE 5100
+ echo -e $YELLOW"TR10"$EYELLOW
+ api_equal json:policies 2
+ echo -e $YELLOW"TR10"$EYELLOW
+ api_equal json:policy_ids 2
+ echo -e $YELLOW"TR10"$EYELLOW
+ api_get_policy_ids 200 NORIC NOSERVICE NOTYPE 5000 5100
+ echo -e $YELLOW"TR10"$EYELLOW
+ api_get_policy_ids 200 ricsim_g1_1 NOSERVICE NOTYPE 5000
+ api_get_policy_ids 200 ricsim_g2_1 NOSERVICE NOTYPE 5100
- api_get_policy_ids 200 NORIC "rapp10" NOTYPE 5000 5100
- echo -e $YELLOW"TR10"$EYELLOW
- api_get_policy_ids 200 NORIC NOSERVICE 1 5000
- api_get_policy_ids 200 NORIC NOSERVICE 2 NOID
+ api_get_policy_ids 200 NORIC "rapp10" NOTYPE 5000 5100
+ echo -e $YELLOW"TR10"$EYELLOW
+ api_get_policy_ids 200 NORIC NOSERVICE 1 5000
- api_get_policy_ids 200 ricsim_g2_1 NOSERVICE 1 NOID
+ api_get_policy_ids 200 NORIC NOSERVICE 2 NOID
+ api_get_policy_ids 200 ricsim_g2_1 NOSERVICE 1 NOID
- api_get_policy 200 5000 testdata/OSC/pi1_template.json
- api_get_policy 200 5100 testdata/STD/pi1_template.json
+ api_get_policy 200 5000 testdata/OSC/pi1_template.json
+ api_get_policy 200 5100 testdata/STD/pi1_template.json
- api_get_policies 200 ricsim_g1_1 "rapp10" 1 5000 ricsim_g1_1 "rapp10" 1 testdata/OSC/pi1_template.json
+ api_get_policies 200 ricsim_g1_1 "rapp10" 1 5000 ricsim_g1_1 "rapp10" 1 testdata/OSC/pi1_template.json
- echo -e $YELLOW"TR10"$EYELLOW
- api_delete_policy 404 2000
- api_delete_policy 404 1500
+ echo -e $YELLOW"TR10"$EYELLOW
+ api_delete_policy 404 2000
- api_delete_policy 204 5000
+ api_delete_policy 404 1500
- api_equal json:policies 1
+ api_delete_policy 204 5000
- api_equal json:policy_ids 1
+ api_equal json:policies 1
- api_delete_policy 204 5100
+ api_equal json:policy_ids 1
- api_equal json:policies 0
+ api_delete_policy 204 5100
- api_equal json:policy_ids 0
+ api_equal json:policies 0
- cr_equal received_callbacks 0
+ api_equal json:policy_ids 0
- if [ $interface == "DMAAP" ] || [ $interface == "DMAAP+SDNC" ]; then
- mr_greater requests_submitted 0
- VAL=$(mr_read requests_submitted)
- mr_equal requests_fetched $VAL
- mr_equal responses_submitted $VAL
- mr_equal responses_fetched $VAL
- mr_equal current_requests 0
- mr_equal current_responses 0
- else
- mr_equal requests_submitted 0
- fi
+ cr_equal received_callbacks 0
+
+ if [ $interface == "DMAAP" ] || [ $interface == "DMAAP+SDNC" ]; then
+ mr_greater requests_submitted 0
+ VAL=$(mr_read requests_submitted)
+ mr_equal requests_fetched $VAL
+ mr_equal responses_submitted $VAL
+ mr_equal responses_fetched $VAL
+ mr_equal current_requests 0
+ mr_equal current_responses 0
+ else
+ mr_equal requests_submitted 0
+ fi
+
+ check_policy_agent_logs
+ check_control_panel_logs
- check_policy_agent_logs
- check_control_panel_logs
+ store_logs $interface
- store_logs $interface
+ done
done
start_control_panel
-#start_sdnc
-
start_policy_agent
-use_agent_rest
+use_agent_rest_http
#Verify no callbacks or dmaap messages has been sent
cr_equal received_callbacks 0
start_policy_agent
-use_agent_rest
+use_agent_rest_http
api_get_status 200
--- /dev/null
+#!/usr/bin/env bash
+
+# ============LICENSE_START===============================================
+# Copyright (C) 2020 Nordix Foundation. All rights reserved.
+# ========================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ============LICENSE_END=================================================
+#
+
+TC_ONELINE_DESCR="Resync 10000 policies using OSC interface over REST+SNDC"
+
+. ../common/testcase_common.sh $@
+. ../common/agent_api_functions.sh
+. ../common/ricsimulator_api_functions.sh
+
+#### TEST BEGIN ####
+
+#Local vars in test script
+##########################
+# Path to callback receiver
+CR_PATH="http://$CR_APP_NAME:$CR_EXTERNAL_PORT/callbacks"
+
+clean_containers
+
+start_ric_simulators ricsim_g1 4 OSC_2.1.0
+
+start_mr
+
+start_cr
+
+start_sdnc
+
+start_consul_cbs
+
+prepare_consul_config SDNC ".consul_config.json"
+consul_config_app ".consul_config.json"
+
+start_control_panel
+
+
+start_policy_agent
+
+use_agent_rest_http
+
+api_get_status 200
+
+sim_print ricsim_g1_1 interface
+
+sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json
+
+api_equal json:policy_types 1 120 #Wait for the agent to refresh types from the simulator
+
+api_put_service 201 "rapp1" 3600 "$CR_PATH/callbacks/1"
+
+api_put_policy 201 "rapp1" ricsim_g1_1 1 2000 testdata/OSC/pi1_template.json 10000
+
+sim_equal ricsim_g1_1 num_instances 10000
+
+sim_post_delete_instances 200 ricsim_g1_1
+
+sim_equal ricsim_g1_1 num_instances 0
+
+sim_equal ricsim_g1_1 num_instances 10000 300
+
+api_delete_policy 204 2435
+
+api_delete_policy 204 8693
+
+sim_post_delete_instances 200 ricsim_g1_1
+
+sim_post_delete_instances 200 ricsim_g1_1
+
+sim_equal ricsim_g1_1 num_instances 9998 300
+
+
+check_policy_agent_logs
+
+#### TEST COMPLETE ####
+
+store_logs END
+
+print_result
\ No newline at end of file
start_policy_agent
-use_agent_rest
+use_agent_rest_http
api_get_status 200
start_policy_agent
-use_agent_rest
+use_agent_rest_http
set_agent_debug
--- /dev/null
+#!/usr/bin/env bash
+
+# ============LICENSE_START===============================================
+# Copyright (C) 2020 Nordix Foundation. All rights reserved.
+# ========================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ============LICENSE_END=================================================
+#
+
+
+TC_ONELINE_DESCR="Resync of RIC via changes in the consul config"
+
+. ../common/testcase_common.sh $@
+. ../common/agent_api_functions.sh
+. ../common/ricsimulator_api_functions.sh
+. ../common/controller_api_functions.sh
+
+#### TEST BEGIN ####
+
+
+# Clean container and start all needed containers #
+clean_containers
+
+# Start one RIC of each type
+start_ric_simulators ricsim_g1 1 OSC_2.1.0
+start_ric_simulators ricsim_g2 1 STD_1.1.3
+
+start_mr
+
+start_cr
+
+start_consul_cbs
+
+prepare_consul_config NOSDNC ".consul_config.json"
+
+consul_config_app ".consul_config.json"
+
+start_control_panel
+
+start_policy_agent
+
+api_equal json:rics 2 120
+
+
+# Add an OSC RIC and check
+start_ric_simulators ricsim_g2 2 STD_1.1.3
+
+prepare_consul_config NOSDNC ".consul_config.json"
+
+consul_config_app ".consul_config.json"
+
+api_equal json:rics 3 120
+
+check_policy_agent_logs
+check_control_panel_logs
+
+# Remove one OSC RIC and check
+start_ric_simulators ricsim_g2 1 STD_1.1.3
+
+prepare_consul_config NOSDNC ".consul_config.json"
+
+consul_config_app ".consul_config.json"
+
+api_equal json:rics 2 120
+
+check_policy_agent_logs
+check_control_panel_logs
+
+store_logs END
+
+
+#### TEST COMPLETE ####
+
+
+print_result
+
+auto_clean_containers
. ../common/testcase_common.sh $@
. ../common/agent_api_functions.sh
+. ../common/ricsimulator_api_functions.sh
+. ../common/controller_api_functions.sh
#### TEST BEGIN ####
set_agent_debug
- use_agent_rest
+ use_agent_rest_http
echo "Using: "$TEST
--- /dev/null
+{
+ "$schema": "http://json-schema.org/draft-07/schema#",
+ "title": "1",
+ "description": "Type 1 policy type",
+ "type": "object",
+ "properties": {
+ "scope": {
+ "type": "object",
+ "properties": {
+ "ueId": {
+ "type": "string"
+ },
+ "qosId": {
+ "type": "string"
+ }
+ },
+ "additionalProperties": false,
+ "required": [
+ "ueId",
+ "qosId"
+ ]
+ },
+ "qosObjective": {
+ "type": "object",
+ "properties": {
+ "priorityLevel": {
+ "type": "number"
+ }
+ },
+ "additionalProperties": false,
+ "required": [
+ "priorityLevel"
+ ]
+ }
+ },
+ "additionalProperties": false,
+ "required": [
+ "scope", "qosObjective"
+ ]
+ }
--- /dev/null
+{
+ "$schema": "http://json-schema.org/draft-07/schema#",
+ "title": "2",
+ "description": "Type 2 policy type",
+ "type": "object",
+ "properties": {
+ "scope": {
+ "type": "object",
+ "properties": {
+ "sliceId": {
+ "type": "string"
+ }
+ },
+ "additionalProperties": false,
+ "required": [
+ "sliceId"
+ ]
+ },
+ "qoeObjectives": {
+ "type": "object",
+ "properties": {
+ "qoeScore": {
+ "type": "number"
+ }
+ },
+ "additionalProperties": false,
+ "required": [
+ "qoeScore"
+ ]
+ }
+ },
+ "additionalProperties": false,
+ "required": [
+ "scope", "qoeObjectives"
+ ]
+ }
--- /dev/null
+-----BEGIN CERTIFICATE-----
+MIICljCCAX4CCQDVlvlNzxH9FzANBgkqhkiG9w0BAQsFADANMQswCQYDVQQGEwJT
+RTAeFw0yMDA0MjgxOTE2MTNaFw00NzA5MTMxOTE2MTNaMA0xCzAJBgNVBAYTAlNF
+MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqpnXP5VmOvMPOTWaxWvm
+zfSBRvnioEFHoriGld+pW+vvvrma9UiWfxX3GaGFItxuwbwLwqwvR2LDo6wQQpbl
+SaNhg89DYD/NZvlRlLNcYOL218LjfFf4xaKVQGBHfT0Ts9JGTbTD/zcR2VS+3DUR
+lvLzbNpQ+Rdvwls7wsL1ZblR+1lry9HMGKCrtsYDSOMSyGqE40u1bOYAw1+VMrfp
+cK14u9toNPIbvk+HDP5yYnjC4FEp0ai07s3T6YDWHvp0WNIFJHCVFYzYQgS79/2b
+8zg4H7ZMQ5XjxcenU6f8Q97nN0VMk46LIutGe/7rYO0uYKrHcJz1qUu1ui96zOVC
+DQIDAQABMA0GCSqGSIb3DQEBCwUAA4IBAQBGvmFRHuUESpwijkekR0WFBuW6UNE5
+J7cZ9CXm7Mz06jeTAZWoCWVAZjYnpQ/MjvyzFglD9wL+A6LblIU+yNctYwtfspAq
+xDYmBKlhsKzlgZ3fyBUlfrM5BFxZR2uu1/4bUU4geEQrI2rYzif3Flj0a55EIeSa
+37fa7Acc+nNfy47mAa8Dsog6LHMs+FXGmuMS31c9lc70c9v4jCArctdDn/zKg9A7
+HCwd0+icgyDD+9U9eBhcFreBWyA1tPREWyx0qbhlw43OsVMpB6VM4exLGs/v1e0x
+/Nmmsis1o54eu2cLGjr5EYlDmdFD3Dn458r0zFkxg4CE23lRUtFz8d6F
+-----END CERTIFICATE-----
--- /dev/null
+#!/bin/bash
+
+# ============LICENSE_START===============================================
+# Copyright (C) 2020 Nordix Foundation. All rights reserved.
+# ========================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ============LICENSE_END=================================================
+#
+
+# This will generate a self-signed certificate with password 'test'
+openssl req -x509 -passout pass:"test" -newkey rsa:2048 -keyout key.crt -out cert.crt -days 9999
--- /dev/null
+-----BEGIN ENCRYPTED PRIVATE KEY-----
+MIIFHzBJBgkqhkiG9w0BBQ0wPDAbBgkqhkiG9w0BBQwwDgQIoefVgflG3OYCAggA
+MB0GCWCGSAFlAwQBKgQQEaJvnbiOIkAwGcyqi6eYCQSCBNDnK9PT/NdGvZAriJAg
+VYbqJiCxrqfrfRDAKU4Z4GWFnodzLt2+Xe6iEeOmCkCfs/oVaWx+yIMFzZKY2sq/
+jMmiihJggV+R+hIEXBsVnvqL/nqbchQ7ckhJK8ofXMcpdUdCd8CHylRPNmNNfMsu
+o3BbDjKEdCtWMmBWuMWI3DtF0U5Tu5d+nH2ZHpl7YtA7U+N5w3nWBlxoPVXmqsEH
+YE8cL0C/b+nFNs81FXKlbIPGNSv51c5YPjS0WQneci2Vj9JMPHWT6VMCaxVlv3js
+droG6AxzHH+UpB1Lx4BfVunHR79nmhzmH9mo74rWCiYZ+Kh7DnC26WHrJW/tqJX8
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ZrsyDTAYoRVnTvPQwSZoUJ6cQS6XgLa3QitDcj+Zqch9z7sV2
+ydkEHEbLXPIt/sQyASluKm5j1tHJVtzwezb5GO54WYwdpy3MmZ3VhXsagJc9oLHX
+MtsDGZR0hXMgzPp49leBhcieWW6fWXAZKt2oa64eI/12i2wSTjNsxPfsu45tJYXO
+GAPL0OYBKeVLi1Pfa3kCLqlMDAyC4GzTScWXad5/FEeo189JU1aGcJn7Gn7Ao805
+wuOOs1TQk+KHvAFDEGkkJEM0lg==
+-----END ENCRYPTED PRIVATE KEY-----
return 1
fi
- if [ $ADAPTER == $RESTBASE ]; then
+ if [ $ADAPTER == $RESTBASE ] || [ $ADAPTER == $RESTBASE_SECURE ]; then
url=" "${ADAPTER}${2}
oper=" -X "$oper
- curlString="curl"${oper}${timeout}${httpcode}${accept}${content}${url}${file}
+ curlString="curl -k "${oper}${timeout}${httpcode}${accept}${content}${url}${file}
echo " CMD: "$curlString >> $HTTPLOG
if [ $# -eq 3 ]; then
echo " FILE: $(<$3)" >> $HTTPLOG
file=" --data-binary "$payload
fi
#urlencode the request url since it will be carried by send-request url
- requestUrl=$(python -c "from __future__ import print_function; import urllib.parse, sys; print(urllib.parse.quote(sys.argv[1]))" "$2")
+ requestUrl=$(python3 -c "from __future__ import print_function; import urllib.parse, sys; print(urllib.parse.quote(sys.argv[1]))" "$2")
url=" "${ADAPTER}"/send-request?url="${requestUrl}"&operation="${oper}
curlString="curl -X POST${timeout}${httpcode}${content}${url}${file}"
echo " CMD: "$curlString >> $HTTPLOG
targetJson=$targetJson"]"
echo "TARGET JSON: $targetJson" >> $HTTPLOG
- res=$(python ../common/compare_json.py "$targetJson" "$body" "id")
+ res=$(python3 ../common/compare_json.py "$targetJson" "$body")
if [ $res -ne 0 ]; then
echo -e $RED" FAIL, returned body not correct"$ERED
sed 's/XXX/'${2}'/g' $3 > $file
targetJson=$(< $file)
echo "TARGET JSON: $targetJson" >> $HTTPLOG
- res=$(python ../common/compare_json.py "$targetJson" "$body")
+ res=$(python3 ../common/compare_json.py "$targetJson" "$body")
if [ $res -ne 0 ]; then
echo -e $RED" FAIL, returned body not correct"$ERED
((RES_FAIL++))
sed 's/XXX/'${pid}'/g' $6 > $file
res="$(__do_curl_to_agent PUT $query $file)"
status=${res:${#res}-3}
- echo -ne " Creating "$count"("$max")\033[0K\r"
+ echo -ne " Creating "$count"("$max")${SAMELINE}"
if [ $status -ne $1 ]; then
let pid=$pid+1
let pid=$pid+1
let count=$count+1
- echo -ne " Created "$count"("$max")\033[0K\r"
+ echo -ne " Created "$count"("$max")${SAMELINE}"
done
echo ""
query="/policy?id="$pid
res="$(__do_curl_to_agent DELETE $query)"
status=${res:${#res}-3}
- echo -ne " Deleting "$count"("$max")\033[0K\r"
+ echo -ne " Deleting "$count"("$max")${SAMELINE}"
if [ $status -ne $1 ]; then
echo " Deleted "$count"?("$max")"
fi
let pid=$pid+1
let count=$count+1
- echo -ne " Deleted "$count"("$max")\033[0K\r"
+ echo -ne " Deleted "$count"("$max")${SAMELINE}"
done
echo ""
targetJson=$targetJson"]"
echo "TARGET JSON: $targetJson" >> $HTTPLOG
- res=$(python ../common/compare_json.py "$targetJson" "$body")
+ res=$(python3 ../common/compare_json.py "$targetJson" "$body")
if [ $res -ne 0 ]; then
echo -e $RED" FAIL, returned body not correct"$ERED
targetJson=$(< $3)
echo "TARGET JSON: $targetJson" >> $HTTPLOG
- res=$(python ../common/compare_json.py "$targetJson" "$body")
+ res=$(python3 ../common/compare_json.py "$targetJson" "$body")
if [ $res -ne 0 ]; then
echo -e $RED" FAIL, returned body not correct"$ERED
if [ $file == "NOFILE" ]; then
targetJson=$targetJson"{}"
else
- targetJson=$targetJson$(< $3)
+ targetJson=$targetJson$(< $file)
fi
done
targetJson=$targetJson"]"
echo "TARGET JSON: $targetJson" >> $HTTPLOG
- res=$(python ../common/compare_json.py "$targetJson" "$body")
+ res=$(python3 ../common/compare_json.py "$targetJson" "$body")
if [ $res -ne 0 ]; then
echo -e $RED" FAIL, returned body not correct"$ERED
echo "TARGET JSON: $targetJson" >> $HTTPLOG
body=${res:0:${#res}-3}
- res=$(python ../common/compare_json.py "$targetJson" "$body")
+ res=$(python3 ../common/compare_json.py "$targetJson" "$body")
if [ $res -ne 0 ]; then
echo -e $RED" FAIL, returned body not correct"$ERED
targetJson=$targetJson"]"
echo "TARGET JSON: $targetJson" >> $HTTPLOG
- res=$(python ../common/compare_json.py "$targetJson" "$body")
+ res=$(python3 ../common/compare_json.py "$targetJson" "$body")
if [ $res -ne 0 ]; then
echo -e $RED" FAIL, returned body not correct"$ERED
if [ $# -gt 2 ]; then
body=${res:0:${#res}-3}
- res=$(python ../common/create_rics_json.py ".tmp_rics.json" "$3" )
+ res=$(python3 ../common/create_rics_json.py ".tmp_rics.json" "$3" )
if [ $res -ne 0 ]; then
echo -e $RED" FAIL, could not create target ric info json"$ERED
((RES_FAIL++))
targetJson=$(<.tmp_rics.json)
echo "TARGET JSON: $targetJson" >> $HTTPLOG
- res=$(python ../common/compare_json.py "$targetJson" "$body")
+ res=$(python3 ../common/compare_json.py "$targetJson" "$body")
if [ $res -ne 0 ]; then
echo -e $RED" FAIL, returned body not correct"$ERED
((RES_FAIL++))
done
targetJson=$targetJson"]"
echo "TARGET JSON: $targetJson" >> $HTTPLOG
- res=$(python ../common/compare_json.py "$targetJson" "$body" "serviceName")
+ res=$(python3 ../common/compare_json.py "$targetJson" "$body")
if [ $res -ne 0 ]; then
echo -e $RED" FAIL, returned body not correct"$ERED
((RES_FAIL++))
targetJson=$targetJson"]"
echo "TARGET JSON: $targetJson" >> $HTTPLOG
- res=$(python ../common/compare_json.py "$targetJson" "$body" "serviceName")
+ res=$(python3 ../common/compare_json.py "$targetJson" "$body")
if [ $res -ne 0 ]; then
echo -e $RED" FAIL, returned body not correct"$ERED
# ============LICENSE_END=================================================
#
+# This script compare two jsons for eqaulity, taken into account that the parameter values
+# marked with '????' are not checked (only the parameter name need to exist)
+# Example of target json with '????'
+# [
+# {
+# "callbackUrl": "????",
+# "keepAliveIntervalSeconds": "????",
+# "serviceName": "serv2",
+# "timeSinceLastActivitySeconds": "????"
+# },
+# {
+# "callbackUrl": "????",
+# "keepAliveIntervalSeconds": "????",
+# "serviceName": "serv1",
+# "timeSinceLastActivitySeconds": "????"
+# }
+#]
+
+
import os
import json
import sys
-# Deep compare of two json obects
-# If a parameter value in the target json is set to '????' then the result json value is not checked for the that parameter
-# Any included json array will be sorted before comparison
-# An optional array key can be given to sort array of objects containing that key
+# # Helper function to compare two json list.
+# # Returns true for equal, false for not equal
+def compare_json_list(list1, list2):
+ if (list1.__len__() != list2.__len__()):
+ return False
-def comparejson(jsonTarget,jsonResult,arrayKey):
+ for l in list1:
+ found = False
+ for m in list2:
+ res = compare_json_obj(l, m)
+ if (res):
+ found = True
+ break
- if isinstance(jsonTarget, dict):
- if (len(jsonTarget) != len(jsonResult)):
- return 1
- for key in jsonTarget.keys():
- if (jsonResult.get(key) is None):
- return 1
- if (comparejson(jsonTarget.get(key), jsonResult.get(key), arrayKey) != 0):
- return 1
- elif isinstance(jsonTarget, list):
- if (len(jsonTarget) != len(jsonResult)):
- return 1
- if (arrayKey is None):
- jsonTarget.sort()
- jsonResult.sort()
- else:
- jsonTarget.sort(key=lambda k: k[arrayKey])
- jsonResult.sort(key=lambda k: k[arrayKey])
+ if (not found):
+ return False
- for i in range(len(jsonTarget)):
- if (comparejson(jsonTarget[i], jsonResult[i], arrayKey) != 0):
- return 1
+ return True
+
+# Deep compare of two json obects
+# If a parameter value in the target json is set to '????' then the result json value is not checked for the that parameter
+# Return true for equal json, false for not equal json
+def compare_json_obj(obj1, obj2):
+ if isinstance(obj1, list):
+ if (not isinstance(obj2, list)):
+ return False
+ return compare_json_list(obj1, obj2)
+ elif (isinstance(obj1, dict)):
+ if (not isinstance(obj2, dict)):
+ return False
+ exp = set(obj2.keys()) == set(obj1.keys())
+ if (not exp):
+ return False
+ for k in obj1.keys():
+ val1 = obj1.get(k)
+ val2 = obj2.get(k)
+ if isinstance(val1, list):
+ if (not compare_json_list(val1, val2)):
+ return False
+ elif isinstance(val1, dict):
+ if (not compare_json_obj(val1, val2)):
+ return False
+ else:
+ #Do not check parameter values marked with '????'
+ if ((val1 != "????") and (val2 != val1)) and ((val2 != "????") and (val2 != val1)):
+ return False
else:
- if (jsonTarget != "????") and (jsonTarget != jsonResult):
- return 1
- return 0
+ return obj1 == obj2
+
+ return True
+
try:
+ #Read the input file and compare the two json (target->result)
jsonTarget = json.loads(sys.argv[1])
jsonResult = json.loads(sys.argv[2])
- arrayKey = None
- if (len(sys.argv) > 3):
- arrayKey = sys.argv[3]
- print(comparejson(jsonTarget,jsonResult,arrayKey))
+ res1=compare_json_obj(jsonTarget, jsonResult)
+
+ #Read the json again (in case the previous calls has re-arranged the jsons)
+ jsonTarget = json.loads(sys.argv[1])
+ jsonResult = json.loads(sys.argv[2])
+ #Compare the opposite order (result->target) to catch special duplicate json key cases
+ res2=compare_json_obj(jsonResult, jsonTarget)
+
+ if (res1 and res2):
+ print (0)
+ else:
+ print (1)
except Exception as e:
print (1)
fi
body=${res:0:${#res}-3}
echo "$body" > .sdnc-reply.json
- res=$(python ../common/extract_sdnc_reply.py .sdnc-reply.json)
+ res=$(python3 ../common/extract_sdnc_reply.py .sdnc-reply.json)
echo " EXTRACED BODY+CODE: "$res >> $HTTPLOG
echo "$res"
return 0
echo " TARGET JSON: $targetJson" >> $HTTPLOG
- res=$(python ../common/compare_json.py "$targetJson" "$body")
+ res=$(python3 ../common/compare_json.py "$targetJson" "$body")
if [ $res -ne 0 ]; then
echo -e $RED" FAIL, returned body not correct"$ERED
targetJson=$(< $5)
echo " TARGET JSON: $targetJson" >> $HTTPLOG
- res=$(python ../common/compare_json.py "$targetJson" "$body")
+ res=$(python3 ../common/compare_json.py "$targetJson" "$body")
if [ $res -ne 0 ]; then
echo -e $RED" FAIL, returned body not correct"$ERED
body=${res:0:${#res}-3}
echo " TARGET JSON: $targetJson" >> $HTTPLOG
- res=$(python ../common/compare_json.py "$targetJson" "$body")
+ res=$(python3 ../common/compare_json.py "$targetJson" "$body")
if [ $res -ne 0 ]; then
echo -e $RED" FAIL, returned body not correct"$ERED
# All calls made to 'localhost:'<port>.
# Expects env PORT set to intended port number
# Expects env RESULT to contain the target response body.
+# Optional env HTTPX shall contain protocol 'http' or 'https'. If not set, 'http' is used. For 'https' all cert errors are ignored
# RESULT="*" means that returned payload is not checked, may container any text
-# RESULT="<text>" menans that the returned payload has to match the <text> exactly
+# RESULT="<text>" means that the returned payload has to match the <text> exactly
# RESULT="json:<returned-payload>" means that the returned json payload is compared with the expected result (order of json keys and index is irrelevant)
+# RESULT="json-array-size:<integer-size>" means that the returned json payload shall contain the number of element given by the <integer-size>
# Env BODY contains the response body after the call
# Any error will stop script execution
# How to use in a test script: source this file into your bash test script to the make the function available.
echo "Exting test script....."
exit 1
fi
- curlstr="curl -X "$1" -sw %{http_code} localhost:$PORT$2 -H accept:*/*"
+
+ if [ -z $HTTPX ]; then
+ if [ "$HTTPX" != "http" ] && [ "$HTTPX" != "https" ]; then
+ echo "Env var HTTPX shall be set to 'http' or 'https'"
+ echo "Exting test script....."
+ exit 1
+ fi
+ PROT="http"
+ else
+ PROT=$HTTPX
+ fi
+
+ curlstr="curl -X "$1" -skw %{http_code} ${PROT}://localhost:$PORT$2 -H accept:*/*"
if [ $# -gt 3 ]; then
curlstr=$curlstr" -H Content-Type:application/json --data-binary @"$4
fi
echo "Exiting....."
exit 1
fi
+ elif [[ "$RESULT" == "json-array-size:"* ]]; then
+ count=${RESULT:16:${#RESULT}}
+ #Find dir of the common dir
+ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
+ echo $body > .tmp.json
+ res=$(python ${DIR}/count_json_elements.py .tmp.json)
+ if [ $res -eq $count ]; then
+ echo " Body (array size) as expected"
+ else
+ echo " Expected json array size: "$count
+ echo "Exiting....."
+ exit 1
+ fi
else
body="$(echo $body | tr -d '\n' )"
if [ "$RESULT" == "$body" ]; then
if [ $# -eq 3 ] || [ $# -eq 4 ]; then
app=$1
port=$(__find_sim_port $app)
- __var_test $app "$LOCALHOST$port/counter/" $2 "=" $3 $4
+ __var_test $app "$RIC_SIM_LOCALHOST$port/counter/" $2 "=" $3 $4
return 0
else
((RES_CONF_FAIL++))
fi
app=$1
port=$(__find_sim_port $app)
- echo -e $BOLD"INFO(${BASH_LINENO[0]}): $app, $2 = $(__do_curl $LOCALHOST$port/counter/$2)"$EBOLD
+ echo -e $BOLD"INFO(${BASH_LINENO[0]}): $app, $2 = $(__do_curl $RIC_SIM_LOCALHOST$port/counter/$2)"$EBOLD
}
# Simulator API: Put a policy type in a ric
app=$2
res=$(__find_sim_port $app)
- curlString="curl -X PUT -sw %{http_code} $LOCALHOST"$res"/policytype?id="$3" -H Content-Type:application/json --data-binary @"$4
+ curlString="curl -X PUT -skw %{http_code} $RIC_SIM_LOCALHOST"$res"/policytype?id="$3" -H Content-Type:application/json --data-binary @"$4
__execute_curl_to_sim $1 "$curlString" $4
return $?
app=$2
res=$(__find_sim_port $app)
- curlString="curl -X DELETE -sw %{http_code} $LOCALHOST"$res"/policytype?id="$3
+ curlString="curl -X DELETE -skw %{http_code} $RIC_SIM_LOCALHOST"$res"/policytype?id="$3
__execute_curl_to_sim $1 "$curlString"
return $?
app=$2
res=$(__find_sim_port $app)
- curlString="curl -X POST -sw %{http_code} $LOCALHOST"$res"/deleteinstances"
+ curlString="curl -X POST -skw %{http_code} $RIC_SIM_LOCALHOST"$res"/deleteinstances"
__execute_curl_to_sim $1 "$curlString"
return $?
app=$2
res=$(__find_sim_port $app)
- curlString="curl -X POST -sw %{http_code} $LOCALHOST"$res"/deleteall"
+ curlString="curl -X POST -skw %{http_code} $RIC_SIM_LOCALHOST"$res"/deleteall"
__execute_curl_to_sim $1 "$curlString"
return $?
app=$2
res=$(__find_sim_port $app)
- curlString="curl -X POST -sw %{http_code} $LOCALHOST"$res"/forceresponse"
+ curlString="curl -X POST -skw %{http_code} $RIC_SIM_LOCALHOST"$res"/forceresponse"
if [ $# -eq 3 ]; then
curlString=$curlString"?code="$3
fi
app=$2
res=$(__find_sim_port $app)
- curlString="curl -X POST -sw %{http_code} $LOCALHOST$res/delay"
+ curlString="curl -X POST -skw %{http_code} $RIC_SIM_LOCALHOST$res/delay"
if [ $# -eq 3 ]; then
curlString=$curlString"?delay="$3
fi
SDNC_A1_CONTROLLER_REMOTE_IMAGE_TAG="1.7.4"
-#SDNC DN remote image and tag
+#SDNC DB remote image and tag
SDNC_DB_REMOTE_IMAGE="mysql/mysql-server"
SDNC_DB_REMOTE_IMAGE_TAG="5.6"
#No local image for DB, remote image always used
+# SDNC ONAP A1 Adapte remote image and tag
+SDNC_ONAP_A1_ADAPTER_REMOTE_IMAGE="nexus3.onap.org:10003/onap/sdnc-image"
+SDNC_ONAP_A1_ADAPTER_REMOTE_IMAGE_TAG="1.8-STAGING-latest"
+#No local image for the A1 adapter, remote image always used
+
+#ONAP A1 Adatper remote image and tag
+SDNC_ONAP_DB_REMOTE_IMAGE="mysql/mysql-server"
+SDNC_ONAP_DB_REMOTE_IMAGE_TAG="5.6"
+#No local image for DB, remote image always used
+
+
# Near RT RIC Simulator local image and tag
RIC_SIM_LOCAL_IMAGE="nexus3.o-ran-sc.org:10004/o-ran-sc/a1-simulator"
RIC_SIM_LOCAL_IMAGE_TAG="latest"
RIC_SIM_REMOTE_IMAGE="nexus3.o-ran-sc.org:10004/o-ran-sc/a1-simulator"
RIC_SIM_REMOTE_IMAGE_TAG="1.0.1"
+RIC_SIM_REMOTE_IMAGE="a1test"
+RIC_SIM_REMOTE_IMAGE_TAG="latest"
+
#Consul remote image and tag
CONSUL_REMOTE_IMAGE="consul"
export POLICY_AGENT_EXTERNAL_PORT=8081 # Policy Agent container external port (host -> container)
export POLICY_AGENT_INTERNAL_PORT=8081 # Policy Agent container internal port (container -> container)
+export POLICY_AGENT_EXTERNAL_SECURE_PORT=8433 # Policy Agent container external secure port (host -> container)
+export POLICY_AGENT_INTERNAL_SECURE_PORT=8433 # Policy Agent container internal secure port (container -> container)
+
export POLICY_AGENT_APP_NAME="policy-agent" # Name for Policy Agent container
POLICY_AGENT_LOGPATH="/var/log/policy-agent/application.log" # Path the application log in the Policy Agent container
+export POLICY_AGENT_APP_NAME_ALIAS="policy-agent-container" # Alias name, name used by the control panel
export MR_EXTERNAL_PORT=3905 # MR stub container external port (host -> container)
export MR_INTERNAL_PORT=3905 # MR stub container internal port (container -> container)
+export MR_EXTERNAL_SECURE_PORT=3906 # MR stub container external secure port (host -> container)
+export MR_INTERNAL_SECURE_PORT=3906 # MR stub container internal secure port (container -> container)
export MR_APP_NAME="message-router" # Name for the MR
export CR_EXTERNAL_PORT=8090 # Callback receiver container external port (host -> container)
# Note, a prefix is added to each container name by the .env file in the 'ric' dir
RIC_SIM_PREFIX="ricsim" # Prefix added to ric container name, added in the .env file in the 'ric' dir
export RIC_SIM_INTERNAL_PORT=8085 # RIC Simulator container internal port (container -> container).
- # (externl ports allocated by docker)
+ # (external ports allocated by docker)
+export RIC_SIM_INTERNAL_SECURE_PORT=8185 # RIC Simulator container internal secure port (container -> container).
+ # (external ports allocated by docker)
export SDNC_APP_NAME="a1-controller" # Name of the SNDC A1 Controller container
export SDNC_EXTERNAL_PORT=8282 # SNDC A1 Controller container external port (host -> container)
SDNC_USER="admin" # SDNC username
SDNC_PWD="Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U" # SNDC PWD
SDNC_API_URL="/restconf/operations/A1-ADAPTER-API:" # Base url path for SNDC API
+SDNC_KARAF_LOG="/opt/opendaylight/data/log/karaf.log" # Path to karaf log
+
+export SDNC_ONAP_APP_NAME="a1-adapter" # Name of the ONAP A1 Adapter container
+export SDNC_ONAP_EXTERNAL_PORT=8282 # ONAP A1 Adapter container external port (host -> container)
+export SDNC_ONAP_INTERNAL_PORT=8181 # ONAP A1 Adapter container internal port (container -> container)
+export SDNC_ONAP_DB_APP_NAME="sdnc-onap-db" # Name of the ONAP A1 Adapter DB container
+SDNC_ONAP_USER="admin" # ONAP A1 Adapter username
+SDNC_ONAP_PWD="Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U" # ONAP A1 Adapter PWD
+SDNC_ONAP_API_URL="/restconf/operations/A1-ADAPTER-API:" # Base url path for ONAP A1 Adapter API
+SDNC_ONAP_PROPERTIES_FILE="/opt/onap/ccsdk/data/properties/a1-adapter-api-dg.properties"
+SDNC_ONAP_KARAF_LOG="/opt/opendaylight/data/log/karaf.log" # Path to karaf log
export CONTROL_PANEL_APP_NAME="control-panel" # Name of the Control Panel container
export CONTROL_PANEL_EXTERNAL_PORT=8080 # Control Panel container external port (host -> container)
export CONTROL_PANEL_INTERNAL_PORT=8080 # Control Panel container external port (host -> container)
CONTROL_PANEL_LOGPATH="/logs/nonrtric-controlpanel.log" # Path the application log in the Control Panel container
-RESTBASE="http://localhost:"$POLICY_AGENT_EXTERNAL_PORT # Base url to the R-APP interface
+RESTBASE="http://localhost:"$POLICY_AGENT_EXTERNAL_PORT # Base url to the Agent NB REST interface
+RESTBASE_SECURE="https://localhost:"$POLICY_AGENT_EXTERNAL_SECURE_PORT # Base url to the secure Agent NB REST interface
DMAAPBASE="http://localhost:"$MR_EXTERNAL_PORT # Base url to the Dmaap adapter
ADAPTER=$RESTBASE # Adapter holds the address the agent R-APP interface (REST OR DMAAP)
# The values of this var is swiched between the two base url when needed
\ No newline at end of file
# This is a script that contains all the functions needed for auto test
# Arg: local|remote|remote-remove [auto-clean]
+
#Formatting for 'echo' cmd
BOLD="\033[1m"
EBOLD="\033[0m"
EGREEN="\033[0m"
YELLOW="\033[33m\033[1m"
EYELLOW="\033[0m"
+SAMELINE="\033[0K\r"
+
+tmp=$(which python3)
+if [ $? -ne 0 ] || [ -z tmp ]; then
+ echo -e $RED"python3 is required to run the test environment, pls install"$ERED
+ exit 1
+fi
+tmp=$(which docker)
+if [ $? -ne 0 ] || [ -z tmp ]; then
+ echo -e $RED"docker is required to run the test environment, pls install"$ERED
+ exit 1
+fi
# Just resetting any previous echo formatting...
echo -ne $EBOLD$ERED$EGREEN
G2_COUNT=0
G3_COUNT=0
+# Var to switch between http and https. Extra curl flag needed for https
+export RIC_SIM_HTTPX="http"
+export RIC_SIM_LOCALHOST=$RIC_SIM_HTTPX"://localhost:"
+export RIC_SIM_PORT=$RIC_SIM_INTERNAL_PORT
+export RIC_SIM_CERT_MOUNT_DIR="./fakedir" #Fake dir so that the sim container does not find any cert
+
#Localhost constant
LOCALHOST="http://localhost:"
__check_image_var " Consul" $1 "CONSUL_IMAGE" "CONSUL_REMOTE_IMAGE" "CONSUL_REMOTE_IMAGE_TAG"
__check_image_var " CBS" $1 "CBS_IMAGE" "CBS_REMOTE_IMAGE" "CBS_REMOTE_IMAGE_TAG"
__check_image_var " SDNC DB" $1 "SDNC_DB_IMAGE" "SDNC_DB_REMOTE_IMAGE" "SDNC_DB_REMOTE_IMAGE_TAG"
+__check_image_var " SDNC ONAP A1 Adapter" $1 "SDNC_ONAP_A1_ADAPTER_IMAGE" "SDNC_ONAP_A1_ADAPTER_REMOTE_IMAGE" "SDNC_ONAP_A1_ADAPTER_REMOTE_IMAGE_TAG"
+__check_image_var " SDNC ONAP DB" $1 "SDNC_ONAP_DB_IMAGE" "SDNC_ONAP_DB_REMOTE_IMAGE" "SDNC_ONAP_DB_REMOTE_IMAGE_TAG"
#Errors in image setting - exit
if [ $IMAGE_ERR -ne 0 ]; then
fi
elif [ $1 == "remote" ] || [ $1 == "remote-remove" ]; then
if [ $1 == "remote-remove" ]; then
- echo -ne " Attempt to stop and remove container(s), if running - \033[0K\r"
+ echo -ne " Attempt to stop and remove container(s), if running - ${SAMELINE}"
tmp="$(docker ps -aq --filter name=${3})"
if [ $? -eq 0 ] && [ ! -z "$tmp" ]; then
- docker stop $tmp &> /dev/null
+ docker stop $tmp &> .dockererr
if [ $? -ne 0 ]; then
((IMAGE_ERR++))
echo ""
echo -e $RED" Container(s) could not be stopped - try manual stopping the container(s)"$ERED
+ cat .dockererr
return 1
fi
fi
- echo -ne " Attempt to stop and remove container(s), if running - "$GREEN"stopped"$EGREEN"\033[0K\r"
+ echo -ne " Attempt to stop and remove container(s), if running - "$GREEN"stopped"$EGREEN"${SAMELINE}"
tmp="$(docker ps -aq --filter name=${3})" &> /dev/null
if [ $? -eq 0 ] && [ ! -z "$tmp" ]; then
- docker rm $tmp &> /dev/null
+ docker rm $tmp &> .dockererr
if [ $? -ne 0 ]; then
((IMAGE_ERR++))
echo ""
echo -e $RED" Container(s) could not be removed - try manual removal of the container(s)"$ERED
+ cat .dockererr
return 1
fi
fi
echo -e " Attempt to stop and remove container(s), if running - "$GREEN"stopped removed"$EGREEN
- echo -ne " Removing image - \033[0K\r"
+ echo -ne " Removing image - ${SAMELINE}"
tmp="$(docker images -q ${4})" &> /dev/null
if [ $? -eq 0 ] && [ ! -z "$tmp" ]; then
- docker rmi $4 &> /dev/null
+ docker rmi $4 &> .dockererr
if [ $? -ne 0 ]; then
((IMAGE_ERR++))
echo ""
echo -e $RED" Image could not be removed - try manual removal of the image"$ERED
+ cat .dockererr
return 1
fi
echo -e " Removing image - "$GREEN"removed"$EGREEN
tmp_im=""
fi
if [ -z "$tmp_im" ]; then
- echo -ne " Pulling image\033[0K\r"
- docker pull $4 > /dev/null
+ echo -ne " Pulling image${SAMELINE}"
+ docker pull $4 &> .dockererr
tmp_im=$(docker images ${4} | grep -v REPOSITORY)
if [ -z "$tmp_im" ]; then
echo ""
echo -e " Pulling image -$RED could not be pulled"$ERED
((IMAGE_ERR++))
+ cat .dockererr
return 1
fi
echo -e " Pulling image -$GREEN Pulled $EGREEN"
app="Consul"; __check_and_pull_image $1 "$app" $CONSUL_APP_NAME $CONSUL_IMAGE
app="CBS"; __check_and_pull_image $1 "$app" $CBS_APP_NAME $CBS_IMAGE
app="SDNC DB"; __check_and_pull_image $1 "$app" $SDNC_APP_NAME $SDNC_DB_IMAGE
+app="SDNC ONAP A1 Adapter"; __check_and_pull_image $1 "$app" $SDNC_ONAP_APP_NAME $SDNC_ONAP_A1_ADAPTER_IMAGE
+app="SDNC ONAP DB"; __check_and_pull_image $1 "$app" $SDNC_ONAP_APP_NAME $SDNC_ONAP_DB_IMAGE
# MR stub image not checked, will be built by this script - only local image
# CR stub image not checked, will be built by this script - only local image
cd $curdir
cd ../mrstub
echo " Building mrstub image: mrstub:latest"
-docker build -t mrstub . &> /dev/null
+docker build -t mrstub . &> .dockererr
if [ $? -eq 0 ]; then
echo -e $GREEN" Build Ok"$EGREEN
else
echo -e $RED" Build Failed"$ERED
((RES_CONF_FAIL++))
+ cat .dockererr
fi
cd $curdir
cd ../cr
echo " Building Callback Receiver image: callback-receiver:latest"
-docker build -t callback-receiver . &> /dev/null
+docker build -t callback-receiver . &> .dockererr
if [ $? -eq 0 ]; then
echo -e $GREEN" Build Ok"$EGREEN
else
echo -e $RED" Build Failed"$ERED
((RES_CONF_FAIL++))
+ cat .dockererr
fi
cd $curdir
echo -e " Consul\t$(docker images --format $format_string $CONSUL_IMAGE)" >> $docker_tmp_file
echo -e " CBS\t$(docker images --format $format_string $CBS_IMAGE)" >> $docker_tmp_file
echo -e " SDNC DB\t$(docker images --format $format_string $SDNC_DB_IMAGE)" >> $docker_tmp_file
+echo -e " SDNC ONAP A1 Adapter\t$(docker images --format $format_string $SDNC_ONAP_A1_ADAPTER_IMAGE)" >> $docker_tmp_file
+echo -e " SDNC ONAP DB\t$(docker images --format $format_string $SDNC_ONAP_DB_IMAGE)" >> $docker_tmp_file
column -t -s $'\t' $docker_tmp_file
"Control Panel " $CONTROL_PANEL_APP_NAME\
"SDNC A1 Controller " $SDNC_APP_NAME\
"SDNC DB " $SDNC_DB_APP_NAME\
+ "SDNC ONAP A1 Adapter " $SDNC_ONAP_APP_NAME\
+ "SDNC DB " $SDNC_ONAP_DB_APP_NAME\
"CBS " $CBS_APP_NAME\
"Consul " $CONSUL_APP_NAME)
for((w=${#CONTR}; w<$nw; w=w+1)); do
CONTR="$CONTR "
done
- echo -ne " $APP: $CONTR - ${GREEN}stopping${EGREEN}\033[0K\r"
+ echo -ne " $APP: $CONTR - ${GREEN}stopping${EGREEN}${SAMELINE}"
docker stop $(docker ps -qa --filter name=${CONTR}) &> /dev/null
- echo -ne " $APP: $CONTR - ${GREEN}stopped${EGREEN}\033[0K\r"
+ echo -ne " $APP: $CONTR - ${GREEN}stopped${EGREEN}${SAMELINE}"
docker rm $(docker ps -qa --filter name=${CONTR}) &> /dev/null
echo -e " $APP: $CONTR - ${GREEN}stopped removed${EGREEN}"
done
start=$SECONDS
duration=$((SECONDS-start))
while [ $duration -lt $1 ]; do
- echo -ne " Slept for ${duration} seconds\033[0K\r"
+ echo -ne " Slept for ${duration} seconds${SAMELINE}"
sleep 1
duration=$((SECONDS-start))
done
- echo -ne " Slept for ${duration} seconds\033[0K\r"
+ echo -ne " Slept for ${duration} seconds${SAMELINE}"
echo ""
}
# Function to create the docker network for the test
# Not to be called from the test script itself.
__create_docker_network() {
- tmp=$(docker network ls -q --filter name=$DOCKER_SIM_NWNAME)
+ tmp=$(docker network ls --format={{.Name}} --filter name=$DOCKER_SIM_NWNAME)
if [ $? -ne 0 ]; then
echo -e $RED" Could not check if docker network $DOCKER_SIM_NWNAME exists"$ERED
return 1
fi
- if [ -z tmp ]; then
+ if [ "$tmp" != $DOCKER_SIM_NWNAME ]; then
echo -e "Creating docker network:$BOLD $DOCKER_SIM_NWNAME $EBOLD"
docker network create $DOCKER_SIM_NWNAME
if [ $? -ne 0 ]; then
}
# Check if container is started by calling url on localhost using a port, expects response code 2XX
-# args: <container-name> <port> <url>
+# args: <container-name> <port> <url> https|https
# Not to be called from the test script itself.
__check_container_start() {
- if [ $# -ne 3 ]; then
+ paramError=0
+ if [ $# -ne 4 ]; then
+ paramError=1
+ elif [ $4 != "http" ] && [ $4 != "https" ]; then
+ paramError=1
+ fi
+ if [ $paramError -ne 0 ]; then
((RES_CONF_FAIL++))
- __print_err "need 3 args, <container-name> <port> <url>" $@
+ __print_err "need 3 args, <container-name> <port> <url> https|https" $@
return 1
fi
- echo -ne " Container $BOLD$1$EBOLD starting\033[0K\r"
+ echo -ne " Container $BOLD$1$EBOLD starting${SAMELINE}"
appname=$1
localport=$2
url=$3
- pa_started=false
+ app_started=0
for i in {1..10}; do
- if [ $(docker inspect --format '{{ .State.Running }}' $appname) ]; then
+ if [ "$(docker inspect --format '{{ .State.Running }}' $appname)" == "true" ]; then
echo -e " Container $BOLD$1$EBOLD$GREEN running$EGREEN on$BOLD image $(docker inspect --format '{{ .Config.Image }}' ${appname}) $EBOLD"
- pa_started=true
+ app_started=1
break
else
sleep $i
fi
done
- if ! [ $pa_started ]; then
+ if [ $app_started -eq 0 ]; then
((RES_CONF_FAIL++))
echo ""
echo -e $RED" Container $BOLD${appname}$EBOLD could not be started"$ERED
fi
if [ $localport -eq 0 ]; then
while [ $localport -eq 0 ]; do
- echo -ne " Waiting for container ${appname} to publish its ports...\033[0K\r"
+ echo -ne " Waiting for container ${appname} to publish its ports...${SAMELINE}"
localport=$(__find_sim_port $appname)
sleep 1
- echo -ne " Waiting for container ${appname} to publish its ports...retrying....\033[0K\r"
+ echo -ne " Waiting for container ${appname} to publish its ports...retrying....${SAMELINE}"
done
echo -ne " Waiting for container ${appname} to publish its ports...retrying....$GREEN OK $EGREEN"
echo ""
fi
pa_st=false
- echo -ne " Waiting for container ${appname} service status...\033[0K\r"
+ echo -ne " Waiting for container ${appname} service status...${SAMELINE}"
for i in {1..20}; do
- result="$(__do_curl $LOCALHOST${localport}${url})"
+ if [ $4 == "https" ]; then
+ result="$(__do_curl "-k https://localhost:"${localport}${url})"
+ else
+ result="$(__do_curl $LOCALHOST${localport}${url})"
+ fi
if [ $? -eq 0 ]; then
if [ ${#result} -gt 15 ]; then
#If response is too long, truncate
result="...response text too long, omitted"
fi
- echo -ne " Waiting for container $BOLD${appname}$EBOLD service status, result: $result\033[0K\r"
+ echo -ne " Waiting for container $BOLD${appname}$EBOLD service status, result: $result${SAMELINE}"
echo -ne " Container $BOLD${appname}$EBOLD$GREEN is alive$EGREEN, responds to service status:$GREEN $result $EGREEN"
pa_st=true
break
else
#echo " Retrying in $i seconds"
- echo -ne " Waiting for container ${appname} service status...retrying in $i seconds\033[0K\r"
+ echo -ne " Waiting for container ${appname} service status...retrying in $i seconds${SAMELINE}"
sleep $i
fi
done
__start_container() {
variableArgCount=$(($#-2))
- if [ $# -lt 5 ] && [ [ $(($variableArgCount%3)) -ne 0 ]; then
+ if [ $# -lt 6 ] && [ [ $(($variableArgCount%4)) -ne 0 ]; then
((RES_CONF_FAIL++))
- __print_err "need 5 or more args, <docker-compose-dir> NODOCKERARGS|<docker-compose-arg> <app-name> <port-number> <alive-url> [<app-name> <port-number> <alive-url>]*" $@
+ __print_err "need 6 or more args, <docker-compose-dir> NODOCKERARGS|<docker-compose-arg> <app-name> <port-number> <alive-url> http|https [<app-name> <port-number> <alive-url> http|https ]*" $@
exit 1
fi
cd $1
if [ "$2" == "NODOCKERARGS" ]; then
- docker-compose up -d &> /dev/null
+ docker-compose up -d &> .dockererr
+ if [ $? -ne 0 ]; then
+ echo -e $RED"Problem to launch container(s) with docker-compose"$ERED
+ cat .dockererr
+ fi
else
- docker-compose up -d $2 &> /dev/null
+ docker-compose up -d $2 &> .dockererr
+ if [ $? -ne 0 ]; then
+ echo -e $RED"Problem to launch container(s) with docker-compose"$ERED
+ cat .dockererr
+ fi
fi
shift; shift;
app=$1; shift;
port=$1; shift;
url=$1; shift;
- let cntr=cntr+3
+ httpx=$1; shift;
+ let cntr=cntr+4
- __check_container_start "$app" "$port" "$url"
+ __check_container_start "$app" "$port" "$url" $httpx
done
cd $curdir
targetJson=$(< $1)
targetJson="{\"config\":"$targetJson"}"
echo "TARGET JSON: $targetJson" >> $HTTPLOG
- res=$(python ../common/compare_json.py "$targetJson" "$body")
+ res=$(python3 ../common/compare_json.py "$targetJson" "$body")
if [ $res -ne 0 ]; then
echo -e $RED" FAIL - policy json config read from consul/cbs is not equal to the intended json config...." $ERED
((RES_CONF_FAIL++))
}
# Function to perpare the consul configuration according to the current simulator configuration
-# args: SDNC|NOSDNC <output-file>
+# args: SDNC|SDNC_ONAP|NOSDNC <output-file>
# (Function for test scripts)
prepare_consul_config() {
echo -e $BOLD"Prepare Consul config"$EBOLD
if [ $# != 2 ]; then
((RES_CONF_FAIL++))
- __print_err "need two args, SDNC|NOSDNC <output-file>" $@
+ __print_err "need two args, SDNC|SDNC_ONAP|NOSDNC <output-file>" $@
exit 1
fi
if [ $1 == "SDNC" ]; then
echo -e " Config$BOLD including SDNC$EBOLD configuration"
+ elif [ $1 == "SDNC_ONAP" ]; then
+ echo -e " Config$BOLD including SDNC ONAP$EBOLD configuration"
elif [ $1 == "NOSDNC" ]; then
- echo -e " Config$BOLD excluding SDNC$EBOLD configuration"
+ echo -e " Config$BOLD excluding SDNC or SDNC ONAP$EBOLD configuration"
else
((RES_CONF_FAIL++))
- __print_err "need two args, SDNC|NOSDNC <output-file>" $@
+ __print_err "need two args, SDNC|SDNC_ONAP|NOSDNC <output-file>" $@
exit 1
fi
config_json=$config_json"\n }"
config_json=$config_json"\n ],"
fi
+ if [ $1 == "SDNC_ONAP" ]; then
+ config_json=$config_json"\n \"controller\": ["
+ config_json=$config_json"\n {"
+ config_json=$config_json"\n \"name\": \"$SDNC_ONAP_APP_NAME\","
+ config_json=$config_json"\n \"baseUrl\": \"http://$SDNC_ONAP_APP_NAME:$SDNC_ONAP_INTERNAL_PORT\","
+ config_json=$config_json"\n \"userName\": \"$SDNC_ONAP_USER\","
+ config_json=$config_json"\n \"password\": \"$SDNC_ONAP_PWD\""
+ config_json=$config_json"\n }"
+ config_json=$config_json"\n ],"
+ fi
config_json=$config_json"\n \"streams_publishes\": {"
fi
config_json=$config_json"\n {"
config_json=$config_json"\n \"name\": \"$ric\","
- config_json=$config_json"\n \"baseUrl\": \"http://$ric:$RIC_SIM_INTERNAL_PORT\","
+ config_json=$config_json"\n \"baseUrl\": \"$RIC_SIM_HTTPX://$ric:$RIC_SIM_PORT\","
if [ $1 == "SDNC" ]; then
config_json=$config_json"\n \"controller\": \"$SDNC_APP_NAME\","
+ elif [ $1 == "SDNC_ONAP" ]; then
+ config_json=$config_json"\n \"controller\": \"$SDNC_ONAP_APP_NAME\","
fi
config_json=$config_json"\n \"managedElementIds\": ["
config_json=$config_json"\n \"me1_$ric\","
echo -e $BOLD"Starting Consul and CBS"$EBOLD
- __start_container consul_cbs NODOCKERARGS "$CONSUL_APP_NAME" "$CONSUL_EXTERNAL_PORT" "/ui/dc1/kv" \
- "$CBS_APP_NAME" "$CBS_EXTERNAL_PORT" "/healthcheck"
+ __start_container consul_cbs NODOCKERARGS "$CONSUL_APP_NAME" "$CONSUL_EXTERNAL_PORT" "/ui/dc1/kv" "http" \
+ "$CBS_APP_NAME" "$CBS_EXTERNAL_PORT" "/healthcheck" "http"
}
###########################
### RIC Simulator functions
###########################
+use_simulator_http() {
+ echo -e "Using unsecure $BOLD http $EBOLD towards the simulators"
+ export RIC_SIM_HTTPX="http"
+ export RIC_SIM_LOCALHOST=$RIC_SIM_HTTPX"://localhost:"
+ export RIC_SIM_PORT=$RIC_SIM_INTERNAL_PORT
+ export RIC_SIM_CERT_MOUNT_DIR="./fakedir" #Fake dir so that the sim container does not find any cert
+ echo ""
+}
+
+use_simulator_https() {
+ echo -e "Using secure $BOLD https $EBOLD towards the simulators"
+ export RIC_SIM_HTTPX="https"
+ export RIC_SIM_LOCALHOST=$RIC_SIM_HTTPX"://localhost:"
+ export RIC_SIM_PORT=$RIC_SIM_INTERNAL_SECURE_PORT
+ export RIC_SIM_CERT_MOUNT_DIR="./cert"
+ echo ""
+}
+
# Start one group (ricsim_g1, ricsim_g2 or ricsim_g3) with a number of RIC Simulators using a given A interface
# args: ricsim_g1|ricsim_g2|ricsim_g3 <count> <interface-id>
# (Function for test scripts)
while [ $cntr -le $2 ]; do
app=$1"_"$cntr
port=0
- app_data="$app_data $app $port /"
+ app_data="$app_data $app $port / "$RIC_SIM_HTTPX
let cntr=cntr+1
done
-
__start_container ric "$docker_args" $app_data
}
echo -e $BOLD"Starting Control Panel"$EBOLD
- __start_container control_panel NODOCKERARGS $CONTROL_PANEL_APP_NAME $CONTROL_PANEL_EXTERNAL_PORT "/"
+ __start_container control_panel NODOCKERARGS $CONTROL_PANEL_APP_NAME $CONTROL_PANEL_EXTERNAL_PORT "/" "http"
}
echo -e $BOLD"Starting SDNC A1 Controller"$EBOLD
- __start_container sdnc NODOCKERARGS $SDNC_APP_NAME $SDNC_EXTERNAL_PORT "/apidoc/explorer"
+ __start_container sdnc NODOCKERARGS $SDNC_APP_NAME $SDNC_EXTERNAL_PORT "/apidoc/explorer" "http"
}
+#######################
+### SDNC ONAP functions
+#######################
+
+# Start the SDNC ONAP A1 Adapter
+# args: -
+# (Function for test scripts)
+start_sdnc_onap() {
+
+ echo -e $BOLD"Starting SDNC ONAP A1 Adapter"$EBOLD
+
+ __start_container sdnc_onap NODOCKERARGS $SDNC_ONAP_APP_NAME $SDNC_ONAP_EXTERNAL_PORT "/apidoc/explorer" "http"
+
+}
+
+# Configure the SDNC ONAP A1 Adapter
+# args: -
+# (Function for test scripts)
+config_sdnc_onap() {
+
+ echo -e $BOLD"Configuring SDNC ONAP A1 Adapter"$EBOLD
+
+ LOCALFILE=".sdnc_onap.prop"
+ REMOTEFILE="/tmp/.sdnc_onap.prop"
+
+ docker cp $SDNC_ONAP_APP_NAME:$SDNC_ONAP_PROPERTIES_FILE $LOCALFILE
+ if [ $? -ne 0 ]; then
+ echo -e $RED"Could not copy $SDNC_ONAP_PROPERTIES_FILE from $SDNC_ONAP_APP_NAME container"$ERED
+ exit 1
+ fi
+
+ #Config of the prop file shall be inserted here
+
+ #Copy file to /tmp and then to final destination, a trick to get correct permission of the file.
+
+ docker cp $LOCALFILE $SDNC_ONAP_APP_NAME:$REMOTEFILE
+ if [ $? -ne 0 ]; then
+ echo -e $RED"Could not copy local $LOCALFILE to $REMOTEFILE in $SDNC_ONAP_APP_NAME container"$ERED
+ exit 1
+ fi
+
+ docker exec -it $SDNC_ONAP_APP_NAME cp $REMOTEFILE $SDNC_ONAP_PROPERTIES_FILE
+ if [ $? -ne 0 ]; then
+ echo -e $RED"Could not copy $REMOTEFILE to $SDNC_ONAP_PROPERTIES_FILE in $SDNC_ONAP_APP_NAME container"$ERED
+ exit 1
+ fi
+}
+
#####################
### MR stub functions
#####################
start_mr() {
echo -e $BOLD"Starting Message Router 'mrstub'"$EBOLD
-
- __start_container mr NODOCKERARGS $MR_APP_NAME $MR_EXTERNAL_PORT "/"
+ export MR_CERT_MOUNT_DIR="./cert"
+ __start_container mr NODOCKERARGS $MR_APP_NAME $MR_EXTERNAL_PORT "/" "http"
}
echo -e $BOLD"Starting Callback Receiver"$EBOLD
- __start_container cr NODOCKERARGS $CR_APP_NAME $CR_EXTERNAL_PORT "/"
+ __start_container cr NODOCKERARGS $CR_APP_NAME $CR_EXTERNAL_PORT "/" "http"
}
echo -e $BOLD"Starting Policy Agent"$EBOLD
- __start_container policy_agent NODOCKERARGS $POLICY_AGENT_APP_NAME $POLICY_AGENT_EXTERNAL_PORT "/status"
+ __start_container policy_agent NODOCKERARGS $POLICY_AGENT_APP_NAME $POLICY_AGENT_EXTERNAL_PORT "/status" "http"
}
# All calls to the agent will be directed to the agent REST interface from now on
# args: -
# (Function for test scripts)
-use_agent_rest() {
- echo -e $BOLD"Using agent REST interface"$EBOLD
+use_agent_rest_http() {
+ echo -e $BOLD"Using agent REST interface with http"$EBOLD
export ADAPTER=$RESTBASE
echo ""
}
+# All calls to the agent will be directed to the agent REST interface from now on
+# args: -
+# (Function for test scripts)
+use_agent_rest_https() {
+ echo -e $BOLD"Using agent REST interface with https"$EBOLD
+ export ADAPTER=$RESTBASE_SECURE
+ echo ""
+}
+
# All calls to the agent will be directed to the agent dmaap interface from now on
# args: -
# (Function for test scripts)
docker logs $CR_APP_NAME > $TESTLOGS/$ATC/$1_cr.log 2>&1
cp .httplog_${ATC}.txt $TESTLOGS/$ATC/$1_httplog_${ATC}.txt 2>&1
- docker exec -it $SDNC_APP_NAME cat /opt/opendaylight/data/log/karaf.log > $TESTLOGS/$ATC/$1_karaf.log 2>&1
+ docker exec -it $SDNC_APP_NAME cat $SDNC_KARAF_LOG> $TESTLOGS/$ATC/$1_SDNC_karaf.log 2>&1
+
+ docker exec -it $SDNC_ONAP_APP_NAME cat $SDNC_ONAP_KARAF_LOG > $TESTLOGS/$ATC/$1_SDNC_ONAP_karaf.log 2>&1
rics=$(docker ps -f "name=$RIC_SIM_PREFIX" --format "{{.Names}}")
for ric in $rics; do
result="$(__do_curl $2$path)"
retcode=$?
echo "$result" > .tmp.curl.json
- result=$(python ../common/count_json_elements.py ".tmp.curl.json")
+ result=$(python3 ../common/count_json_elements.py ".tmp.curl.json")
fi
duration=$((SECONDS-start))
- echo -ne " Result=${result} after ${duration} seconds\033[0K\r"
+ echo -ne " Result=${result} after ${duration} seconds${SAMELINE}"
let ctr=ctr+1
if [ $retcode -ne 0 ]; then
if [ $duration -gt $6 ]; then
fi
elif [ $4 = "=" ] && [ "$result" -eq $5 ]; then
((RES_PASS++))
- echo -e " Result=${result} after ${duration} seconds\033[0K\r"
+ echo -e " Result=${result} after ${duration} seconds${SAMELINE}"
echo -e $GREEN" PASS${EGREEN} - Result=${result} after ${duration} seconds"
#echo -e "---- \033[32m\033[1mPASS\033[0m - Test criteria met in ${duration} seconds ----"
return
elif [ $4 = ">" ] && [ "$result" -gt $5 ]; then
((RES_PASS++))
- echo -e " Result=${result} after ${duration} seconds\033[0K\r"
+ echo -e " Result=${result} after ${duration} seconds${SAMELINE}"
echo -e $GREEN" PASS${EGREEN} - Result=${result} after ${duration} seconds"
#echo -e "---- \033[32m\033[1mPASS\033[0m - Test criteria met in ${duration} seconds, result = ${result} ----"
return
elif [ $4 = "<" ] && [ "$result" -lt $5 ]; then
((RES_PASS++))
- echo -e " Result=${result} after ${duration} seconds\033[0K\r"
+ echo -e " Result=${result} after ${duration} seconds${SAMELINE}"
echo -e $GREEN" PASS${EGREEN} - Result=${result} after ${duration} seconds"
#echo -e "---- \033[32m\033[1mPASS\033[0m - Test criteria met in ${duration} seconds, result = ${result} ----"
return
elif [ $4 = "contain_str" ] && [[ $result =~ $5 ]]; then
((RES_PASS++))
- echo -e " Result=${result} after ${duration} seconds\033[0K\r"
+ echo -e " Result=${result} after ${duration} seconds${SAMELINE}"
echo -e $GREEN" PASS${EGREEN} - Result=${result} after ${duration} seconds"
#echo -e "---- \033[32m\033[1mPASS\033[0m - Test criteria met in ${duration} seconds, result = ${result} ----"
return
result="$(__do_curl $2$path)"
retcode=$?
echo "$result" > .tmp.curl.json
- result=$(python ../common/count_json_elements.py ".tmp.curl.json")
+ result=$(python3 ../common/count_json_elements.py ".tmp.curl.json")
fi
if [ $retcode -ne 0 ]; then
((RES_FAIL++))
# (Function for test scripts)
mr_greater() {
if [ $# -eq 2 ] || [ $# -eq 3 ]; then
- __var_test "MR" "$LOCALHOST$MR_EXTERNAL_PORT/counter/" $1 "=" $2 $3
+ __var_test "MR" "$LOCALHOST$MR_EXTERNAL_PORT/counter/" $1 ">" $2 $3
else
((RES_CONF_FAIL++))
__print_err "Wrong args to mr_greater, needs two or three args: <sim-param> <target-value> [ timeout ]" $@
-.tmp.json
\ No newline at end of file
+.tmp.json
+.dockererr
\ No newline at end of file
msg_callbacks={}
# Server info
-HOST_IP = "0.0.0.0"
+HOST_IP = "::"
HOST_PORT = 8090
# Metrics vars
-.tmp.json
\ No newline at end of file
+.tmp.json
+.dockererr
\ No newline at end of file
# ============LICENSE_END=================================================
#
-FROM python:3.7
+#Dockerfile to create an image with both python3.8 and nodejs 14
+FROM python:3.8
WORKDIR /usr/src/app
+#Install python modules
COPY requirements.txt requirements.txt
-
RUN pip install -r requirements.txt
+#Install nodejs and packages
+RUN curl -sL https://deb.nodesource.com/setup_14.x | bash -
+RUN apt-get install -y nodejs
+COPY package.json package.json
+RUN npm install express
+RUN npm install express-http-proxy
+
+#Copy apps and start script
COPY mr.py mr.py
+COPY frontend.js frontend.js
+COPY start.sh start.sh
+
+RUN chmod +x ./start.sh
-CMD [ "python3", "-u", "./mr.py" ]
\ No newline at end of file
+CMD ["./start.sh"]
\ No newline at end of file
The mrstub exposes the read and write urls, used by the agent, as configured in consul.
In addition, request messages can be fed to the mrstub and the response messages can be read by polling.
+# Ports and certificates
+
+The MR normally opens the port 3905 for http. If a certificate and a key are provided the simulator will also open port 3906 for https.
+The certificate and key shall be placed in the same dir and the dir shall be mounted to /usr/src/app/cert in the container.
+
+| Port | Protocol |
+| -------- | ----- |
+| 3905 | http |
+| 3906 | https |
+
+The dir cert contains a self-signed cert. Use the script generate_cert_and_key.sh to generate a new certificate and key. The password of the certificate must be set 'test'.
+The same urls are availables on both the http port 3905 and the https port 3906. If using curl and https, the flag -k shall be given to make curl ignore checking the certificate.
+
+### Message Router interface ###
+
+Messages from the MR can be read using this url using http(s) GET:<br>
+```events/A1-POLICY-AGENT-READ/users/policy-agent?timeout=<timeout>&limit=<limit>```<br>
+Both 'timeout' and 'limit' are optional.
+|Parameter|Description|
+|---------|--------------------|
+|limit|Optional parameter to limit the maximum number of messages to return. A value 0 < limit < 4096. If limit is not given, the limit is set to 4096.|
+|timeout|Optional parameter to control the max length of the poll. A value in milliseconds 0 < timeout < 60000. If timeout is not given, the timeout is 10 seconds. If not messages are available when the poll starts, the poll will end as soon as there is at least one message available|
+
+Messages to the MR can be written using this url http(s) POST/PUT:<br>
+```/events/A1-POLICY-AGENT-WRITE```<br>
+One or more messages can be written in the same operation.
### Control interface ###
>Build image<br>
```docker build -t mrstub .```
->Start the image<br>
+>Start the image on http only<br>
```docker run -it -p 3905:3905 mrstub```
-The script ```mrstub-build-start.sh``` do the above two steps in one go. This starts the stub container in stand-alone mode for basic test.<br>If the mrstub should be executed manually with the agent, replace docker run with this command to connect to the docker network with the correct service name (--name shall be the same as configured in consul for the read and write streams).
+>Start the image on http and https<br>
+```docker run -it -p 3905:3905 -p 3906:3906 -v "/PATH_TO_CERT/cert:/usr/src/app/cert" mrstub```
+
+The script ```mrstub-build-start.sh``` do the build and docker run in one go. This starts the stub container in stand-alone mode for basic test.<br>If the mrstub should be executed manually with the agent, replace docker run with this command to connect to the docker network with the correct service name (--name shall be the same as configured in consul for the read and write streams).
```docker run -it -p 3905:3905 --network nonrtric-docker-net --name message-router mrstub```
### Basic test ###
-Basic test is made with the script ```basic_test.sh``` which tests all the available urls with a subset of the possible operations. Use the script ```mrstub-build-start.sh``` to start the mrstub in a container first.
\ No newline at end of file
+Basic test is made with the script ```basic_test.sh nonsecure|secure``` which tests all the available urls with a subset of the possible operations. Choose nonsecure for http and secure for https. Use the script ```mrstub-build-start.sh``` to start the mrstub in a container first.
\ No newline at end of file
# Automated test script for mrstub container
-# mr-stub port
-export PORT=3905
+# Run the build_and_start with the same arg as this script
+if [ $# -ne 1 ]; then
+ echo "Usage: ./basic_test nonsecure|secure"
+ exit 1
+fi
+if [ "$1" != "nonsecure" ] && [ "$1" != "secure" ]; then
+ echo "Usage: ./basic_test nonsecure|secure"
+ exit 1
+fi
+
+if [ $1 == "nonsecure" ]; then
+ #Default http port for the simulator
+ PORT=3905
+ # Set http protocol
+ HTTPX="http"
+else
+ #Default https port for the mr-stub
+ PORT=3906
+ # Set https protocol
+ HTTPX="https"
+fi
# source function to do curl and check result
. ../common/do_curl_function.sh
RESULT="json:[{\"apiVersion\":\"1.0\",\"operation\":\"GET\",\"correlationId\":\""$CORRID"\",\"originatorId\": \"849e6c6b420\",\"payload\":{},\"requestId\":\"23343221\", \"target\":\"policy-agent\", \"timestamp\":\"????\", \"type\":\"request\",\"url\":\"/test2\"}]"
do_curl GET '/events/A1-POLICY-AGENT-READ/users/policy-agent' 200
+echo "=== Fetch a request, empty. Shall delay 10 seconds ==="
+T1=$SECONDS
+RESULT="json:[]"
+do_curl GET '/events/A1-POLICY-AGENT-READ/users/policy-agent' 200
+T2=$SECONDS
+if [ $(($T2-$T1)) -lt 10 ] || [ $(($T2-$T1)) -gt 15 ]; then
+ echo "Delay to short or too long"$(($T2-$T1))". Should be default 10 sec"
+ exit 1
+else
+ echo " Delay ok:"$(($T2-$T1))
+fi
+
+echo "=== Fetch a request, empty. Shall delay 5 seconds ==="
+T1=$SECONDS
+RESULT="json:[]"
+do_curl GET '/events/A1-POLICY-AGENT-READ/users/policy-agent?timeout=5000' 200
+T2=$SECONDS
+if [ $(($T2-$T1)) -lt 5 ] || [ $(($T2-$T1)) -gt 7 ]; then
+ echo "Delay to short or too long"$(($T2-$T1))". Should be 10 sec"
+ exit 1
+else
+ echo " Delay ok:"$(($T2-$T1))
+fi
+
+echo "=== Fetch a request with limit 25, shall be empty. ==="
+RESULT="json-array-size:0"
+do_curl GET '/events/A1-POLICY-AGENT-READ/users/policy-agent?timeout=1000&limit=25' 200
+
+echo "=== Send 5 request to test limit on MR GET==="
+RESULT="*"
+for i in {1..5}
+do
+ do_curl POST '/send-request?operation=GET&url=/test2' 200
+done
+
+echo "=== Fetch a request with limit 3. ==="
+RESULT="json-array-size:3"
+do_curl GET '/events/A1-POLICY-AGENT-READ/users/policy-agent?timeout=1000&limit=3' 200
+
+echo "=== Fetch a request with limit 3, shall return 2. ==="
+RESULT="json-array-size:2"
+do_curl GET '/events/A1-POLICY-AGENT-READ/users/policy-agent?timeout=1000&limit=3' 200
+
+echo "=== Fetch a request with limit 3, shall return 0. ==="
+RESULT="json-array-size:0"
+do_curl GET '/events/A1-POLICY-AGENT-READ/users/policy-agent?timeout=1000&limit=3' 200
+
echo "=== Send a json response ==="
# Create minimal accepted response message
echo "[{\"correlationId\": \""$CORRID"\", \"message\": \"test2-response\", \"status\": \"200\"}]" > .tmp.json
--- /dev/null
+-----BEGIN CERTIFICATE-----
+MIICljCCAX4CCQCv7SV/aTc/YjANBgkqhkiG9w0BAQsFADANMQswCQYDVQQGEwJT
+RTAeFw0yMDA1MDMwMDI0MzdaFw00NzA5MTgwMDI0MzdaMA0xCzAJBgNVBAYTAlNF
+MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEApsGQcCv+Ce/+AbHx+3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k6Bk
+QH9cjMXdsd0Sb0Epw3CWGtXZ6YTHlVWqjdTNlOQdzQ7qfzktgcKujGwvQK0Mgd8x
+nmG+f/HWMOss0JEL3ZR+K9Rr50u8/R+W5+e4VE57yw1fg9Jpq2/sVe2Pt8S7isFK
+qDLoFZtF5RXi1O9KcA9BpnQX1ihPSC1RoY1pGXoF2D4KkV9U4/4j2qM6MGxjQ6lw
+MN0qJ/N70Lti3YWqvYiTymLwVJr8FqoMQsV19MB8012Xd51Bvy6igddhrO83wuuV
+b8PlUzl3Tl7yOviYqxiJ0xd8qw+Hs4+FkHbZIFJcUzTHVbb4SlPUE3wn6nrrIcfK
+rT4wsYhK3afrlvK3ILi6kzzazS1dK+Hv9+mNozNf5u5nNBFQ+7MhtttzLWIaiV6D
+ilLpOwcoO0X0qrzXKR7a+rQ/Dw==
+-----END ENCRYPTED PRIVATE KEY-----
--- /dev/null
+// ============LICENSE_START===============================================
+// Copyright (C) 2020 Nordix Foundation. All rights reserved.
+// ========================================================================
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+// ============LICENSE_END=================================================
+//
+
+//This script acts like a proxy. All operations, except MR GET messages, are re-sent to the python backend server.
+//The MR GET is intercepted and the python backend is polled until a message is available or up to a
+//maximum time decided by a query parameter. No query parameter will result in a 10s long poll.
+
+
+const proxy = require('express-http-proxy');
+const app = require('express')();
+const http = require('http');
+const https = require('https');
+const fs = require('fs');
+var privateKey;
+var certificate;
+var credentials;
+
+try {
+ privateKey = fs.readFileSync('cert/key.crt', 'utf8');
+ certificate = fs.readFileSync('cert/cert.crt', 'utf8');
+ credentials = {key: privateKey,
+ cert: certificate,
+ passphrase: 'test'};
+} catch(exp) {
+ console.log("Could not load cert and key")
+}
+
+const httpPort=3905;
+const httpsPort=3906;
+const proxyport=2222
+
+const sleep = (milliseconds) => {
+ return new Promise(resolve => setTimeout(resolve, milliseconds))
+}
+
+app.get("*/events/A1-POLICY-AGENT-READ/users/policy-agent*", inititate_long_poll);
+
+function inititate_long_poll(req,res) {
+ var millis=10000 //MR default is 10sec
+ var tmp=req.query.timeout
+ if (tmp != undefined) {
+ millis=parseInt(tmp);
+ millis=(millis < 0 ? 10000 : Math.min(millis, 60000)) //Max poll is 60 sec
+ console.log("Setting poll time to (ms): " + millis)
+ }
+ do_poll(req, res, req.url, Date.now()+millis)
+}
+
+function do_poll(req,res, url, millis) {
+ const options = {
+ hostname: 'localhost',
+ port: proxyport,
+ path: url,
+ method: 'GET'
+ }
+ http.get(options, function(resp) {
+ let data = '';
+ // Receiving chunk by chunk
+ resp.on('data', (chunk) => {
+ data += chunk;
+ });
+
+ // Full response received
+ resp.on('end', () => {
+ var payload=data.trim();
+ if (resp.statusCode == 200 && payload.length == 2 && payload=="[]" && Date.now()<this.millis) {
+ // Sleep before next poll
+ sleep(10).then(() => {
+ do_poll(req,res, this.url, this.millis)
+ })
+ } else {
+ //Eventually return the response
+ res.statusCode=resp.statusCode
+ res.header(resp.headers);
+ res.send(data)
+ return;
+ }
+ });
+ }.bind({millis:millis, url:url})).on("error", (err) => {
+ console.log("Error when reading from backend: " + err.message);
+ res.statusCode=500
+ res.send("ERROR detected in frontend: "+ err.message)
+ return
+ });
+}
+
+//Catch all, resend from proxy
+app.use(proxy('localhost:'+proxyport, {
+ limit: '5mb',
+}));
+
+//Start serving http
+var httpServer = http.createServer(app);
+var httpsServer;
+console.log("Running on http: "+httpPort)
+httpServer.listen(httpPort, "::");
+
+//Start serving https if cert is available
+if (credentials != undefined) {
+ httpsServer = https.createServer(credentials, app);
+ console.log("Running on https: "+httpsPort)
+ httpsServer.listen(httpsPort, "::");
+}
app = Flask(__name__)
# list of messages to/from Dmaap
-msg_requests={}
+msg_requests=[]
msg_responses={}
# Server info
-HOST_IP = "0.0.0.0"
-HOST_PORT = 3905
+HOST_IP = "127.0.0.1"
+HOST_PORT = 2222
# Metrics vars
cntr_msg_requests_submitted=0
msg=create_message(oper, correlation_id, payload, url)
print(msg)
print(APP_WRITE_URL+" MSG(correlationid = "+correlation_id+"): " + json.dumps(json.loads(msg), indent=2))
- msg_requests[correlation_id]=msg
+ msg_requests.append(msg)
cntr_msg_requests_submitted += 1
return Response(correlation_id, status=200, mimetype=MIME_TEXT)
except Exception as e:
def events_read():
global msg_requests
global cntr_msg_requests_fetched
+
+ limit=request.args.get('limit')
+ if (limit is None):
+ limit=4096
+ else:
+ limit=int(limit)
+ if (limit<0):
+ limit=0
+ if (limit>4096):
+ limit=4096
+ print("Limting number of returned messages to: "+str(limit))
try:
msgs=''
- for item in msg_requests:
+ cntr=0
+ while(cntr<limit and len(msg_requests)>0):
if (len(msgs)>1):
msgs=msgs+','
- msgs=msgs+msg_requests[item]
+ msgs=msgs+msg_requests.pop(0)
cntr_msg_requests_fetched += 1
-
- msg_requests={}
+ cntr=cntr+1
msgs='['+msgs+']'
print(AGENT_READ_URL+" MSGs: "+json.dumps(json.loads(msgs), indent=2))
return Response(msgs, status=200, mimetype=MIME_JSON)
cntr_msg_requests_fetched=0
cntr_msg_responses_submitted=0
cntr_msg_responses_fetched=0
- msg_requests={}
+ msg_requests=[]
msg_responses={}
return Response('OK', status=200, mimetype=MIME_TEXT)
docker build -t mrstub .
-docker run -it -p 3905:3905 mrstub
+docker run -it -p 3905:3905 -p 3906:3906 -v "$PWD/cert:/usr/src/app/cert" mrstub
--- /dev/null
+{
+ "name": "app",
+ "version": "1.0.0",
+ "description": "",
+ "main": "frontend.js",
+ "dependencies": {
+ "accepts": "^1.3.7",
+ "array-flatten": "^3.0.0",
+ "body-parser": "^1.19.0",
+ "bytes": "^3.1.0",
+ "content-disposition": "^0.5.3",
+ "content-type": "^1.0.4",
+ "cookie": "^0.4.1",
+ "cookie-signature": "^1.1.0",
+ "debug": "^4.1.1",
+ "depd": "^2.0.0",
+ "destroy": "^1.0.4",
+ "ee-first": "^1.1.1",
+ "encodeurl": "^1.0.2",
+ "es6-promise": "^4.2.8",
+ "escape-html": "^1.0.3",
+ "etag": "^1.8.1",
+ "express": "^4.17.1",
+ "express-http-proxy": "^1.6.0",
+ "finalhandler": "^1.1.2",
+ "forwarded": "^0.1.2",
+ "fresh": "^0.5.2",
+ "http-errors": "^1.7.3",
+ "iconv-lite": "^0.5.1",
+ "inherits": "^2.0.4",
+ "ipaddr.js": "^1.9.1",
+ "media-typer": "^1.1.0",
+ "merge-descriptors": "^1.0.1",
+ "methods": "^1.1.2",
+ "mime": "^2.4.5",
+ "mime-db": "^1.44.0",
+ "mime-types": "^2.1.27",
+ "ms": "^2.1.2",
+ "negotiator": "^0.6.2",
+ "on-finished": "^2.3.0",
+ "parseurl": "^1.3.3",
+ "path-to-regexp": "^6.1.0",
+ "proxy-addr": "^2.0.6",
+ "qs": "^6.9.3",
+ "range-parser": "^1.2.1",
+ "raw-body": "^2.4.1",
+ "safe-buffer": "^5.2.0",
+ "safer-buffer": "^2.1.2",
+ "send": "^0.17.1",
+ "serve-static": "^1.14.1",
+ "setprototypeof": "^1.2.0",
+ "statuses": "^2.0.0",
+ "toidentifier": "^1.0.0",
+ "type-is": "^1.6.18",
+ "unpipe": "^1.0.0",
+ "utils-merge": "^1.0.1",
+ "vary": "^1.1.2"
+ },
+ "devDependencies": {},
+ "scripts": {
+ "test": "echo \"Error: no test specified\" && exit 1"
+ },
+ "author": "",
+ "license": "ISC"
+}
-Flask==1.1.1
+pip==20.1
+Flask==1.1.2
+
--- /dev/null
+#!/bin/bash
+
+# ============LICENSE_START===============================================
+# Copyright (C) 2020 Nordix Foundation. All rights reserved.
+# ========================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ============LICENSE_END=================================================
+#
+
+nodejs frontend.js &
+python3 -u ./mr.py
\ No newline at end of file
--- /dev/null
+.tmp.json
+.dockererr
\ No newline at end of file
--- /dev/null
+.tmp.json
+.dockererr
\ No newline at end of file
--- /dev/null
+.tmp.json
+.dockererr
\ No newline at end of file
--- /dev/null
+.tmp.json
+.dockererr
\ No newline at end of file
--- /dev/null
+-----BEGIN CERTIFICATE-----
+MIICljCCAX4CCQCv7SV/aTc/YjANBgkqhkiG9w0BAQsFADANMQswCQYDVQQGEwJT
+RTAeFw0yMDA1MDMwMDI0MzdaFw00NzA5MTgwMDI0MzdaMA0xCzAJBgNVBAYTAlNF
+MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEApsGQcCv+Ce/+AbHx+3Wu
+ujGtWF7uLX+/MahOHPfdXqidwG7OpmYnGkL06cA52P0BcZdc1hPGQbQdFJC8aW6U
+5X9owRz9IRiwpzRhRqmMJfeqrLaqLL9K5MpCv+qsDzXu9ngRLJDk5CyeEfTjosEr
+GWDywWahQKHChamdH701djFGwWGP3gttGvQoMnaSpzeyDKitBZql6bSxKkhWgFop
+yxfU7qjbzOASLWaMx2r+MIJ88+AYDqYBTj649N534AYrIdjlQnvEKzGH0sOgHFYO
+oaTTvmE/vRPlmbSX1U7mo/SvMWNPZkKUPDltyapOpBltfMiRJH4ndLOXJWRgmYha
+SQIDAQABMA0GCSqGSIb3DQEBCwUAA4IBAQAdAwQpntpgUWUxCTk/Pw2+w5v+VxMM
+K6QWhm9JdRn3XKQnKrFexVRso/x8TA8V50EUGwQwbnKApNXvJsV2jvbP/YwDsG2u
+jBxs0DSspjDvbhUTkuWNYufQZIUGYMyccHap+CKD4rD2loMkmwbh5rII3SGEzUFE
+rOY4VhqDj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L_PORT}
+ - ${MR_EXTERNAL_SECURE_PORT}:${MR_INTERNAL_SECURE_PORT}
+ volumes:
+ - ${MR_CERT_MOUNT_DIR}:/usr/src/app/cert:ro
--- /dev/null
+.tmp.json
+.dockererr
\ No newline at end of file
image: ${POLICY_AGENT_IMAGE}
container_name: ${POLICY_AGENT_APP_NAME}
networks:
- - default
+ default:
+ aliases:
+ - ${POLICY_AGENT_APP_NAME_ALIAS}
ports:
- ${POLICY_AGENT_EXTERNAL_PORT}:${POLICY_AGENT_INTERNAL_PORT}
+ - ${POLICY_AGENT_EXTERNAL_SECURE_PORT}:${POLICY_AGENT_INTERNAL_SECURE_PORT}
environment:
- CONSUL_HOST=${CONSUL_HOST}
- CONSUL_PORT=${CONSUL_INTERNAL_PORT}
-.env
\ No newline at end of file
+.tmp.json
+.dockererr
+.env
+fakedir
\ No newline at end of file
--- /dev/null
+-----BEGIN CERTIFICATE-----
+MIICljCCAX4CCQDVlvlNzxH9FzANBgkqhkiG9w0BAQsFADANMQswCQYDVQQGEwJT
+RTAeFw0yMDA0MjgxOTE2MTNaFw00NzA5MTMxOTE2MTNaMA0xCzAJBgNVBAYTAlNF
+MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqpnXP5VmOvMPOTWaxWvm
+zfSBRvnioEFHoriGld+pW+vvvrma9UiWfxX3GaGFItxuwbwLwqwvR2LDo6wQQpbl
+SaNhg89DYD/NZvlRlLNcYOL218LjfFf4xaKVQGBHfT0Ts9JGTbTD/zcR2VS+3DUR
+lvLzbNpQ+Rdvwls7wsL1ZblR+1lry9HMGKCrtsYDSOMSyGqE40u1bOYAw1+VMrfp
+cK14u9toNPIbvk+HDP5yYnjC4FEp0ai07s3T6YDWHvp0WNIFJHCVFYzYQgS79/2b
+8zg4H7ZMQ5XjxcenU6f8Q97nN0VMk46LIutGe/7rYO0uYKrHcJz1qUu1ui96zOVC
+DQIDAQABMA0GCSqGSIb3DQEBCwUAA4IBAQBGvmFRHuUESp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yC4GzTScWXad5/FEeo189JU1aGcJn7Gn7Ao805
+wuOOs1TQk+KHvAFDEGkkJEM0lg==
+-----END ENCRYPTED PRIVATE KEY-----
networks:
- default
ports:
- - ${RIC_SIM_INTERNAL_PORT}/tcp
+ - ${RIC_SIM_PORT}/tcp
environment:
- A1_VERSION=${G1_A1_VERSION}
+ - REMOTE_HOSTS_LOGGING=1
+ volumes:
+ - ${RIC_SIM_CERT_MOUNT_DIR}:/usr/src/app/cert:ro
g2:
image: ${RIC_SIM_IMAGE}
networks:
- default
ports:
- - ${RIC_SIM_INTERNAL_PORT}/tcp
+ - ${RIC_SIM_PORT}/tcp
environment:
- A1_VERSION=${G2_A1_VERSION}
+ - REMOTE_HOSTS_LOGGING=1
+ volumes:
+ - ${RIC_SIM_CERT_MOUNT_DIR}:/usr/src/app/cert:ro
g3:
image: ${RIC_SIM_IMAGE}
networks:
- default
ports:
- - ${RIC_SIM_INTERNAL_PORT}/tcp
+ - ${RIC_SIM_PORT}/tcp
environment:
- - A1_VERSION=${G3_A1_VERSION}
\ No newline at end of file
+ - A1_VERSION=${G3_A1_VERSION}
+ - REMOTE_HOSTS_LOGGING=1
+ volumes:
+ - ${RIC_SIM_CERT_MOUNT_DIR}:/usr/src/app/cert:ro
\ No newline at end of file
--- /dev/null
+.tmp.json
+.dockererr
\ No newline at end of file
--- /dev/null
+# ==================================================================================
+# Modifications Copyright (c) 2019 Nordix Foundation.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ==================================================================================
+version: '2.1'
+
+networks:
+ default:
+ driver: bridge
+ name: ${DOCKER_SIM_NWNAME}
+
+services:
+ db:
+ image: ${SDNC_ONAP_DB_IMAGE}
+ container_name: ${SDNC_ONAP_DB_APP_NAME}
+ networks:
+ - default
+ ports:
+ - "3306"
+ environment:
+ - MYSQL_ROOT_PASSWORD=openECOMP1.0
+ - MYSQL_ROOT_HOST=%
+ logging:
+ driver: "json-file"
+ options:
+ max-size: "30m"
+ max-file: "5"
+
+ a1-controller:
+ image: ${SDNC_ONAP_A1_ADAPTER_IMAGE}
+ depends_on :
+ - db
+ container_name: ${SDNC_ONAP_APP_NAME}
+ networks:
+ - default
+ entrypoint: ["/opt/onap/sdnc/bin/startODL.sh"]
+ ports:
+ - ${SDNC_ONAP_EXTERNAL_PORT}:${SDNC_ONAP_INTERNAL_PORT}
+ links:
+ - db:dbhost
+ - db:sdnctldb01
+ - db:sdnctldb02
+ environment:
+ - MYSQL_ROOT_PASSWORD=openECOMP1.0
+ - SDNC_CONFIG_DIR=/opt/onap/sdnc/data/properties
+ dns:
+ - ${DNS_IP_ADDR-10.0.100.1}
+ logging:
+ driver: "json-file"
+ options:
+ max-size: "30m"
+ max-file: "5"
+ extra_hosts:
+ aaf.osaaf.org: 10.12.6.214
// Presents a web page on localhost:9999/mon
var LOCALHOST="http://127.0.0.1:"
+var LOCALHOSTSECURE="https://127.0.0.1:"
+//This var may switch between LOCALHOST and LOCALHOSTSECURE
+var SIM_LOCALHOST=LOCALHOST
var MRSTUB_PORT="3905"
var AGENT_PORT="8081"
var CR_PORT="8090"
var http = require('http');
+var https = require('https');
var express = require('express');
var app = express();
})
//Get parameter valuue from other server
-function getSimCtr(url, index, cb) {
+function getSimCtr(httpx, url, index, cb) {
var data = '';
- http.get(url, (resp) => {
- // A chunk of data has been recieved.
- resp.on('data', (chunk) => {
- data += chunk;
- });
-
- // The whole response has been received.
- resp.on('end', () => {
- var code=resp.statusCode
- if (code > 199 && code < 300) {
- cb(data, index);
- } else {
- cb("not found", index);
- }
- });
+ var http_type=http
+ if (httpx=="https") {
+ http_type=https
+ }
+ console.log("URL: "+ url + " - " + httpx)
+ try {
+ http_type.get(url, (resp) => {
+ // A chunk of data has been recieved.
+ resp.on('data', (chunk) => {
+ data += chunk;
+ });
+
+ // The whole response has been received.
+ resp.on('end', () => {
+ var code=resp.statusCode
+ if (code > 199 && code < 300) {
+ cb(data, index);
+ } else {
+ cb("not found", index);
+ }
+ });
- }).on("error", (err) => {
- console.log("Error: " + err.message);
- cb("no response", index);
- });
+ }).on("error", (err) => {
+ console.log("Error: " + err.message);
+ cb("no response", index);
+ });
+ } catch(err) {
+ cb("no response", index);
+ }
};
var simvar2=[]
var simvar3=[]
var simvar4=[]
+var simvar5=[]
//Counts the number of get request for the html page
var getCtr=0
-var refreshInterval=2000
+var refreshInterval=4000
+
+//Ignore self signed cert
+process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = 0;
+
+var sim_http_type="http"
function fetchAllMetrics() {
setTimeout(() => {
//Get metric values from the simulators
for(var index=0;index<simnames.length;index++) {
- getSimCtr(LOCALHOST+simports[index]+"/counter/num_instances", index, function(data, index) {
+ try {
+ if (index == 0) {
+ // Check is simulator are running on http or https - no response assumes http
+ getSimCtr("https",LOCALHOSTSECURE+simports[index]+"/", index, function(data, index) {
+ if (data=="OK") {
+ console.log("Found https simulator - assuming all simulators using https" )
+ sim_http_type="https"
+ SIM_LOCALHOST=LOCALHOSTSECURE
+ } else {
+ console.log("No https simulator found - assuming all simulators using http" )
+ sim_http_type="http"
+ SIM_LOCALHOST=LOCALHOST
+ }
+ });
+
+ }
+ } catch(err) {
+ console.log("No https simulator found - assuming all simulators using http" )
+ sim_http_type="http"
+ SIM_LOCALHOST=LOCALHOST
+ }
+ getSimCtr(sim_http_type, SIM_LOCALHOST+simports[index]+"/counter/num_instances", index, function(data, index) {
simvar1[index] = data;
});
- getSimCtr(LOCALHOST+simports[index]+"/counter/num_types", index, function(data,index) {
+ getSimCtr(sim_http_type, SIM_LOCALHOST+simports[index]+"/counter/num_types", index, function(data,index) {
simvar2[index] = data;
});
- getSimCtr(LOCALHOST+simports[index]+"/policytypes", index, function(data,index) {
+ getSimCtr(sim_http_type, SIM_LOCALHOST+simports[index]+"/policytypes", index, function(data,index) {
data=data.replace(/\[/g,'');
data=data.replace(/\]/g,'');
data=data.replace(/ /g,'');
data=data.replace(/\"/g,'');
simvar3[index] = data;
});
- getSimCtr(LOCALHOST+simports[index]+"/counter/interface", index, function(data,index) {
+ getSimCtr(sim_http_type, SIM_LOCALHOST+simports[index]+"/counter/interface", index, function(data,index) {
simvar4[index] = data;
});
+ getSimCtr(sim_http_type, SIM_LOCALHOST+simports[index]+"/counter/remote_hosts", index, function(data,index) {
+ simvar5[index] = data;
+ });
}
//MR - get metrics values from the MR stub
- getSimCtr(LOCALHOST+MRSTUB_PORT+"/counter/requests_submitted", 0, function(data, index) {
+ getSimCtr("http", LOCALHOST+MRSTUB_PORT+"/counter/requests_submitted", 0, function(data, index) {
mr1 = data;
});
- getSimCtr(LOCALHOST+MRSTUB_PORT+"/counter/requests_fetched", 0, function(data, index) {
+ getSimCtr("http", LOCALHOST+MRSTUB_PORT+"/counter/requests_fetched", 0, function(data, index) {
mr2 = data;
});
- getSimCtr(LOCALHOST+MRSTUB_PORT+"/counter/current_requests", 0, function(data, index) {
+ getSimCtr("http", LOCALHOST+MRSTUB_PORT+"/counter/current_requests", 0, function(data, index) {
mr3 = data;
});
- getSimCtr(LOCALHOST+MRSTUB_PORT+"/counter/responses_submitted", 0, function(data, index) {
+ getSimCtr("http", LOCALHOST+MRSTUB_PORT+"/counter/responses_submitted", 0, function(data, index) {
mr4 = data;
});
- getSimCtr(LOCALHOST+MRSTUB_PORT+"/counter/responses_fetched", 0, function(data, index) {
+ getSimCtr("http", LOCALHOST+MRSTUB_PORT+"/counter/responses_fetched", 0, function(data, index) {
mr5 = data;
});
- getSimCtr(LOCALHOST+MRSTUB_PORT+"/counter/current_responses", 0, function(data, index) {
+ getSimCtr("http", LOCALHOST+MRSTUB_PORT+"/counter/current_responses", 0, function(data, index) {
mr6 = data;
});
//CR - get metrics values from the callbackreceiver
- getSimCtr(LOCALHOST+CR_PORT+"/counter/received_callbacks", 0, function(data, index) {
+ getSimCtr("http", LOCALHOST+CR_PORT+"/counter/received_callbacks", 0, function(data, index) {
cr1 = data;
});
- getSimCtr(LOCALHOST+CR_PORT+"/counter/fetched_callbacks", 0, function(data, index) {
+ getSimCtr("http", LOCALHOST+CR_PORT+"/counter/fetched_callbacks", 0, function(data, index) {
cr2 = data;
});
- getSimCtr(LOCALHOST+CR_PORT+"/counter/current_messages", 0, function(data, index) {
+ getSimCtr("http", LOCALHOST+CR_PORT+"/counter/current_messages", 0, function(data, index) {
cr3 = data;
});
//Agent - get metrics from the agent
- getSimCtr(LOCALHOST+AGENT_PORT+"/status", 0, function(data, index) {
+ getSimCtr("http", LOCALHOST+AGENT_PORT+"/status", 0, function(data, index) {
ag1 = data;
});
- getSimCtr(LOCALHOST+AGENT_PORT+"/services", 0, function(data, index) {
+ getSimCtr("http", LOCALHOST+AGENT_PORT+"/services", 0, function(data, index) {
ag2="";
try {
var jd=JSON.parse(data);
ag2=data
}
});
- getSimCtr(LOCALHOST+AGENT_PORT+"/policy_types", 0, function(data, index) {
+ getSimCtr("http", LOCALHOST+AGENT_PORT+"/policy_types", 0, function(data, index) {
ag3="";
try {
var jd=JSON.parse(data);
ag3=""
}
});
- getSimCtr(LOCALHOST+AGENT_PORT+"/policy_ids", 0, function(data, index) {
+ getSimCtr("http", LOCALHOST+AGENT_PORT+"/policy_ids", 0, function(data, index) {
ag4=""
try {
var jd=JSON.parse(data);
htmlStr=htmlStr+padding("Near-RT RIC Simulator name", 35," ")
htmlStr=htmlStr+padding("Types", 10," ")
- htmlStr=htmlStr+padding("Instances", 10," ")
- htmlStr=htmlStr+"<br>"+padding("",55,"=")+"<br>"
-
+ htmlStr=htmlStr+padding("Instances", 10," ")+"<br>"
+ htmlStr=htmlStr+padding("",55,"=")+"<br>"
for(var simIndex=0;simIndex<simnames.length;simIndex++) {
htmlStr=htmlStr+padding(simnames[simIndex]+ " ("+simports[simIndex]+")",35," ");
htmlStr=htmlStr+padding(simvar2[simIndex],10," ")
htmlStr=htmlStr+"<br>";
}
+ htmlStr=htmlStr+"<br>";
+ htmlStr=htmlStr+padding("Near-RT RIC Simulator name", 35," ")
+ htmlStr=htmlStr+padding("Remote hosts", 50," ")+"<br>"
+ htmlStr=htmlStr+padding("",90,"=")+"<br>"
+ for(simIndex=0;simIndex<simnames.length;simIndex++) {
+ htmlStr=htmlStr+padding(simnames[simIndex]+ " ("+simports[simIndex]+")",35," ");
+ htmlStr=htmlStr+padding(simvar5[simIndex],50," ")
+ htmlStr=htmlStr+"<br>";
+ }
+
htmlStr=htmlStr+
"</body>" +
"</html>";