Install latest stable version of Juju
[osm/devops.git] / robot-systest / run_test.sh
1 #!/usr/bin/env bash
2
3 ##
4 # Copyright 2019 Tech Mahindra Limited
5 #
6 # All Rights Reserved.
7 #
8 # Licensed under the Apache License, Version 2.0 (the "License");
9 # you may not use this file except in compliance with the License.
10 # You may obtain a copy of the License at
11 #
12 # http://www.apache.org/licenses/LICENSE-2.0
13 #
14 # Unless required by applicable law or agreed to in writing, software
15 # distributed under the License is distributed on an "AS IS" BASIS,
16 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 # See the License for the specific language governing permissions and
18 # limitations under the License.
19 ##
20
21 ## Change log:
22 # 1. Feature 7829: Mrityunjay Yadav, Jayant Madavi : MY00514913@techmahindra.com : 06-Sep-2019
23 # Entry script to start the vim, smoke, openstack_stage_4 and comprehensive test using Robot Framework as a Automation Test Framework
24 ##
25
26 BASEDIR=$(dirname "$0")
27 TOPDIR=$(dirname "$BASEDIR")
28 DESCRIPTOR_DIR=$TOPDIR/descriptor-packages
29
30
31 robot_prerequisite(){
32 echo -e "\nInstalling robot requirements"
33 # installing python packages
34 pip install haikunator requests robotframework robotframework-seleniumlibrary robotframework-requests
35
36 # installing chrome driver and chrome for UI testing
37 curl -sS -o - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
38 echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list
39 apt-get update && apt-get -y install google-chrome-stable chromium-chromedriver
40 }
41
42 while getopts ":t:-:" o; do
43 case "${o}" in
44 t)
45 TEST=${OPTARG}
46 ;;
47 -)
48 [[ "${OPTARG}" == "do_install" ]] && robot_prerequisite && continue
49 ;;
50 \?)
51 echo -e "Invalid option: '-$OPTARG'\n" >&2
52 exit 1
53 ;;
54 esac
55 done
56
57 if [[ -z $TEST ]]; then
58 printf "Test not provided. \nRunning default test: smoke\n"
59 TEST="smoke"
60 fi
61
62 if [[ "$TEST" == "vim" ]]; then
63 echo "Robot Framework Vim Test"
64 robot -d $BASEDIR/reports -i vim $BASEDIR/testsuite/
65 exit 0
66 elif [[ "$TEST" == "smoke" ]]; then
67 echo "Robot Framework SMOKE test"
68 robot -d $BASEDIR/reports -i smoke $BASEDIR/testsuite/
69 exit 0
70 elif [[ "$TEST" == "sanity" ]]; then
71 echo "Robot Framework Cirros VNF Test"
72 mkdir -p $BASEDIR/images/cache
73 if [[ ! -z $OS_AUTH_URL ]]; then
74 (openstack image show cirros-0.3.5-x86_64-disk.img) || (wget -r -nc http://download.cirros-cloud.net/0.3.5/cirros-0.3.5-x86_64-disk.img -O $BASEDIR/images/cache/cirros-0.3.5-x86_64-disk.img && make $BASEDIR/images/cache/cirros-0.3.5-x86_64-disk.img && openstack image create --file $BASEDIR/images/cache/cirros-0.3.5-x86_64-disk.img cirros-0.3.5-x86_64-disk.img)
75 fi
76 if [[ ! -z $VCD_AUTH_URL ]]; then
77 # TODO: Check for image over VIM before downloading
78 if [[ ! -s $BASEDIR/images/cache/cirros-0.3.5-x86_64-disk.img ]]; then
79 wget -r -nc http://download.cirros-cloud.net/0.3.5/cirros-0.3.5-x86_64-disk.img -O $BASEDIR/images/cache/cirros-0.3.5-x86_64-disk.img
80 fi
81 ovf_converter $BASEDIR/images/cache/cirros-0.3.5-x86_64-disk.img -n cirros
82 python $TOPDIR/tools/vmware_ovf_upload.py $VCD_AUTH_URL $VCD_USERNAME $VCD_PASSWORD $VCD_ORGANIZATION $BASEDIR/images/cache/cirros.ovf
83 fi
84 robot -d $BASEDIR/reports -i sanity $BASEDIR/testsuite/
85 exit 0
86 elif [[ "$TEST" == "comprehensive" ]]; then
87 echo "Robot Framework Comprehensive Test"
88 mkdir -p $BASEDIR/images/cache
89 if [[ ! -z $OS_AUTH_URL ]]; then
90 (openstack image show ubuntu1604) || (wget -r -nc https://cloud-images.ubuntu.com/xenial/current/xenial-server-cloudimg-amd64-disk1.img -O $BASEDIR/images/cache/xenial-server-cloudimg-amd64-disk1.img && make $BASEDIR/images/cache/xenial-server-cloudimg-amd64-disk1.img && openstack image create --file $BASEDIR/images/cache/xenial-server-cloudimg-amd64-disk1.img ubuntu1604)
91 (openstack image show hackfest3-mgmt) || (wget -r -nc https://cloud-images.ubuntu.com/xenial/current/xenial-server-cloudimg-amd64-disk1.img -O $BASEDIR/images/cache/xenial-server-cloudimg-amd64-disk1.img && make $BASEDIR/images/cache/xenial-server-cloudimg-amd64-disk1.img && openstack image create --file $BASEDIR/images/cache/xenial-server-cloudimg-amd64-disk1.img hackfest3-mgmt)
92 fi
93 if [[ ! -z $VCD_AUTH_URL ]]; then
94 # TODO: Check for image over VIM before downloading
95 if [[ ! -s $BASEDIR/images/cache/xenial-server-cloudimg-amd64-disk1.img ]]; then
96 wget -r -nc https://cloud-images.ubuntu.com/xenial/current/xenial-server-cloudimg-amd64-disk1.img -O $BASEDIR/images/cache/xenial-server-cloudimg-amd64-disk1.img
97 fi
98 ovf_converter $BASEDIR/images/cache/xenial-server-cloudimg-amd64-disk1.img -n ubuntu1604
99 python $TOPDIR/tools/vmware_ovf_upload.py $VCD_AUTH_URL $VCD_USERNAME $VCD_PASSWORD $VCD_ORGANIZATION $BASEDIR/images/cache/ubuntu1604.ovf
100 fi
101 robot -d $BASEDIR/reports -i comprehensive $BASEDIR/testsuite/
102 exit 0
103 else
104 echo "wrong test provided"
105 exit 1
106 fi
107
108 exit 1