forked from red-hat-data-services/ods-ci
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_robot_test.sh
executable file
·109 lines (93 loc) · 2.75 KB
/
run_robot_test.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#/bin/bash
TEST_CASE_FILE=tests/Tests
TEST_VARIABLES_FILE=test-variables.yml
TEST_VARIABLES=""
TEST_ARTIFACT_DIR="test-output"
EXTRA_ROBOT_ARGS=""
SKIP_PIP_INSTALL=0
while [ "$#" -gt 0 ]; do
case $1 in
# Override/Add global variables specified in the test variables file
--test-variable)
shift
TEST_VARIABLES="${TEST_VARIABLES} --variable $1"
shift
;;
# Specify the test variable file
--test-variables-file)
shift
TEST_VARIABLES_FILE=$1
shift
;;
# Specify test case to run
--test-case)
shift
TEST_CASE_FILE=$1
shift
;;
# Specify directory to store artifacts and reports from each test run
--test-artifact-dir)
shift
TEST_ARTIFACT_DIR=$1
shift
;;
# Additional arguments to pass to the robot cli
--extra-robot-args)
shift
EXTRA_ROBOT_ARGS=$1
shift
;;
# Skip the pip install during the execution of this script
--skip-pip-install)
shift
SKIP_PIP_INSTALL=1
;;
*)
echo "Unknown command line switch: $1"
exit 1
;;
esac
done
if [[ ! -f "${TEST_VARIABLES_FILE}" ]]; then
echo "Robot Framework test variable file (test-variables.yml) is missing"
exit 1
fi
currentpath=`pwd`
case "$(uname -s)" in
Linux)
case "$(lsb_release --id --short)" in
"Fedora"|"CentOS")
## Bootstrap script to setup drivers ##
echo "setting driver to $currentpath/Drivers/fedora"
PATH=$PATH:$currentpath/drivers/fedora
export PATH=$PATH
echo $PATH
;;
"Ubuntu")
echo "Not yet supported, but shouldn't be hard for you to fix :) "
echo "Please add the driver, test and submit PR"
exit 1
;;
"openSUSE project"|"SUSE LINUX"|"openSUSE")
echo "Not yet supported, but shouldn't be hard for you to fix :) "
echo "Please add the driver, test and submit PR"
exit 1
;;
esac
#TODO: Make this optional so we are not creating/updating the virtualenv everytime we run a test
VENV_ROOT=${currentpath}/venv
#setup virtualenv
python3 -m venv ${VENV_ROOT}
source ${VENV_ROOT}/bin/activate
if [[ ${SKIP_PIP_INSTALL} -eq 0 ]]; then
${VENV_ROOT}/bin/pip install -r requirements.txt
fi
#Create a unique directory to store the output for current test run
if [[ ! -d "${TEST_ARTIFACT_DIR}" ]]; then
mkdir ${TEST_ARTIFACT_DIR}
fi
#TODO: Configure the "tmp_dir" creation so that we can have a "latest" link
TEST_ARTIFACT_DIR=$(mktemp -d -p ${TEST_ARTIFACT_DIR} -t ods-ci-$(date +%Y-%m-%d-%H-%M)-XXXXXXXXXX)
#run tests
./venv/bin/robot -d ${TEST_ARTIFACT_DIR} -x xunit_test_result.xml -r test_report.html ${TEST_VARIABLES} --variablefile ${TEST_VARIABLES_FILE} --exclude TBC ${EXTRA_ROBOT_ARGS} ${TEST_CASE_FILE}
esac