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: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 "
42 # setup a detail log file
43 current_time=$(date "+%Y.%m.%d-%H.%M.%S")
44 LOGFILE=/tmp/ete-k8s.e2sim.$current_time.log
46 DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
49 # extract the base to find root to dep
53 BASEDIR50=$BASE/dep/ric-platform/50-RIC-Platform
54 #OVERRIDEYAML=$BASE/dep/RECIPE_EXAMPLE/ric-platform
57 echo "Using etc/ric.conf from $BASEDIR50"
59 source $BASEDIR50/etc/ric.conf
62 if [ -z "$RICPLT_RELEASE_NAME" ];then
63 RELEASE_NAME=$helm_release_name
65 RELEASE_NAME=$RICPLT_RELEASE_NAME
70 # first parameter: number of expected running pods
71 # second parameter: namespace (all-namespaces means all namespaces)
72 # third parameter: [optional] keyword
73 wait_for_pods_running () {
75 CMD="kubectl get pods --all-namespaces "
76 if [ "$NS" != "all-namespaces" ]; then
77 CMD="kubectl get pods -n $2 "
80 if [ "$#" == "3" ]; then
81 KEYWORD="${3}.*Running"
84 CMD2="$CMD | grep \"$KEYWORD\" | wc -l"
85 NUMPODS=$(eval "$CMD2")
86 echo "waiting for $NUMPODS/$1 pods running in namespace [$NS] with keyword [$KEYWORD]"
87 while [ $NUMPODS -lt $1 ]; do
89 NUMPODS=$(eval "$CMD2")
95 wait_for_pods_terminated() {
97 CMD="kubectl get pods --all-namespaces "
98 if [ "$NS" != "all-namespaces" ]; then
99 CMD="kubectl get pods -n $2 "
102 if [ "$#" == "3" ]; then
106 CMD2="$CMD | grep \"$KEYWORD\" | wc -l"
107 NUMPODS=$(eval "$CMD2")
108 echo "waiting for $NUMPODS/$1 pods terminated (gone) in namespace [$NS] with keyword [$KEYWORD]"
109 while [ $NUMPODS -gt $1 ]; do
111 NUMPODS=$(eval "$CMD2")
119 # e2mgr can take a few seconds after the POD is running to be up
123 E2MGR_IP=$(kubectl -n ricplt get services | grep e2mgr-http | awk '{print $3}')
125 CMD3="curl -s -o /dev/null -w \"%{http_code}\" http://$E2MGR_IP:3800/v1/nodeb-ids"
127 HTTP_CODE=$(eval "$CMD3")
129 while [ $HTTP_CODE -ne 200 ]; do
131 HTTP_CODE=$(eval "$CMD3")
140 if [ "$4" != "" ] ; then
146 export NAMESPACE="$1"
148 POD=$(kubectl --namespace $NAMESPACE get pods | sed 's/ .*//'| grep robot)
154 # if $2 is e2setup or x2setup then helm delete/helm install
162 e2setup|e2setup_dash|x2setup|x2setup_dash)
163 helm delete ${RELEASE_NAME}-e2term --purge >> $LOGFILE
164 helm delete ${RELEASE_NAME}-e2mgr --purge >> $LOGFILE
165 helm delete ${RELEASE_NAME}-e2sim --purge >> $LOGFILE
166 wait_for_pods_terminated 0 $NAMESPACE e2sim
167 wait_for_pods_terminated 0 $NAMESPACE e2term
168 wait_for_pods_terminated 0 $NAMESPACE e2mgr
169 helm install -f $OVERRIDEYAML --namespace "${NAMESPACE}" --name "${RELEASE_NAME}-e2term" $BASEDIR50/helm/e2term >> $LOGFILE
170 helm install -f $OVERRIDEYAML --namespace "${NAMESPACE}" --name "${RELEASE_NAME}-e2mgr" $BASEDIR50/helm/e2mgr >> $LOGFILE
171 cd /root/test/simulators/e2sim/helm
172 ./e2sim_install.sh >> $LOGFILE
173 wait_for_pods_running 1 $NAMESPACE e2term
174 wait_for_pods_running 1 $NAMESPACE e2mgr
175 wait_for_pods_running 1 $NAMESPACE e2sim
176 # wait for application
178 E2SIMIP=$(kubectl -n ricplt get pod -o=wide | grep e2sim | sed 's/\s\s*/ /g' | cut -d ' ' -f6)
179 VARIABLES="$VARIABLES -v TEST_NODE_B_IP:$E2SIMIP"
190 export GLOBAL_BUILD_NUMBER=$(kubectl --namespace $NAMESPACE exec ${POD} -- bash -c "ls -1q /share/logs/ | wc -l")
191 OUTPUT_FOLDER=$(printf %04d $GLOBAL_BUILD_NUMBER)_ete_$TAG
192 DISPLAY_NUM=$(($GLOBAL_BUILD_NUMBER + 90))
194 VARIABLEFILES="-V /share/config/vm_properties.py -V /share/config/integration_robot_properties.py"
195 #VARIABLEFILES="-V /tmp/vm_properties.py -V /share/config/integration_robot_properties.py"
196 VARIABLES="$VARIABLES -v GLOBAL_BUILD_NUMBER:$$"
200 kubectl --namespace $NAMESPACE exec ${POD} -- ${ETEHOME}/runTags.sh ${VARIABLEFILES} ${VARIABLES} -d /share/logs/${OUTPUT_FOLDER} ${TAGS} --display $DISPLAY_NUM