Merge "Reorganize directories and switch libaries to using asn1c"
[it/test.git] / ric_robot_suite / setup.sh
1 #!/bin/bash
2
3 ################################################################################
4 #   Copyright (c) 2019 AT&T Intellectual Property.                             #
5 #   Copyright (c) 2019 Nokia.                                                  #
6 #                                                                              #
7 #   Licensed under the Apache License, Version 2.0 (the "License");            #
8 #   you may not use this file except in compliance with the License.           #
9 #   You may obtain a copy of the License at                                    #
10 #                                                                              #
11 #       http://www.apache.org/licenses/LICENSE-2.0                             #
12 #                                                                              #
13 #   Unless required by applicable law or agreed to in writing, software        #
14 #   distributed under the License is distributed on an "AS IS" BASIS,          #
15 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
16 #   See the License for the specific language governing permissions and        #
17 #   limitations under the License.                                             #
18 ################################################################################
19
20
21
22 #
23 # setup : script to setup required runtime environment. This script can be run again to update anything
24 # this should stay in your project directory
25
26
27 # save console output in setup_<timestamp>.log file in project directory
28 timestamp=$(date +"%m%d%Y_%H%M%S")
29 LOG_FILE=setup_$timestamp.log
30 exec > >(tee -a ${LOG_FILE} )
31 exec 2> >(tee -a ${LOG_FILE} >&2)
32
33
34 # get the path
35 path=$(pwd)
36 pip install \
37 --no-cache-dir \
38 --exists-action s \
39 --target="$path/robot/library" \
40 'selenium<=3.0.0' \
41 'requests==2.11.1' \
42 'robotframework-selenium2library==1.8.0' \
43 'robotframework-databaselibrary==0.8.1' \
44 'robotframework-extendedselenium2library==0.9.1' \
45 'robotframework-requests==0.5.0' \
46 'robotframework-sshlibrary==2.1.2' \
47 'robotframework-sudslibrary==0.8' \
48 'robotframework-ftplibrary==1.3' \
49 'robotframework-rammbock==0.4.0.1' \
50 'deepdiff==2.5.1' \
51 'dnspython==1.15.0' \
52 'robotframework-httplibrary==0.4.2' \
53 'robotframework-archivelibrary==0.3.2' \
54 'PyYAML==3.12' \
55 'kubernetes==9.0.0' \
56 'pick==0.6.4' \
57 'robotframework-kafkalibrary==0.0.2'
58
59 # dk3239: HACK
60 #  for some reason the parent __init__.py isn't getting installed
61 #  with google-auth.  This is a quick fix until I figure out which
62 #  package (hint: it's not "google") owns it.
63 touch $path/robot/library/google/__init__.py
64
65 # get the git for the eteutils you will need to add a private key to your ssh before this
66 if [ -d $path/testsuite/eteutils ]
67 then
68     # Support LF build location
69         cd $path/testsuite/eteutils
70 else
71         cd ~
72         git config --global http.sslVerify false
73         if [ -d ~/python-testing-utils ]
74         then
75                 cd python-testing-utils
76                 git pull origin master
77         else
78                 git clone -b 3.0.1-ONAP https://gerrit.onap.org/r/testsuite/python-testing-utils.git
79                 cd python-testing-utils
80         fi
81 fi
82
83 # install python-testing-utils from current directory (.)
84 pip install \
85 --no-cache-dir \
86 --upgrade \
87 --exists-action s \
88 --target="$path/robot/library" .
89
90
91 # install the ric project python scripts
92 # from /var/opt/RIC/ric-python-utils
93 # to   /var/opt/RIC/robot/library/ricutils
94 if [ -d $path/ric-python-utils ]
95 then
96     # Support LF build location
97         cd $path/ric-python-utils
98     # install ric-python-utils from current directory (.)
99         pip install \
100         --no-cache-dir \
101         --upgrade \
102         --exists-action s \
103         --target="$path/robot/library" .
104 fi
105
106 # NOTE: Patch to incude explicit install of paramiko to 2.0.2 to work with sshlibrary 2.1.2
107 # This should be removed on new release of paramiko (2.1.2) or sshlibrary
108 # https://github.com/robotframework/SSHLibrary/issues/157
109 pip install \
110 --no-cache-dir \
111 --target="$path/robot/library" \
112 -U 'paramiko==2.0.2'
113
114
115 # Go back to execution folder
116 cd $path
117
118 # if the script is running during the image build skip the rest of it
119 # as required software is installed already.
120 if $BUILDTIME
121 then
122         # we need to update PATH with APT-GET installed chromium-chromedriver
123         echo "Adding in-container chromedriver to PATH"
124         ln -s /usr/lib/chromium-browser/chromedriver /usr/local/bin/chromedriver
125 else    
126         #
127         # Get the appropriate chromedriver. Default to linux64
128         #
129         CHROMEDRIVER_URL=http://chromedriver.storage.googleapis.com/2.43
130         CHROMEDRIVER_ZIP=chromedriver_linux64.zip
131         CHROMEDRIVER_TARGET=chromedriver.zip
132
133         # Handle mac and windows
134         OS=`uname -s`
135         case $OS in
136           MINGW*_NT*)
137                 CHROMEDRIVER_ZIP=chromedriver_win32.zip
138                 ;;
139           Darwin*)
140                 CHROMEDRIVER_ZIP=chromedriver_mac64.zip
141                 ;;
142           *) echo "Defaulting to Linux 64" ;;
143         esac
144
145         if [ $CHROMEDRIVER_ZIP == 'chromedriver_linux64.zip' ]
146         then
147             curl $CHROMEDRIVER_URL/$CHROMEDRIVER_ZIP -o $CHROMEDRIVER_TARGET
148                 unzip chromedriver.zip -d /usr/local/bin
149         else
150             curl $CHROMEDRIVER_URL/$CHROMEDRIVER_ZIP -o $CHROMEDRIVER_TARGET
151                 unzip $CHROMEDRIVER_TARGET
152         fi
153         rm -rf $CHROMEDRIVER_TARGET
154 fi
155
156 #
157 # Install kafkacat : https://github.com/edenhill/kafkacat
158 #
159 OS=`uname -s`
160 case $OS in
161         Darwin)
162                 brew install kafkacat ;;
163         Linux)
164                 apt-get -y install kafkacat
165 esac
166 #
167 # Install protobuf
168 #
169 OS=`uname -s`
170 case $OS in
171         Darwin)
172                 brew install protobuf ;;
173         Linux)
174                 apt-get -y install protobuf-compiler
175 esac