# Create a log dir for the test case
mkdir -p $TESTLOGS/$ATC
+# Save create for current logs
+mkdir -p $TESTLOGS/$ATC/previous
+
+rm $TESTLOGS/$ATC/previous/*.log &> /dev/null
+rm $TESTLOGS/$ATC/previous/*.txt &> /dev/null
+rm $TESTLOGS/$ATC/previous/*.json &> /dev/null
+
+mv $TESTLOGS/$ATC/*.log $TESTLOGS/$ATC/previous &> /dev/null
+mv $TESTLOGS/$ATC/*.txt $TESTLOGS/$ATC/previous &> /dev/null
+mv $TESTLOGS/$ATC/*.txt $TESTLOGS/$ATC/previous &> /dev/null
+
# Clear the log dir for the test case
rm $TESTLOGS/$ATC/*.log &> /dev/null
rm $TESTLOGS/$ATC/*.txt &> /dev/null
if [ -f "$TEST_ENV_VAR_FILE" ]; then
echo -e $BOLD"Sourcing env vars from: "$TEST_ENV_VAR_FILE$EBOLD
. $TEST_ENV_VAR_FILE
+
+ if [ -z "$TEST_ENV_PROFILE" ] || [ -z "$SUPPORTED_PROFILES" ]; then
+ echo -e $YELLOW"This test case may no work with selected test env file. TEST_ENV_PROFILE is missing in test_env file or SUPPORTED_PROFILES is missing in test case file"$EYELLOW
+ else
+ if [[ "$SUPPORTED_PROFILES" == *"$TEST_ENV_PROFILE"* ]]; then
+ echo -e $GREEN"Test case support the selected test env file"$EGREEN
+ else
+ echo -e $RED"Test case does not support the selected test env file"$ERED
+ echo -e $RED"Exiting...."$ERED
+ exit 1
+ fi
+ fi
else
echo -e $RED"Selected env var file does not exist: "$TEST_ENV_VAR_FILE$ERED
echo " Select one of following env var file matching the intended target of the test"
G1_A1_VERSION=""
G2_A1_VERSION=""
G3_A1_VERSION=""
+G4_A1_VERSION=""
+G5_A1_VERSION=""
G1_COUNT=0
G2_COUNT=0
G3_COUNT=0
+G4_COUNT=0
+G5_COUNT=0
# Vars to switch between http and https. Extra curl flag needed for https
export RIC_SIM_HTTPX="http"
export CR_HTTPX="http"
export CR_PORT=$CR_INTERNAL_PORT
export CR_LOCAL_PORT=$CR_EXTERNAL_PORT #When CR is running outside the docker net
+export CR_PATH="$CR_HTTPX://$CR_APP_NAME:$CR_PORT$CR_APP_CALLBACK"
export PROD_STUB_HTTPX="http"
export PROD_STUB_PORT=$PROD_STUB_INTERNAL_PORT
((RES_CONF_FAIL++))
echo ""
echo -e $RED" Container $BOLD${appname}$EBOLD could not be started"$ERED
- return 1
+ echo -e $RED" Stopping script..."$ERED
+ exit 1
fi
if [ $localport -eq 0 ]; then
while [ $localport -eq 0 ]; do
else
TS_TMP=$SECONDS
while [ $(($TS_TMP+$i)) -gt $SECONDS ]; do
- echo -ne " Waiting for container ${appname} service status...retrying in $(($TS_TMP+$i-$SECONDS)) seconds ${SAMELINE}"
+ echo -ne " Waiting for container ${appname} service status...$(($SECONDS-$TSTART)) seconds, retrying in $(($TS_TMP+$i-$SECONDS)) seconds ${SAMELINE}"
sleep 1
done
fi
if [ "$pa_st" = "false" ]; then
((RES_CONF_FAIL++))
- echo -e $RED" Container ${appname} did not respond to service status"$ERED
+ echo -e $RED" Container ${appname} did not respond to service status in $(($SECONDS-$TSTART)) seconds"$ERED
return 0
fi
if [ $? -ne 0 ]; then
echo -e $RED"Problem to launch container(s) with docker-compose"$ERED
cat .dockererr
+ echo -e $RED"Stopping script...."$ERED
+ exit 1
fi
elif [ "$2" == "STANDALONE" ]; then
echo "Skipping docker-compose"
if [ $? -ne 0 ]; then
echo -e $RED"Problem to launch container(s) with docker-compose"$ERED
cat .dockererr
+ echo -e $RED"Stopping script...."$ERED
+ exit 1
fi
fi
app_prefix=""
echo ""
}
-# Start one group (ricsim_g1, ricsim_g2 or ricsim_g3) with a number of RIC Simulators using a given A interface
+# 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 <count> <interface-id>
+# args: ricsim_g1|ricsim_g2|ricsim_g3|ricsim_g4|ricsim_g5 <count> <interface-id>
# (Function for test scripts)
start_ric_simulators() {
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 <count> <interface-id>" $@
+ __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"
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 <count> <interface-id>" $@
+ __print_err "need three args, $RIC1|$RIC2|$RIC3|$RIC4|$RIC5 <count> <interface-id>" $@
exit 1
fi
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"
+ 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
export CR_HTTPX="http"
export CR_PORT=$CR_INTERNAL_PORT
export CR_LOCAL_PORT=$CR_EXTERNAL_PORT
+ export CR_PATH="$CR_HTTPX://$CR_APP_NAME:$CR_PORT$CR_APP_CALLBACK"
echo ""
}
export CR_HTTPX="https"
export CR_PORT=$CR_INTERNAL_SECURE_PORT
export CR_LOCAL_PORT=$CR_EXTERNAL_SECURE_PORT
+ export CR_PATH="$CR_HTTPX://$CR_APP_NAME:$CR_PORT$CR_APP_CALLBACK"
echo ""
}
# args: -
# (Function for test scripts)
use_agent_dmaap_https() {
- echo -e "Using $BOLD https $EBOLD and $BOLD REST $EBOLD towards the agent"
+ echo -e "Using $BOLD https $EBOLD and $BOLD DMAAP $EBOLD towards the agent"
export ADAPTER=$DMAAPBASE_SECURE
echo ""
return 0
__start_container ecs NODOCKERARGS $ECS_APP_NAME $ECS_EXTERNAL_PORT "/status" "http"
}
+# Restart ECS
+# args: -
+# (Function for test scripts)
+restart_ecs() {
+ docker restart $ECS_APP_NAME &> ./tmp/.dockererr
+ if [ $? -ne 0 ]; then
+ __print_err "Could restart $ECS_APP_NAME" $@
+ cat ./tmp/.dockererr
+ ((RES_CONF_FAIL++))
+ return 1
+ fi
+
+ __check_container_start $ECS_APP_NAME $ECS_EXTERNAL_PORT "/status" "http"
+ echo ""
+ return 0
+}
+
# All calls to ECS will be directed to the ECS REST interface from now on
# args: -
# (Function for test scripts)
__print_err "need one arg, <file-prefix>" $@
exit 1
fi
- echo -e $BOLD"Storing all container logs using prefix: "$1$EBOLD
+ echo -e $BOLD"Storing all container logs in $TESTLOGS/$ATC using prefix: "$1$EBOLD
docker stats --no-stream > $TESTLOGS/$ATC/$1_docker_stats.log 2>&1
### Generic test cases for varaible checking
-# Tests if a variable value in the CR is equal to a target value and and optional timeout.
-# Arg: <variable-name> <target-value> - This test set pass or fail depending on if the variable is
-# equal to the target or not.
-# Arg: <variable-name> <target-value> <timeout-in-sec> - This test waits up to the timeout seconds
-# before setting pass or fail depending on if the variable value becomes equal to the target
-# value or not.
-# (Function for test scripts)
-cr_equal() {
- if [ $# -eq 2 ] || [ $# -eq 3 ]; then
- __var_test "CR" "$LOCALHOST$CR_EXTERNAL_PORT/counter/" $1 "=" $2 $3
- else
- ((RES_CONF_FAIL++))
- __print_err "Wrong args to cr_equal, needs two or three args: <sim-param> <target-value> [ timeout ]" $@
- fi
-}
-
# Tests if a variable value in the MR stub is equal to a target value and and optional timeout.
# Arg: <variable-name> <target-value> - This test set pass or fail depending on if the variable is
# equal to the target or not.