+###########################
+### 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
+}
+