X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=near-rt-ric-simulator%2Fcommon%2Ftestcase_common.sh;h=088995fd3ff9e8ab48c14cbd44e443204b97dc11;hb=refs%2Fchanges%2F70%2F3270%2F2;hp=dfca543c09367b8692e8e28dce5b0f5621f6dc20;hpb=cab4e22306e67088c0e9a195d25767929ed55ca7;p=nonrtric.git diff --git a/near-rt-ric-simulator/common/testcase_common.sh b/near-rt-ric-simulator/common/testcase_common.sh index dfca543c..088995fd 100755 --- a/near-rt-ric-simulator/common/testcase_common.sh +++ b/near-rt-ric-simulator/common/testcase_common.sh @@ -1,33 +1,59 @@ -#!/usr/bin/env bash +#!/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 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" +RED="\033[31m\033[1m" +ERED="\033[0m" +GREEN="\033[32m\033[1m" +EGREEN="\033[0m" +YELLOW="\033[33m\033[1m" +EYELLOW="\033[0m" + +# Just resetting any previous echo formatting... +echo -ne $EBOLD$ERED$EGREEN + +# source test environment variables . ../common/test_env.sh -echo "Test case started as: ${BASH_SOURCE[$i+1]} "$1 +echo "Test case started as: ${BASH_SOURCE[$i+1]} "$@ -# This is a script that contains all the functions needed for auto test -# Arg: local | remote +#Vars for A1 interface version and container count +G1_A1_VERSION="" +G2_A1_VERSION="" +G3_A1_VERSION="" +G1_COUNT=0 +G2_COUNT=0 +G3_COUNT=0 -STARTED_POLICY_AGENT="" #Policy agent app names added to this var to keep track of started container in the script -START_ARG=$1 -IMAGE_TAG="1.0.0-SNAPSHOT" -IMAGE_TAG_REMOTE="latest" +#Localhost constant +LOCALHOST="http://localhost:" -if [ $# -lt 1 ] || [ $# -gt 2 ]; then - echo "Expected arg: local | remote " - exit 1 -elif [ $1 == "local" ]; then - if [ -z $POLICY_AGENT_LOCAL_IMAGE ]; then - echo "POLICY_AGENT_LOCAL_IMAGE not set in test_env" - exit 1 - fi - POLICY_AGENT_IMAGE=$POLICY_AGENT_LOCAL_IMAGE":"$IMAGE_TAG -elif [ $1 == "remote" ]; then - if [ -z $POLICY_AGENT_REMOTE_IMAGE ]; then - echo "POLICY_AGENT_REMOTE_IMAGE not set in test_env" - exit 1 - fi - POLICY_AGENT_IMAGE=$POLICY_AGENT_REMOTE_IMAGE":"$IMAGE_TAG_REMOTE -fi +# Make curl retries for http response codes set in this env var, space separated list of codes +AGENT_RETRY_CODES="" + +# Var to hold 'auto' in case containers shall be stopped when test case ends +AUTO_CLEAN="" # Set a description string for the test case if [ -z "$TC_ONELINE_DESCR" ]; then @@ -35,18 +61,36 @@ if [ -z "$TC_ONELINE_DESCR" ]; then echo "No test case description found, TC_ONELINE_DESCR should be set on in the test script , using "$TC_ONELINE_DESCR fi -ATC=$(basename "${BASH_SOURCE[$i+1]}" .sh) +# Counter for test suites +if [ -f .tmp_tcsuite_ctr ]; then + tmpval=$(< .tmp_tcsuite_ctr) + ((tmpval++)) + echo $tmpval > .tmp_tcsuite_ctr +fi +# Create a test case id, ATC (Auto Test Case), from the name of the test case script. +# FTC1.sh -> ATC == FTC1 +ATC=$(basename "${BASH_SOURCE[$i+1]}" .sh) # Create the logs dir if not already created in the current dir if [ ! -d "logs" ]; then mkdir logs fi - TESTLOGS=$PWD/logs +# Create a http message log for this testcase +HTTPLOG=$PWD"/.httplog_"$ATC".txt" +echo "" > $HTTPLOG + +# Create a log dir for the test case mkdir -p $TESTLOGS/$ATC +# Clear the log dir for the test case +rm $TESTLOGS/$ATC/*.log &> /dev/null +rm $TESTLOGS/$ATC/*.txt &> /dev/null +rm $TESTLOGS/$ATC/*.json &> /dev/null + +# Log all output from the test case to a TC log TCLOG=$TESTLOGS/$ATC/TC.log exec &> >(tee ${TCLOG}) @@ -54,6 +98,9 @@ exec &> >(tee ${TCLOG}) RES_TEST=0 RES_PASS=0 RES_FAIL=0 +RES_CONF_FAIL=0 + +#Var for measuring execution time TCTEST_START=$SECONDS echo "-------------------------------------------------------------------------------------------------" @@ -64,136 +111,519 @@ echo "-- Description: "$TC_ONELINE_DESCR echo "-------------------------------------------------------------------------------------------------" echo "----------------------------------- Test case setup -----------------------------------" +echo -e $BOLD"Checking configured image setting for this test case"$EBOLD + +#Temp var to check for image variable name errors +IMAGE_ERR=0 +#Create a file with image info for later printing as a table +image_list_file=".image-list" +echo -e " Container\tImage\ttag" > $image_list_file + +# Check if image env var is set and if so export the env var with image to use (used by docker compose files) +# arg: