3f86ff9c4d099dc5dc8908812f8bd9f7a28b1b15
[osm/tests.git] / robot-systest / deprecated / 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 robotframework-jsonlibrary
35 }
36
37 while getopts ":t:-:" o; do
38 case "${o}" in
39 t)
40 TEST=${OPTARG}
41 ;;
42 -)
43 [[ "${OPTARG}" == "do_install" ]] && robot_prerequisite && continue
44 ;;
45 \?)
46 echo -e "Invalid option: '-$OPTARG'\n" >&2
47 exit 1
48 ;;
49 esac
50 done
51
52 if [[ -z $TEST ]]; then
53 printf "Test not provided. \nRunning default test: smoke\n"
54 TEST="smoke"
55 fi
56
57 if [[ "$TEST" == "vim" ]]; then
58 echo "Robot Framework Vim Test"
59 robot -d $BASEDIR/reports -i vim $BASEDIR/testsuite/
60 exit 0
61 elif [[ "$TEST" == "smoke" ]]; then
62 echo "Robot Framework SMOKE test"
63 robot --removekeywords tag:vim-setup --removekeywords WUKS -d $BASEDIR/reports -i smoke $BASEDIR/testsuite/
64 exit 0
65 elif [[ "$TEST" == "sanity" ]]; then
66 echo "Robot Framework Cirros VNF Test"
67 mkdir -p $BASEDIR/images/cache
68 if [[ ! -z $OS_AUTH_URL ]]; then
69 (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)
70 fi
71 if [[ ! -z $VCD_AUTH_URL ]]; then
72 # TODO: Check for image over VIM before downloading
73 if [[ ! -s $BASEDIR/images/cache/cirros-0.3.5-x86_64-disk.img ]]; then
74 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
75 fi
76 ovf_converter $BASEDIR/images/cache/cirros-0.3.5-x86_64-disk.img -n cirros
77 python $TOPDIR/tools/vmware_ovf_upload.py $VCD_AUTH_URL $VCD_USERNAME $VCD_PASSWORD $VCD_ORGANIZATION $BASEDIR/images/cache/cirros.ovf
78 fi
79 robot --removekeywords tag:vim-setup --removekeywords WUKS -d $BASEDIR/reports -i sanity $BASEDIR/testsuite/
80 exit 0
81 elif [[ "$TEST" == "comprehensive" ]]; then
82 echo "Robot Framework Comprehensive Test"
83 echo "Installing chrome driver and chrome for UI testing"
84 # installing chrome driver and chrome for UI testing
85 curl -sS -o - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
86 echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list
87 apt-get update && apt-get -y install google-chrome-stable chromium-chromedriver
88 echo "Checking of image over VIMs"
89 mkdir -p $BASEDIR/images/cache
90 if [[ ! -z $OS_AUTH_URL ]]; then
91 (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)
92 (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)
93 fi
94 if [[ ! -z $VCD_AUTH_URL ]]; then
95 # TODO: Check for image over VIM before downloading
96 if [[ ! -s $BASEDIR/images/cache/xenial-server-cloudimg-amd64-disk1.img ]]; then
97 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
98 fi
99 ovf_converter $BASEDIR/images/cache/xenial-server-cloudimg-amd64-disk1.img -n ubuntu1604
100 python $TOPDIR/tools/vmware_ovf_upload.py $VCD_AUTH_URL $VCD_USERNAME $VCD_PASSWORD $VCD_ORGANIZATION $BASEDIR/images/cache/ubuntu1604.ovf
101 fi
102 robot --removekeywords tag:vim-setup --removekeywords WUKS -d $BASEDIR/reports -i comprehensive $BASEDIR/testsuite/
103 exit 0
104 else
105 echo "wrong test provided"
106 exit 1
107 fi
108
109 exit 1