X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=near-rt-ric-simulator%2Fcommon%2Ftestcase_common.sh;h=d9a012ea66e7cc0fdf1d985b9fa083a5601bb926;hb=72c98f3b7ef556cf3556c398e12078d9b9eb6d1a;hp=7a8d8dca085255c62d8cedc5f248b211abe98271;hpb=d7fbc4199c419bb5c849e2bbec969294ebcee951;p=nonrtric.git diff --git a/near-rt-ric-simulator/common/testcase_common.sh b/near-rt-ric-simulator/common/testcase_common.sh index 7a8d8dca..d9a012ea 100755 --- a/near-rt-ric-simulator/common/testcase_common.sh +++ b/near-rt-ric-simulator/common/testcase_common.sh @@ -3,17 +3,19 @@ . ../common/test_env.sh echo "Test case started as: ${BASH_SOURCE[$i+1]} "$1 $2 +echo "Numbers of ric simulator started" $2 # This is a script that contains all the functions needed for auto test -# Arg: local | remote +# Arg: local | remote (1, 2, 3, 4....) 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="1.0.0" +IMAGE_TAG_REMOTE="latest" +RIC_NUMBER=$2 if [ $# -lt 1 ] || [ $# -gt 2 ]; then - echo "Expected arg: local [] | remote [] " + echo "Expected arg: local | remote and numbers of the rics " exit 1 elif [ $1 == "local" ]; then if [ -z $POLICY_AGENT_LOCAL_IMAGE ]; then @@ -111,6 +113,22 @@ if [ $1 != "manual-container" ] && [ $1 != "manual-app" ]; then fi fi +echo "" + +echo "Building images for the simulators" +curdir=$PWD +cd $SIM_GROUP +cd ../ric-plt/a1 +docker build -t ric-simulator:latest . &> /dev/null +cd $curdir + +echo "" + +echo "Local registry images for simulators:" +echo "Consul: " $(docker images | grep consul) +echo "CBS: " $(docker images | grep platform.configbinding.app) +echo "RIC: " $(docker images | grep ric-simulator) +echo "" __consul_config() { @@ -128,12 +146,48 @@ consul_config_app() { } + + +start_ric_simulator() { + + DOCKER_SIM_NWNAME="nonrtric-docker-net" + echo "Creating docker network $DOCKER_SIM_NWNAME, if needed" + docker network ls| grep $DOCKER_SIM_NWNAME > /dev/null || docker network create $DOCKER_SIM_NWNAME + + echo "start ric simulator" + curdir=$PWD + cd $SIM_GROUP + cd ric/ + + docker-compose up --scale ric-simulator=$RIC_NUMBER -d + + cd $curdir + echo "" +} + +prepare_consul_config() { + echo "prepare consul config" + curdir=$PWD + cd $SIM_GROUP + cd ric/ + + python3 cleanConsul.py + python3 prepareConsul.py + + cd $curdir + echo "" + + +} + + # Start all simulators in the simulator group start_simulators() { echo "Starting all simulators" curdir=$PWD cd $SIM_GROUP + $SIM_GROUP/simulators-start.sh cd $curdir echo "" @@ -144,6 +198,10 @@ clean_containers() { docker stop $(docker ps -q --filter name=/policy-agent) &> /dev/null echo "Removing all containers, policy agent app and simulators with name prefix 'policy_agent'" docker rm $(docker ps -a -q --filter name=/policy-agent) &> /dev/null + echo "Stopping all containers, policy agent app(s) and simulators with name prefix 'ric-simulator'" + docker stop $(docker ps -q --filter name=ric-simulator) &> /dev/null + echo "Removing all containers, policy agent app and simulators with name prefix 'ric-simulator'" + docker rm $(docker ps -a -q --filter name=ric-simulator) &> /dev/null echo "Removing unused docker networks with substring 'policy agent' in network name" docker network rm $(docker network ls -q --filter name=nonrtric) echo ""