+###########################
+### Producer stub functions
+###########################
+
+# Start the Producer stub in the simulator group
+# args: -
+# (Function for test scripts)
+start_prod_stub() {
+
+ echo -e $BOLD"Starting $PROD_STUB_DISPLAY_NAME"$EBOLD
+
+ if [ $RUNMODE == "KUBE" ]; then
+
+ # Check if app shall be fully managed by the test script
+ __check_included_image "PRODSTUB"
+ retcode_i=$?
+
+ # Check if app shall only be used by the testscipt
+ __check_prestarted_image "PRODSTUB"
+ retcode_p=$?
+
+ if [ $retcode_i -ne 0 ] && [ $retcode_p -ne 0 ]; then
+ echo -e $RED"The $ECS_APP_NAME app is not included as managed nor prestarted in this test script"$ERED
+ echo -e $RED"The $ECS_APP_NAME will not be started"$ERED
+ exit
+ fi
+ if [ $retcode_i -eq 0 ] && [ $retcode_p -eq 0 ]; then
+ echo -e $RED"The $ECS_APP_NAME app is included both as managed and prestarted in this test script"$ERED
+ echo -e $RED"The $ECS_APP_NAME will not be started"$ERED
+ exit
+ fi
+
+ if [ $retcode_p -eq 0 ]; then
+ echo -e " Using existing $PROD_STUB_APP_NAME deployment and service"
+ echo " Setting RC replicas=1"
+ __kube_scale deployment $PROD_STUB_APP_NAME $KUBE_SIM_NAMESPACE 1
+ fi
+
+ if [ $retcode_i -eq 0 ]; then
+ echo -e " Creating $PROD_STUB_APP_NAME deployment and service"
+ export PROD_STUB_APP_NAME
+ export KUBE_SIM_NAMESPACE
+ export PROD_STUB_IMAGE
+ export PROD_STUB_INTERNAL_PORT
+ export PROD_STUB_INTERNAL_SECURE_PORT
+ export PROD_STUB_EXTERNAL_PORT
+ export PROD_STUB_EXTERNAL_SECURE_PORT
+
+ __kube_create_namespace $KUBE_SIM_NAMESPACE
+
+ # Create service
+ input_yaml=$SIM_GROUP"/"$PROD_STUB_COMPOSE_DIR"/"svc.yaml
+ output_yaml=$PWD/tmp/prodstub_svc.yaml
+ __kube_create_instance service $PROD_STUB_APP_NAME $input_yaml $output_yaml
+
+ # Create app
+ input_yaml=$SIM_GROUP"/"$PROD_STUB_COMPOSE_DIR"/"app.yaml
+ output_yaml=$PWD/tmp/prodstub_app.yaml
+ __kube_create_instance app $PROD_STUB_APP_NAME $input_yaml $output_yaml
+ fi
+
+ PROD_STUB_HOST_NAME=$(__kube_get_service_host $PROD_STUB_APP_NAME $KUBE_SIM_NAMESPACE)
+
+ PROD_STUB_EXTERNAL_PORT=$(__kube_get_service_port $PROD_STUB_APP_NAME $KUBE_SIM_NAMESPACE "http")
+ PROD_STUB_EXTERNAL_SECURE_PORT=$(__kube_get_service_port $PROD_STUB_APP_NAME $KUBE_SIM_NAMESPACE "https")
+
+ echo " Host IP, http port, https port: $PROD_STUB_HOST_NAME $PROD_STUB_EXTERNAL_PORT $PROD_STUB_EXTERNAL_SECURE_PORT"
+ if [ $PROD_STUB_HTTPX == "http" ]; then
+ PROD_STUB_PATH=$PROD_STUB_HTTPX"://"$PROD_STUB_HOST_NAME":"$PROD_STUB_EXTERNAL_PORT
+ PROD_STUB_SERVICE_PATH=$PROD_STUB_HTTPX"://"$PROD_STUB_APP_NAME"."$KUBE_SIM_NAMESPACE":"$PROD_STUB_EXTERNAL_PORT
+ else
+ PROD_STUB_PATH=$PROD_STUB_HTTPX"://"$PROD_STUB_HOST_NAME":"$PROD_STUB_EXTERNAL_SECURE_PORT
+ PROD_STUB_SERVICE_PATH=$PROD_STUB_HTTPX"://"$PROD_STUB_APP_NAME"."$KUBE_SIM_NAMESPACE":"$PROD_STUB_EXTERNAL_SECURE_PORT
+ fi
+
+ __check_service_start $PROD_STUB_APP_NAME $PROD_STUB_PATH$PROD_STUB_ALIVE_URL
+
+ echo -ne " Service $PROD_STUB_APP_NAME - reset "$SAMELINE
+ result=$(__do_curl $PROD_STUB_PATH/reset)
+ if [ $? -ne 0 ]; then
+ echo -e " Service $PROD_STUB_APP_NAME - reset $RED Failed $ERED - will continue"
+ else
+ echo -e " Service $PROD_STUB_APP_NAME - reset $GREEN OK $EGREEN"
+ fi
+ else
+
+ # Check if docker app shall be fully managed by the test script
+ __check_included_image 'PRODSTUB'
+ if [ $? -eq 1 ]; then
+ echo -e $RED"The Producer stub app is not included as managed in this test script"$ERED
+ echo -e $RED"The Producer stub will not be started"$ERED
+ exit
+ fi
+
+ export PROD_STUB_APP_NAME
+ export PROD_STUB_APP_NAME_ALIAS
+ export PROD_STUB_INTERNAL_PORT
+ export PROD_STUB_EXTERNAL_PORT
+ export PROD_STUB_INTERNAL_SECURE_PORT
+ export PROD_STUB_EXTERNAL_SECURE_PORT
+ export DOCKER_SIM_NWNAME
+
+ __start_container $PROD_STUB_COMPOSE_DIR NODOCKERARGS 1 $PROD_STUB_APP_NAME
+
+ __check_service_start $PROD_STUB_APP_NAME $PROD_STUB_PATH$PROD_STUB_ALIVE_URL
+ fi
+ echo ""
+ return 0
+}