-# Function to start a container and wait until it responds on the given port and url.
-#args: <docker-compose-dir> NODOCKERARGS|<docker-compose-arg> <app-name> <port-number> <alive-url> [<app-name> <port-number> <alive-url>]*
-__start_container() {
-
- variableArgCount=$(($#-2))
- if [ $# -lt 6 ] && [ [ $(($variableArgCount%4)) -ne 0 ]; then
- ((RES_CONF_FAIL++))
- __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
-
- __create_docker_network
-
- curdir=$PWD
- cd $SIM_GROUP
- cd $1
-
- if [ "$2" == "NODOCKERARGS" ]; then
- docker-compose up -d &> .dockererr
- if [ $? -ne 0 ]; then
- echo -e $RED"Problem to launch container(s) with docker-compose"$ERED
- cat .dockererr
- echo -e $RED"Stopping script...."$ERED
- exit 1
- fi
- elif [ "$2" == "STANDALONE" ]; then
- echo "Skipping docker-compose"
- else
- docker-compose up -d $2 &> .dockererr
- if [ $? -ne 0 ]; then
- echo -e $RED"Problem to launch container(s) with docker-compose"$ERED
- cat .dockererr
- echo -e $RED"Stopping script...."$ERED
- exit 1
- fi
- fi
- app_prefix=""
- if [ "$2" == "STANDALONE" ]; then
- app_prefix="STANDALONE_"
- fi
- shift; shift;
- cntr=0
- while [ $cntr -lt $variableArgCount ]; do
- app=$app_prefix$1; shift;
- port=$1; shift;
- url=$1; shift;
- httpx=$1; shift;
- let cntr=cntr+4
-
- __check_container_start "$app" "$port" "$url" $httpx
- done
-
- cd $curdir
- echo ""
- return 0
-}
-
-# Generate a UUID to use as prefix for policy ids
-generate_uuid() {
- UUID=$(python3 -c 'import sys,uuid; sys.stdout.write(uuid.uuid4().hex)')
- #Reduce length to make space for serial id, us 'a' as marker where the serial id is added
- UUID=${UUID:0:${#UUID}-4}"a"
-}
-
-####################
-### Consul functions
-####################
-
-# Function to load config from a file into consul for the Policy Agent
-# arg: <json-config-file>
-# (Function for test scripts)
-consul_config_app() {
-
- echo -e $BOLD"Configuring Consul"$EBOLD
-
- if [ $# -ne 1 ]; then
- ((RES_CONF_FAIL++))
- __print_err "need one arg, <json-config-file>" $@
- exit 1
- fi
-
- echo " Loading config for "$POLICY_AGENT_APP_NAME" from "$1
-
- curlString="$LOCALHOST${CONSUL_EXTERNAL_PORT}/v1/kv/${POLICY_AGENT_APP_NAME}?dc=dc1 -X PUT -H Accept:application/json -H Content-Type:application/json -H X-Requested-With:XMLHttpRequest --data-binary @"$1
- result=$(__do_curl "$curlString")
- if [ $? -ne 0 ]; then
- echo -e $RED" FAIL - json config could not be loaded to consul" $ERED
- ((RES_CONF_FAIL++))
- return 1
- fi
- body="$(__do_curl $LOCALHOST$CBS_EXTERNAL_PORT/service_component_all/$POLICY_AGENT_APP_NAME)"
- echo $body > "./tmp/.output"$1
-
- if [ $? -ne 0 ]; then
- echo -e $RED" FAIL - json config could not be loaded from consul/cbs, contents cannot be checked." $ERED
- ((RES_CONF_FAIL++))
- return 1
- else
- targetJson=$(< $1)
- targetJson="{\"config\":"$targetJson"}"
- echo "TARGET JSON: $targetJson" >> $HTTPLOG
- 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++))
- return 1
- else
- echo -e $GREEN" Config loaded ok to consul"$EGREEN
- fi
- fi
-
- echo ""
-
-}
-
-# Function to perpare the consul configuration according to the current simulator configuration
-# args: SDNC|NOSDNC <output-file>
-# (Function for test scripts)
-prepare_consul_config() {
- echo -e $BOLD"Prepare Consul config"$EBOLD
-
- echo " Writing consul config for "$POLICY_AGENT_APP_NAME" to file: "$2
-
- if [ $# != 2 ]; then
- ((RES_CONF_FAIL++))
- __print_err "need two args, SDNC|NOSDNC <output-file>" $@
- exit 1
- fi
-
- if [ $1 == "SDNC" ]; then
- echo -e " Config$BOLD including SDNC$EBOLD configuration"
- elif [ $1 == "NOSDNC" ]; then
- echo -e " Config$BOLD excluding SDNC$EBOLD configuration"
- else
- ((RES_CONF_FAIL++))
- __print_err "need two args, SDNC|NOSDNC <output-file>" $@
- exit 1
- fi
-
- config_json="\n {"
- if [ $1 == "SDNC" ]; then
- config_json=$config_json"\n \"controller\": ["
- config_json=$config_json"\n {"
- config_json=$config_json"\n \"name\": \"$SDNC_APP_NAME\","
- if [ $AGENT_STAND_ALONE -eq 0 ]; then
- config_json=$config_json"\n \"baseUrl\": \"$SDNC_HTTPX://$SDNC_APP_NAME:$SDNC_PORT\","
- else
- config_json=$config_json"\n \"baseUrl\": \"$SDNC_HTTPX://localhost:$SDNC_LOCAL_PORT\","
- fi
- config_json=$config_json"\n \"userName\": \"$SDNC_USER\","
- config_json=$config_json"\n \"password\": \"$SDNC_PWD\""
- config_json=$config_json"\n }"
- config_json=$config_json"\n ],"
- fi
-
- config_json=$config_json"\n \"streams_publishes\": {"
- config_json=$config_json"\n \"dmaap_publisher\": {"
- config_json=$config_json"\n \"type\": \"$MR_APP_NAME\","
- config_json=$config_json"\n \"dmaap_info\": {"
- if [ $AGENT_STAND_ALONE -eq 0 ]; then
- config_json=$config_json"\n \"topic_url\": \"$MR_HTTPX://$MR_APP_NAME:$MR_PORT$MR_WRITE_URL\""
- else
- config_json=$config_json"\n \"topic_url\": \"$MR_HTTPX://localhost:$MR_LOCAL_PORT$MR_WRITE_URL\""
- fi
- config_json=$config_json"\n }"
- config_json=$config_json"\n }"
- config_json=$config_json"\n },"
- config_json=$config_json"\n \"streams_subscribes\": {"
- config_json=$config_json"\n \"dmaap_subscriber\": {"
- config_json=$config_json"\n \"type\": \"$MR_APP_NAME\","
- config_json=$config_json"\n \"dmaap_info\": {"
- if [ $AGENT_STAND_ALONE -eq 0 ]; then
- config_json=$config_json"\n \"topic_url\": \"$MR_HTTPX://$MR_APP_NAME:$MR_PORT$MR_READ_URL\""
- else
- config_json=$config_json"\n \"topic_url\": \"$MR_HTTPX://localhost:$MR_LOCAL_PORT$MR_READ_URL\""
- fi
- config_json=$config_json"\n }"
- config_json=$config_json"\n }"
- config_json=$config_json"\n },"
-
- config_json=$config_json"\n \"ric\": ["
-
- rics=$(docker ps | grep $RIC_SIM_PREFIX | awk '{print $NF}')
-
- if [ $? -ne 0 ] || [ -z "$rics" ]; then
- echo -e $RED" FAIL - the names of the running RIC Simulator cannot be retrieved." $ERED
- ((RES_CONF_FAIL++))
- return 1
- fi
-
- cntr=0
- for ric in $rics; do
- if [ $cntr -gt 0 ]; then
- config_json=$config_json"\n ,"
- fi
- config_json=$config_json"\n {"
- config_json=$config_json"\n \"name\": \"$ric\","
- if [ $AGENT_STAND_ALONE -eq 0 ]; then
- config_json=$config_json"\n \"baseUrl\": \"$RIC_SIM_HTTPX://$ric:$RIC_SIM_PORT\","
- else
- config_json=$config_json"\n \"baseUrl\": \"$RIC_SIM_HTTPX://localhost:$(__find_sim_port $ric)\","
- fi
- if [ $1 == "SDNC" ]; then
- config_json=$config_json"\n \"controller\": \"$SDNC_APP_NAME\","
- fi
- config_json=$config_json"\n \"managedElementIds\": ["
- config_json=$config_json"\n \"me1_$ric\","
- config_json=$config_json"\n \"me2_$ric\""
- config_json=$config_json"\n ]"
- config_json=$config_json"\n }"
- let cntr=cntr+1
- done
-
- config_json=$config_json"\n ]"
- config_json=$config_json"\n}"
-
-
- printf "$config_json">$2
-
- echo ""
-}
-
-
-# Start Consul and CBS
-# args: -
-# (Function for test scripts)
-start_consul_cbs() {
-
- echo -e $BOLD"Starting Consul and CBS"$EBOLD
- __check_included_image 'CONSUL'
- if [ $? -eq 1 ]; then
- echo -e $RED"The Consul image has not been checked for this test run due to arg to the test script"$ERED
- echo -e $RED"Consul will not be started"$ERED
- exit
- fi
- __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 $BOLD"RICSIM protocol setting"$EBOLD
- echo -e " Using $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
- echo ""
-}
-
-use_simulator_https() {
- echo -e $BOLD"RICSIM protocol setting"$EBOLD
- echo -e " Using $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
- echo ""
-}
-
-# Start one group (ricsim_g1, ricsim_g2 .. ricsim_g5) with a number of RIC Simulators using a given A interface
-# 'ricsim' may be set on command line to other prefix
-# args: ricsim_g1|ricsim_g2|ricsim_g3|ricsim_g4|ricsim_g5 <count> <interface-id>
-# (Function for test scripts)
-start_ric_simulators() {
-
- echo -e $BOLD"Starting RIC Simulators"$EBOLD
-
- __check_included_image 'RICSIM'
- if [ $? -eq 1 ]; then
- echo -e $RED"The Near-RT RIC Simulator image has not been checked for this test run due to arg to the test script"$ERED
- echo -e $RED"The Near-RT RIC Simulartor(s) will not be started"$ERED
- exit
- fi
-
- RIC1=$RIC_SIM_PREFIX"_g1"
- RIC2=$RIC_SIM_PREFIX"_g2"
- RIC3=$RIC_SIM_PREFIX"_g3"
- RIC4=$RIC_SIM_PREFIX"_g4"
- RIC5=$RIC_SIM_PREFIX"_g5"
-
- if [ $# != 3 ]; then
- ((RES_CONF_FAIL++))
- __print_err "need three args, $RIC1|$RIC2|$RIC3|$RIC4|$RIC5 <count> <interface-id>" $@
- exit 1
- fi
- echo " $2 simulators using basename: $1 on interface: $3"
- #Set env var for simulator count and A1 interface vesion for the given group
- if [ $1 == "$RIC1" ]; then
- G1_COUNT=$2
- G1_A1_VERSION=$3
- elif [ $1 == "$RIC2" ]; then
- G2_COUNT=$2
- G2_A1_VERSION=$3
- elif [ $1 == "$RIC3" ]; then
- G3_COUNT=$2
- G3_A1_VERSION=$3
- elif [ $1 == "$RIC4" ]; then
- G4_COUNT=$2
- G4_A1_VERSION=$3
- elif [ $1 == "$RIC5" ]; then
- G5_COUNT=$2
- G5_A1_VERSION=$3
- else
- ((RES_CONF_FAIL++))
- __print_err "need three args, $RIC1|$RIC2|$RIC3|$RIC4|$RIC5 <count> <interface-id>" $@
- exit 1
- fi
-
- # Create .env file to compose project, all ric container will get this prefix
- echo "COMPOSE_PROJECT_NAME="$RIC_SIM_PREFIX > $SIM_GROUP/ric/.env
-
- export G1_A1_VERSION
- export G2_A1_VERSION
- export G3_A1_VERSION
- export G4_A1_VERSION
- export G5_A1_VERSION
-
- docker_args="--scale g1=$G1_COUNT --scale g2=$G2_COUNT --scale g3=$G3_COUNT --scale g4=$G4_COUNT --scale g5=$G5_COUNT"
- app_data=""
- cntr=1
- while [ $cntr -le $2 ]; do
- app=$1"_"$cntr
- port=0
- app_data="$app_data $app $port / "$RIC_SIM_HTTPX
- let cntr=cntr+1
- done
- __start_container ric "$docker_args" $app_data
-
-}
-
-###########################
-### Control Panel functions
-###########################
-
-# Start the Control Panel container
-# args: -
-# (Function for test scripts)
-start_control_panel() {
-
- echo -e $BOLD"Starting Control Panel"$EBOLD
- __check_included_image 'CP'
- if [ $? -eq 1 ]; then
- echo -e $RED"The Control Panel image has not been checked for this test run due to arg to the test script"$ERED
- echo -e $RED"The Control Panel will not be started"$ERED
- exit
- fi
- __start_container control_panel NODOCKERARGS $CONTROL_PANEL_APP_NAME $CONTROL_PANEL_EXTERNAL_PORT "/" "http"
-
-}
-
-###########################
-### RAPP Catalogue
-###########################
-
-# Start the RAPP Catalogue container
-# args: -
-# (Function for test scripts)
-start_rapp_catalogue() {
-
- echo -e $BOLD"Starting RAPP Catalogue"$EBOLD
-
- __check_included_image 'RC'
- if [ $? -eq 1 ]; then
- echo -e $RED"The RAPP Catalogue image has not been checked for this test run due to arg to the test script"$ERED
- echo -e $RED"The RAPP Catalogue will not be started"$ERED
- exit
- fi
- __start_container rapp_catalogue NODOCKERARGS $RAPP_CAT_APP_NAME $RAPP_CAT_EXTERNAL_PORT "/services" "http"
-}
-
-use_rapp_catalogue_http() {
- echo -e $BOLD"RAPP Catalogue protocol setting"$EBOLD
- echo -e " Using $BOLD http $EBOLD towards the RAPP Catalogue"
- export RAPP_CAT_HTTPX="http"
- export RAPP_CAT_PORT=$RAPP_CAT_INTERNAL_PORT
- export RAPP_CAT_LOCAL_PORT=$RAPP_CAT_EXTERNAL_PORT
- echo ""
-}
-
-use_rapp_catalogue_https() {
- echo -e $BOLD"RAPP Catalogue protocol setting"$EBOLD
- echo -e " Using $BOLD https $EBOLD towards the RAPP Catalogue"
- export RAPP_CAT_HTTPX="https"
- export RAPP_CAT_PORT=$RAPP_CAT_INTERNAL_PORT
- export RAPP_CAT_LOCAL_PORT=$RAPP_CAT_EXTERNAL_PORT
- echo ""
-}
-
-##################
-### SDNC functions
-##################
-
-# Start the SDNC A1 Controller
-# args: -
-# (Function for test scripts)
-start_sdnc() {
-
- echo -e $BOLD"Starting SDNC A1 Controller"$EBOLD
-
- __check_included_image 'SDNC'
- if [ $? -eq 1 ]; then
- echo -e $RED"The image for SDNC and the related DB has not been checked for this test run due to arg to the test script"$ERED
- echo -e $RED"SDNC will not be started"$ERED
- exit
- fi
-
- __start_container sdnc NODOCKERARGS $SDNC_APP_NAME $SDNC_EXTERNAL_PORT $SDNC_ALIVE_URL "http"
-
-}
-
-use_sdnc_http() {
- echo -e $BOLD"SDNC protocol setting"$EBOLD
- echo -e " Using $BOLD http $EBOLD towards SDNC"
- export SDNC_HTTPX="http"
- export SDNC_PORT=$SDNC_INTERNAL_PORT
- export SDNC_LOCAL_PORT=$SDNC_EXTERNAL_PORT
- echo ""
-}
-
-use_sdnc_https() {
- echo -e $BOLD"SDNC protocol setting"$EBOLD
- echo -e " Using $BOLD https $EBOLD towards SDNC"
- export SDNC_HTTPX="https"
- export SDNC_PORT=$SDNC_INTERNAL_SECURE_PORT
- export SDNC_LOCAL_PORT=$SDNC_EXTERNAL_SECURE_PORT
- echo ""
-}
-
-#####################
-### MR stub functions
-#####################
-
-# Start the Message Router stub interface in the simulator group
-# args: -
-# (Function for test scripts)
-start_mr() {
-
- echo -e $BOLD"Starting Message Router 'mrstub'"$EBOLD
- __check_included_image 'MR'
- if [ $? -eq 1 ]; then
- echo -e $RED"The Message Router image has not been checked for this test run due to arg to the test script"$ERED
- echo -e $RED"The Message Router will not be started"$ERED
- exit
- fi
- export MR_CERT_MOUNT_DIR="./cert"
- __start_container mr NODOCKERARGS $MR_APP_NAME $MR_EXTERNAL_PORT "/" "http"
-}
-
-use_mr_http() {
- echo -e $BOLD"MR protocol setting"$EBOLD
- echo -e " Using $BOLD http $EBOLD towards MR"
- export MR_HTTPX="http"
- export MR_PORT=$MR_INTERNAL_PORT
- export MR_LOCAL_PORT=$MR_EXTERNAL_PORT
- echo ""
-}
-
-use_mr_https() {
- echo -e $BOLD"MR protocol setting"$EBOLD
- echo -e " Using $BOLD https $EBOLD towards MR"
- export MR_HTTPX="https"
- export MR_PORT=$MR_INTERNAL_SECURE_PORT
- export MR_LOCAL_PORT=$MR_EXTERNAL_SECURE_PORT
- echo ""
-}
-
-
-################
-### CR functions
-################
-
-# Start the Callback reciver in the simulator group
-# args: -
-# (Function for test scripts)
-start_cr() {
-
- echo -e $BOLD"Starting Callback Receiver"$EBOLD
- __check_included_image 'CR'
- if [ $? -eq 1 ]; then
- echo -e $RED"The Callback Receiver image has not been checked for this test run due to arg to the test script"$ERED
- echo -e $RED"The Callback Receiver will not be started"$ERED
- exit
- fi
- __start_container cr NODOCKERARGS $CR_APP_NAME $CR_EXTERNAL_PORT "/" "http"
-
-}
-
-use_cr_http() {
- echo -e $BOLD"CR protocol setting"$EBOLD
- echo -e " Using $BOLD http $EBOLD towards CR"
- export CR_HTTPX="http"
- export CR_PORT=$CR_INTERNAL_PORT
- export CR_LOCAL_PORT=$CR_EXTERNAL_PORT
- export CR_PATH="$CR_HTTPX://$CR_APP_NAME:$CR_PORT$CR_APP_CALLBACK"
- echo ""
-}
-
-use_cr_https() {
- echo -e $BOLD"CR protocol setting"$EBOLD
- echo -e " Using $BOLD https $EBOLD towards CR"
- export CR_HTTPX="https"
- export CR_PORT=$CR_INTERNAL_SECURE_PORT
- export CR_LOCAL_PORT=$CR_EXTERNAL_SECURE_PORT
- export CR_PATH="$CR_HTTPX://$CR_APP_NAME:$CR_PORT$CR_APP_CALLBACK"
- echo ""
-}
-
-###########################
-### Producer stub functions
-###########################
-
-# Start the Producer stub in the simulator group
-# args: -
-# (Function for test scripts)
-start_prod_stub() {
-
- echo -e $BOLD"Starting Producer stub"$EBOLD
- __check_included_image 'PRODSTUB'
- if [ $? -eq 1 ]; then
- echo -e $RED"The Producer stub image has not been checked for this test run due to arg to the test script"$ERED
- echo -e $RED"The Producer stub will not be started"$ERED
- exit
- fi
- __start_container prodstub NODOCKERARGS $PROD_STUB_APP_NAME $PROD_STUB_EXTERNAL_PORT "/" "http"
-
-}
-
-use_prod_stub_http() {
- echo -e $BOLD"Producer stub protocol setting"$EBOLD
- echo -e " Using $BOLD http $EBOLD towards Producer stub"
- export PROD_STUB_HTTPX="http"
- export PROD_STUB_PORT=$PROD_STUB_INTERNAL_PORT
- export PROD_STUB_LOCAL_PORT=$PROD_STUB_EXTERNAL_PORT
- export PROD_STUB_LOCALHOST=$PROD_STUB_HTTPX"://localhost:"$PROD_STUB_LOCAL_PORT
- echo ""
-}
-
-use_prod_stub_https() {
- echo -e $BOLD"Producer stub protocol setting"$EBOLD
- echo -e " Using $BOLD https $EBOLD towards Producer stub"
- export PROD_STUB_HTTPX="https"
- export PROD_STUB_PORT=$PROD_STUB_INTERNAL_SECURE_PORT
- export PROD_STUB_LOCAL_PORT=$PROD_STUB_EXTERNAL_SECURE_PORT
- export PROD_STUB_LOCALHOST=$PROD_STUB_HTTPX"://localhost:"$PROD_STUB_LOCAL_PORT
- echo ""
-}
-
-###########################
-### Policy Agents functions
-###########################
-
-# Use an agent on the local machine instead of container
-use_agent_stand_alone() {
- AGENT_STAND_ALONE=1
-}
-
-# Start the policy agent
-# args: -
-# (Function for test scripts)
-start_policy_agent() {
-
- echo -e $BOLD"Starting Policy Agent"$EBOLD
-
- if [ $AGENT_STAND_ALONE -eq 0 ]; then
- __check_included_image 'PA'
- if [ $? -eq 1 ]; then
- echo -e $RED"The Policy Agent image has not been checked for this test run due to arg to the test script"$ERED
- echo -e $RED"The Policy Agent will not be started"$ERED
- exit
- fi
- __start_container policy_agent NODOCKERARGS $POLICY_AGENT_APP_NAME $POLICY_AGENT_EXTERNAL_PORT "/status" "http"
- else
- echo -e $RED"The consul config produced by this test script (filename '<fullpath-to-autotest-dir>.output<file-name>"$ERED
- echo -e $RED"where the file name is the file in the consul_config_app command in this script) must be pointed out by the agent "$ERED
- echo -e $RED"application.yaml"$ERED
- echo -e $RED"The application jar may need to be built before continuing"$ERED
- echo -e $RED"The agent shall now be running on port $POLICY_AGENT_EXTERNAL_PORT for http"$ERED
-
- read -p "<press any key to continue>"
- __start_container policy_agent "STANDALONE" $POLICY_AGENT_APP_NAME $POLICY_AGENT_EXTERNAL_PORT "/status" "http"
- fi
-
-}
-
-# All calls to the agent will be directed to the agent REST interface from now on
-# args: -
-# (Function for test scripts)
-use_agent_rest_http() {
- echo -e $BOLD"Agent protocol setting"$EBOLD
- echo -e " Using $BOLD http $EBOLD and $BOLD REST $EBOLD towards the agent"
- 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"Agent protocol setting"$EBOLD
- echo -e " Using $BOLD https $EBOLD and $BOLD REST $EBOLD towards the agent"
- export ADAPTER=$RESTBASE_SECURE
- echo ""
- return 0
-}
-
-# All calls to the agent will be directed to the agent dmaap interface over http from now on
-# args: -
-# (Function for test scripts)
-use_agent_dmaap_http() {
- echo -e $BOLD"Agent dmaap protocol setting"$EBOLD
- echo -e " Using $BOLD http $EBOLD and $BOLD DMAAP $EBOLD towards the agent"
- export ADAPTER=$DMAAPBASE
- echo ""
- return 0
-}
-
-# All calls to the agent will be directed to the agent dmaap interface over https from now on
-# args: -
-# (Function for test scripts)
-use_agent_dmaap_https() {
- echo -e $BOLD"Agent dmaap protocol setting"$EBOLD
- echo -e " Using $BOLD https $EBOLD and $BOLD DMAAP $EBOLD towards the agent"
- export ADAPTER=$DMAAPBASE_SECURE
- echo ""
- return 0
-}
-
-# Turn on debug level tracing in the agent
-# args: -
-# (Function for test scripts)
-set_agent_debug() {
- echo -e $BOLD"Setting agent debug logging"$EBOLD
- actuator="/actuator/loggers/org.oransc.policyagent"
- if [[ $POLICY_AGENT_IMAGE = *"onap"* ]]; then
- actuator="/actuator/loggers/org.onap.ccsdk.oran.a1policymanagementservice"
- fi
- curlString="$LOCALHOST$POLICY_AGENT_EXTERNAL_PORT$actuator -X POST -H Content-Type:application/json -d {\"configuredLevel\":\"debug\"}"
- result=$(__do_curl "$curlString")
- if [ $? -ne 0 ]; then
- __print_err "could not set debug mode" $@
- ((RES_CONF_FAIL++))
- return 1
- fi
- echo ""
- return 0
-}
-
-# Turn on trace level tracing in the agent
-# args: -
-# (Function for test scripts)
-set_agent_trace() {
- echo -e $BOLD"Setting agent trace logging"$EBOLD
- actuator="/actuator/loggers/org.oransc.policyagent"
- if [[ $POLICY_AGENT_IMAGE = *"onap"* ]]; then
- actuator="/actuator/loggers/org.onap.ccsdk.oran.a1policymanagementservice"
- fi
- curlString="$LOCALHOST$POLICY_AGENT_EXTERNAL_PORT$actuator -X POST -H Content-Type:application/json -d {\"configuredLevel\":\"trace\"}"
- result=$(__do_curl "$curlString")
- if [ $? -ne 0 ]; then
- __print_err "could not set trace mode" $@
- ((RES_CONF_FAIL++))
- return 1
- fi
- echo ""
- return 0
-}
-
-# Perform curl retries when making direct call to the agent for the specified http response codes
-# Speace separated list of http response codes
-# args: [<response-code>]*
-use_agent_retries() {
- echo -e $BOLD"Do curl retries to the agent REST inteface for these response codes:$@"$EBOLD
- AGENT_RETRY_CODES=$@
- echo ""
- return
-}
-
-###########################
-### ECS functions
-###########################
-
-# Start the ECS
-# args: -
-# (Function for test scripts)
-start_ecs() {
-
- echo -e $BOLD"Starting ECS"$EBOLD
-
- curdir=$PWD
- cd $SIM_GROUP
- cd ecs
- cd $ECS_HOST_MNT_DIR
- if [ -d database ]; then
- if [ "$(ls -A $DIR)" ]; then
- echo -e $BOLD" Cleaning files in mounted dir: $PWD/database"$EBOLD
- rm -rf database/* &> /dev/null
- if [ $? -ne 0 ]; then
- echo -e $RED" Cannot remove database files in: $PWD"$ERED
- exit 1
- fi
- fi
- else
- echo " No files in mounted dir or dir does not exists"
- fi
- cd $curdir
-
- __check_included_image 'ECS'
- if [ $? -eq 1 ]; then
- echo -e $RED"The ECS image has not been checked for this test run due to arg to the test script"$ERED
- echo -e $RED"ECS will not be started"$ERED
- exit
- fi
- export ECS_CERT_MOUNT_DIR="./cert"
- __start_container ecs NODOCKERARGS $ECS_APP_NAME $ECS_EXTERNAL_PORT "/status" "http"
-}
-
-# Restart ECS
-# args: -
-# (Function for test scripts)
-restart_ecs() {
- echo -e $BOLD"Re-starting ECS"$EBOLD
- docker restart $ECS_APP_NAME &> ./tmp/.dockererr
- if [ $? -ne 0 ]; then
- __print_err "Could restart $ECS_APP_NAME" $@
- cat ./tmp/.dockererr
- ((RES_CONF_FAIL++))
- return 1
- fi
-
- __check_container_start $ECS_APP_NAME $ECS_EXTERNAL_PORT "/status" "http"
- echo ""
- return 0
-}
-
-# All calls to ECS will be directed to the ECS REST interface from now on
-# args: -
-# (Function for test scripts)
-use_ecs_rest_http() {
- echo -e $BOLD"ECS protocol setting"$EBOLD
- echo -e " Using $BOLD http $EBOLD and $BOLD REST $EBOLD towards ECS"
- export ECS_ADAPTER=$ECS_RESTBASE
- echo ""
-}
-
-# All calls to ECS will be directed to the ECS REST interface from now on
-# args: -
-# (Function for test scripts)
-use_ecs_rest_https() {
- echo -e $BOLD"ECS protocol setting"$EBOLD
- echo -e " Using $BOLD https $EBOLD and $BOLD REST $EBOLD towards ECS"
- export ECS_ADAPTER=$ECS_RESTBASE_SECURE
- echo ""
- return 0
-}
-
-# All calls to ECS will be directed to the ECS dmaap interface over http from now on
-# args: -
-# (Function for test scripts)
-use_ecs_dmaap_http() {
- echo -e $BOLD"ECS dmaap protocol setting"$EBOLD
- echo -e $RED" - NOT SUPPORTED - "$ERED
- echo -e " Using $BOLD http $EBOLD and $BOLD DMAAP $EBOLD towards ECS"
- export ECS_ADAPTER=$ECS_DMAAPBASE
- echo ""
- return 0
-}
-
-# All calls to ECS will be directed to the ECS dmaap interface over https from now on
-# args: -
-# (Function for test scripts)
-use_ecs_dmaap_https() {
- echo -e $BOLD"RICSIM protocol setting"$EBOLD
- echo -e $RED" - NOT SUPPORTED - "$ERED
- echo -e " Using $BOLD https $EBOLD and $BOLD REST $EBOLD towards ECS"
- export ECS_ADAPTER=$ECS_DMAAPBASE_SECURE
- echo ""
- return 0
-}
-
-# Turn on debug level tracing in ECS
-# args: -
-# (Function for test scripts)
-set_ecs_debug() {
- echo -e $BOLD"Setting ecs debug logging"$EBOLD
- curlString="$LOCALHOST$ECS_EXTERNAL_PORT/actuator/loggers/org.oransc.enrichment -X POST -H Content-Type:application/json -d {\"configuredLevel\":\"debug\"}"
- result=$(__do_curl "$curlString")
- if [ $? -ne 0 ]; then
- __print_err "Could not set debug mode" $@
- ((RES_CONF_FAIL++))
- return 1
- fi
- echo ""
- return 0
-}
-
-# Turn on trace level tracing in ECS
-# args: -
-# (Function for test scripts)
-set_ecs_trace() {
- echo -e $BOLD"Setting ecs trace logging"$EBOLD
- curlString="$LOCALHOST$ECS_EXTERNAL_PORT/actuator/loggers/org.oransc.enrichment -X POST -H Content-Type:application/json -d {\"configuredLevel\":\"trace\"}"
- result=$(__do_curl "$curlString")
- if [ $? -ne 0 ]; then
- __print_err "Could not set trace mode" $@
- ((RES_CONF_FAIL++))
- return 1
- fi
- echo ""
- return 0
-}
-
-# Perform curl retries when making direct call to ECS for the specified http response codes
-# Speace separated list of http response codes
-# args: [<response-code>]*
-use_agent_retries() {
- echo -e $BOLD"Do curl retries to the ECS REST inteface for these response codes:$@"$EBOLD
- ECS_AGENT_RETRY_CODES=$@
- echo ""
- return
-}
-
-#################
-### Log functions
-#################
-
-# Check the agent logs for WARNINGs and ERRORs
-# args: -
-# (Function for test scripts)
-
-check_policy_agent_logs() {
- __check_container_logs "Policy Agent" $POLICY_AGENT_APP_NAME $POLICY_AGENT_LOGPATH WARN ERR
-}
-
-check_ecs_logs() {
- __check_container_logs "ECS" $ECS_APP_NAME $ECS_LOGPATH WARN ERR
-}
-
-check_control_panel_logs() {
- __check_container_logs "Control Panel" $CONTROL_PANEL_APP_NAME $CONTROL_PANEL_LOGPATH WARN ERR
-}
-
-check_sdnc_logs() {
- __check_container_logs "SDNC A1 Controller" $SDNC_APP_NAME $SDNC_KARAF_LOG WARN ERROR
-}