Add initial codes
[it/test.git] / ric_robot_suite / docker / ric-robot / demo.sh
1 # Copyright © 2019 AT&T Intellectual Property. All rights reserved.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 #       http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 #!/bin/bash
16
17 function usage
18 {
19         echo "Usage: demo.sh <command> [<parameters>]"
20         echo " "
21         echo "       demo.sh <namespace> init_robot"
22         echo "               - Execute both initialize of robot login/password etc"
23         echo " "
24 }
25
26
27 #
28 # For docker container environment
29 #
30 # Run the testsuite for the passed tag. Valid tags are health
31 # Please clean up logs when you are done...
32 # Note: Do not run multiple concurrent demo.sh/ete.sh as the --display is not parameterized and tests will collide
33 #
34 if [ "$1" == "" ] ; then
35    echo "Usage: demo.sh  [ init_robot ]"
36    exit
37 fi
38
39 ##
40 ## if more than 1 tag is supplied, the must be provided with -i or -e
41 ##
42 while [ $# -gt 0 ]
43 do
44         key="$1"
45         echo "KEY:"
46         echo $key
47
48         case $key in
49         init_robot)
50                         TAG="UpdateWebPage"
51                         read -s -p "WEB Site Password for user 'test': " WEB_PASSWORD
52                         if [ "$WEB_PASSWORD" = "" ]; then
53                                 echo ""
54                                 echo "WEB Password is required for user 'test'"
55                                 exit
56                         fi
57                         VARIABLES="$VARIABLES -v WEB_PASSWORD:$WEB_PASSWORD"
58                         shift
59                         if [ $# -eq 2 ];then
60                                 VARIABLES="$VARIABLES -v HOSTS_PREFIX:$1"
61                         fi
62                         shift
63                         ;;
64         *)
65                         usage
66                         exit
67         esac
68 done
69
70 set -x
71
72 POD=ric-robot
73
74 TAGS="-i $TAG"
75
76
77 ETEHOME=/var/opt/RIC
78 #export GLOBAL_BUILD_NUMBER=$(docker exec  -it ${POD}  bash -c "ls -1q /share/logs/ | wc -l ")
79 GLOBAL_BUILD_NUMBER=$(docker exec  -it ${POD}  bash -c "ls -1q /share/logs/ | wc -l")
80 GLOBAL_BUILD_NUMBER=$(echo "$GLOBAL_BUILD_NUMBER" | tr -d '\r')
81 OUTPUT_FOLDER=$(printf %04d $GLOBAL_BUILD_NUMBER)_demo_$TAG
82 DISPLAY_NUM=$(($GLOBAL_BUILD_NUMBER + 90))
83
84 VARIABLEFILES="-V /share/config/vm_properties.py -V /share/config/integration_robot_properties.py"
85 VARIABLES="$VARIABLES -v GLOBAL_BUILD_NUMBER:$$"
86
87 docker  exec -it ${POD} ${ETEHOME}/runTags.sh ${VARIABLEFILES} ${VARIABLES} -d /share/logs/${OUTPUT_FOLDER} ${TAGS} --display $DISPLAY_NUM