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" == "" ] || [ "$3" == "" ]; then
26 echo "Usage: ete-k8s.sh <namespace> <tag> <override_file> [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:36421 -v TEST_NODE_B_NAME:BBBB654321\""
30 echo " NOTE1: TEST_NODE_B_NAME is 4 upper case letters and then 6 numbers in Dashboard validation "
31 echo " NOTE2: TEST_NODE_B_PORT real nodeB's use 36422 but e2sim must be on a port other than 36422"
43 # setup a detail log file
44 current_time=$(date "+%Y.%m.%d-%H.%M.%S")
45 LOGFILE=/tmp/ete-k8s.e2sim.$current_time.log
47 DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
50 # extract the base to find root to dep
54 BASEDIR50=$BASE/dep/ric-platform/50-RIC-Platform
55 #OVERRIDEYAML=$BASE/dep/RECIPE_EXAMPLE/ric-platform
58 echo "Using etc/ric.conf from $BASEDIR50"
60 source $BASEDIR50/etc/ric.conf
63 if [ -z "$RICPLT_RELEASE_NAME" ];then
64 RELEASE_NAME=$helm_release_name
66 RELEASE_NAME=$RICPLT_RELEASE_NAME
71 # first parameter: number of expected running pods
72 # second parameter: namespace (all-namespaces means all namespaces)
73 # third parameter: [optional] keyword
74 wait_for_pods_running () {
76 CMD="kubectl get pods --all-namespaces "
77 if [ "$NS" != "all-namespaces" ]; then
78 CMD="kubectl get pods -n $2 "
81 if [ "$#" == "3" ]; then
82 KEYWORD="${3}.*Running"
85 CMD2="$CMD | grep \"$KEYWORD\" | wc -l"
86 NUMPODS=$(eval "$CMD2")
87 echo "waiting for $NUMPODS/$1 pods running in namespace [$NS] with keyword [$KEYWORD]"
88 while [ $NUMPODS -lt $1 ]; do
90 NUMPODS=$(eval "$CMD2")
96 wait_for_pods_terminated() {
98 CMD="kubectl get pods --all-namespaces "
99 if [ "$NS" != "all-namespaces" ]; then
100 CMD="kubectl get pods -n $2 "
103 if [ "$#" == "3" ]; then
107 CMD2="$CMD | grep \"$KEYWORD\" | wc -l"
108 NUMPODS=$(eval "$CMD2")
109 echo "waiting for $NUMPODS/$1 pods terminated (gone) in namespace [$NS] with keyword [$KEYWORD]"
110 while [ $NUMPODS -gt $1 ]; do
112 NUMPODS=$(eval "$CMD2")
120 # e2mgr can take a few seconds after the POD is running to be up
124 E2MGR_IP=$(kubectl -n ricplt get services | grep e2mgr-http | awk '{print $3}')
126 CMD3="curl -s -o /dev/null -w \"%{http_code}\" http://$E2MGR_IP:3800/v1/nodeb-ids"
128 HTTP_CODE=$(eval "$CMD3")
130 while [ $HTTP_CODE -ne 200 ]; do
132 HTTP_CODE=$(eval "$CMD3")
141 if [ "$4" != "" ] ; then
147 export NAMESPACE="$1"
149 POD=$(kubectl --namespace $NAMESPACE get pods | sed 's/ .*//'| grep robot)
155 # if $2 is e2setup or x2setup then helm delete/helm install
163 e2setup|e2setup_dash|x2setup|x2setup_dash)
164 helm delete ${RELEASE_NAME}-e2term --purge >> $LOGFILE
165 helm delete ${RELEASE_NAME}-e2mgr --purge >> $LOGFILE
166 helm delete ${RELEASE_NAME}-e2sim --purge >> $LOGFILE
167 wait_for_pods_terminated 0 $NAMESPACE e2sim
168 wait_for_pods_terminated 0 $NAMESPACE e2term
169 wait_for_pods_terminated 0 $NAMESPACE e2mgr
170 helm install -f $OVERRIDEYAML --namespace "${NAMESPACE}" --name "${RELEASE_NAME}-e2term" $BASEDIR50/helm/e2term >> $LOGFILE
171 helm install -f $OVERRIDEYAML --namespace "${NAMESPACE}" --name "${RELEASE_NAME}-e2mgr" $BASEDIR50/helm/e2mgr >> $LOGFILE
172 cd /root/test/simulators/e2sim/helm
173 ./e2sim_install.sh >> $LOGFILE
174 wait_for_pods_running 1 $NAMESPACE e2term
175 wait_for_pods_running 1 $NAMESPACE e2mgr
176 wait_for_pods_running 1 $NAMESPACE e2sim
177 # wait for application
179 E2SIMIP=$(kubectl -n ricplt get pod -o=wide | grep e2sim | sed 's/\s\s*/ /g' | cut -d ' ' -f6)
180 VARIABLES="$VARIABLES -v TEST_NODE_B_IP:$E2SIMIP"
191 export GLOBAL_BUILD_NUMBER=$(kubectl --namespace $NAMESPACE exec ${POD} -- bash -c "ls -1q /share/logs/ | wc -l")
192 OUTPUT_FOLDER=$(printf %04d $GLOBAL_BUILD_NUMBER)_ete_$TAG
193 DISPLAY_NUM=$(($GLOBAL_BUILD_NUMBER + 90))
195 VARIABLEFILES="-V /share/config/vm_properties.py -V /share/config/integration_robot_properties.py"
196 #VARIABLEFILES="-V /tmp/vm_properties.py -V /share/config/integration_robot_properties.py"
197 VARIABLES="$VARIABLES -v GLOBAL_BUILD_NUMBER:$$"
201 kubectl --namespace $NAMESPACE exec ${POD} -- ${ETEHOME}/runTags.sh ${VARIABLEFILES} ${VARIABLES} -d /share/logs/${OUTPUT_FOLDER} ${TAGS} --display $DISPLAY_NUM