blob: 42b23284ef9fcb2d7dc0495c9bda415b1b22fe38 [file] [log] [blame]
yadavmr58af6b12019-09-18 15:33:25 +05301#!/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
26BASEDIR=$(dirname "$0")
27TOPDIR=$(dirname "$BASEDIR")
28DESCRIPTOR_DIR=$TOPDIR/descriptor-packages
29
30
31robot_prerequisite(){
32 echo -e "\nInstalling robot requirements"
33 # installing python packages
34 pip install haikunator requests robotframework robotframework-seleniumlibrary robotframework-requests
yadavmr58af6b12019-09-18 15:33:25 +053035}
36
37while 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
50done
51
52if [[ -z $TEST ]]; then
53 printf "Test not provided. \nRunning default test: smoke\n"
54 TEST="smoke"
55fi
56
57if [[ "$TEST" == "vim" ]]; then
58 echo "Robot Framework Vim Test"
59 robot -d $BASEDIR/reports -i vim $BASEDIR/testsuite/
60 exit 0
61elif [[ "$TEST" == "smoke" ]]; then
62 echo "Robot Framework SMOKE test"
yadavmrf21d9da2019-11-05 11:42:57 +053063 robot --removekeywords tag:vim-setup --removekeywords WUKS -d $BASEDIR/reports -i smoke $BASEDIR/testsuite/
yadavmr58af6b12019-09-18 15:33:25 +053064 exit 0
65elif [[ "$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
yadavmrf21d9da2019-11-05 11:42:57 +053079 robot --removekeywords tag:vim-setup --removekeywords WUKS -d $BASEDIR/reports -i sanity $BASEDIR/testsuite/
yadavmr58af6b12019-09-18 15:33:25 +053080 exit 0
81elif [[ "$TEST" == "comprehensive" ]]; then
82 echo "Robot Framework Comprehensive Test"
yadavmrf21d9da2019-11-05 11:42:57 +053083 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"
yadavmr58af6b12019-09-18 15:33:25 +053089 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
yadavmrf21d9da2019-11-05 11:42:57 +0530102 robot --removekeywords tag:vim-setup --removekeywords WUKS -d $BASEDIR/reports -i comprehensive $BASEDIR/testsuite/
yadavmr58af6b12019-09-18 15:33:25 +0530103 exit 0
104else
105 echo "wrong test provided"
106 exit 1
107fi
108
109exit 1