2 ################################################################################
3 # Copyright (c) 2019 AT&T Intellectual Property. #
4 # Copyright (c) 2019 Nokia. #
6 # Licensed under the Apache License, Version 2.0 (the "License"); #
7 # you may not use this file except in compliance with the License. #
8 # You may obtain a copy of the License at #
10 # http://www.apache.org/licenses/LICENSE-2.0 #
12 # Unless required by applicable law or agreed to in writing, software #
13 # distributed under the License is distributed on an "AS IS" BASIS, #
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
15 # See the License for the specific language governing permissions and #
16 # limitations under the License. #
17 ################################################################################
21 # Run the testsuite for the passed tag. Valid tags are health
22 # Please clean up logs when you are done...
23 # Note: Do not run multiple concurrent ete.sh as the --display is not parameterized and tests will collide
25 if [ "$1" == "" ] || [ "$2" == "" ]; then
26 echo "Usage: ete-k8s.sh <namespace> <tag> [input variable]"
27 echo " [input variable] is added to runTags with "-v" prepended"
28 echo " example : TEST_NODE_B_IP:10.240.0.217 "
29 echo " example : \"TEST_NODE_B_IP:10.240.0.217 -v TEST_NODE_B_PORT:34622 -v TEST_NODE_B_NAME:BBBB654321\""
30 echo " note: TEST_NODE_B_NAME is 4 upper case letters and then 6 numbers in Dashboard validation "
43 DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
45 #/root/test/ric_robot_suite/helm
46 # extract the base to find root to dep
50 BASEDIR50=$BASE/dep/ric-platform/50-RIC-Platform/
51 OVERRIDEYAML=$BASE/dep/RECIPE_EXAMPLE/RIC_PLATFORM_RECIPE_EXAMPLE
53 echo "Using etc/ric.conf from $BASEDIR50"
55 source $BASEDIR50/etc/ric.conf
58 if [ -z "$RICPLT_RELEASE_NAME" ];then
59 RELEASE_NAME=$helm_release_name
61 RELEASE_NAME=$RICPLT_RELEASE_NAME
66 # first parameter: number of expected running pods
67 # second parameter: namespace (all-namespaces means all namespaces)
68 # third parameter: [optional] keyword
69 wait_for_pods_running () {
71 CMD="kubectl get pods --all-namespaces "
72 if [ "$NS" != "all-namespaces" ]; then
73 CMD="kubectl get pods -n $2 "
76 if [ "$#" == "3" ]; then
77 KEYWORD="${3}.*Running"
80 CMD2="$CMD | grep \"$KEYWORD\" | wc -l"
81 NUMPODS=$(eval "$CMD2")
82 echo "waiting for $NUMPODS/$1 pods running in namespace [$NS] with keyword [$KEYWORD]"
83 while [ $NUMPODS -lt $1 ]; do
85 NUMPODS=$(eval "$CMD2")
86 echo "> waiting for $NUMPODS/$1 pods running in namespace [$NS] with keyword [$KEYWORD]"
90 wait_for_pods_terminated() {
92 CMD="kubectl get pods --all-namespaces "
93 if [ "$NS" != "all-namespaces" ]; then
94 CMD="kubectl get pods -n $2 "
97 if [ "$#" == "3" ]; then
101 CMD2="$CMD | grep \"$KEYWORD\" | wc -l"
102 NUMPODS=$(eval "$CMD2")
103 echo "waiting for $NUMPODS/$1 pods terminated (gone) in namespace [$NS] with keyword [$KEYWORD]"
104 while [ $NUMPODS -gt $1 ]; do
106 NUMPODS=$(eval "$CMD2")
107 echo "> waiting for $NUMPODS/$1 pods terminated (gone) in namespace [$NS] with keyword [$KEYWORD]"
112 if [ "$3" != "" ] ; then
118 export NAMESPACE="$1"
120 POD=$(kubectl --namespace $NAMESPACE get pods | sed 's/ .*//'| grep robot)
126 # if $2 is e2setup or x2setup then helm delete/helm install
134 e2setup|e2setup_dash|x2setup|x2setup_dash)
135 #/root/dep/ric-platform/50-RIC-Platform/bin/harry-uninstall
136 helm delete ${RELEASE_NAME}-e2term --purge
137 helm delete ${RELEASE_NAME}-e2mgr --purge
138 helm delete ${RELEASE_NAME}-e2sim --purge
139 wait_for_pods_terminated 0 $NAMESPACE e2sim
140 wait_for_pods_terminated 0 $NAMESPACE e2term
141 wait_for_pods_terminated 0 $NAMESPACE e2mgr
142 helm install -f $OVERRIDEYAML --namespace "${NAMESPACE}" --name "${RELEASE_NAME}-e2term" $BASEDIR50/helm/e2term
143 helm install -f $OVERRIDEYAML --namespace "${NAMESPACE}" --name "${RELEASE_NAME}-e2mgr" $BASEDIR50/helm/e2mgr
144 cd /root/test/simulators/e2sim/helm
146 wait_for_pods_running 1 $NAMESPACE e2term
147 wait_for_pods_running 1 $NAMESPACE e2mgr
148 wait_for_pods_running 1 $NAMESPACE e2sim
149 E2SIMIP=$(kubectl -n ricplt get pod -o=wide | grep e2sim | sed 's/\s\s*/ /g' | cut -d ' ' -f6)
151 VARIABLES="$VARIABLES -v TEST_NODE_B_IP:$E2SIMIP"
162 export GLOBAL_BUILD_NUMBER=$(kubectl --namespace $NAMESPACE exec ${POD} -- bash -c "ls -1q /share/logs/ | wc -l")
163 OUTPUT_FOLDER=$(printf %04d $GLOBAL_BUILD_NUMBER)_ete_$TAG
164 DISPLAY_NUM=$(($GLOBAL_BUILD_NUMBER + 90))
166 VARIABLEFILES="-V /share/config/vm_properties.py -V /share/config/integration_robot_properties.py"
167 #VARIABLEFILES="-V /tmp/vm_properties.py -V /share/config/integration_robot_properties.py"
168 VARIABLES="$VARIABLES -v GLOBAL_BUILD_NUMBER:$$"
172 kubectl --namespace $NAMESPACE exec ${POD} -- ${ETEHOME}/runTags.sh ${VARIABLEFILES} ${VARIABLES} -d /share/logs/${OUTPUT_FOLDER} ${TAGS} --display $DISPLAY_NUM