-
Notifications
You must be signed in to change notification settings - Fork 12
/
run_selenium_tests.sh
104 lines (90 loc) · 2.4 KB
/
run_selenium_tests.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
#!/bin/bash
# Run the selenium tests against local or remote bb2 in docker
#
echo_msg () {
echo "$(basename $0): $*"
}
display_usage() {
echo
echo "Usage:"
echo "------------------"
echo
echo "Syntax: run_selenium_tests.sh [-h|d] [LOCAL|STAGING|PROD|<bb2 server url>]"
echo
echo "Options:"
echo
echo "-h Print this Help."
echo
echo "Note, tests are in selenium debug mode (vnc view web UI interaction at http://localhost:5900)."
echo
echo "Examples:"
echo
echo "run_selenium_tests.sh http://localhost:4000/ (or LOCAL)"
echo
echo "run_selenium_tests.sh https://staging.bluebutton.cms.gov/ (or STAGING)"
echo
echo "run_selenium_tests.sh https://bluebutton.cms.gov/ (or PROD)"
echo
echo "<bb2 server url> default to STAGING (https://staging.bluebutton.cms.gov/)"
echo
echo
}
# main
echo_msg
echo_msg RUNNING SCRIPT: ${0}
echo_msg
# Set bash builtins for safety
set -e -u -o pipefail
export HOME_PAGE_URL="https://staging.bluebutton.cms.gov/"
while getopts "h" option; do
case $option in
h)
display_usage;
exit;;
\?)
display_usage;
exit;;
esac
done
if [[ -n ${1-''} ]]
then
case "$1" in
LOCAL)
export HOME_PAGE_URL="http://web:4000/"
;;
STAGING)
export HOME_PAGE_URL="https://staging.bluebutton.cms.gov/"
;;
PROD)
export HOME_PAGE_URL="https://bluebutton.cms.gov/"
;;
*)
if [[ $1 == 'http*' ]]
then
export HOME_PAGE_URL=$1
else
echo "Invalid argument: " $1
display_usage
exit 1
fi
;;
esac
fi
# Set SYSTEM
SYSTEM=$(uname -s)
echo "BB2 Site Static URL=" ${HOME_PAGE_URL}
# stop all before run selenium tests
docker-compose -f docker-compose.selenium.yml down --remove-orphans
if [[ ${HOME_PAGE_URL} == "http://web:4000/" ]]
then
echo "web server is a local instance...."
docker-compose -f docker-compose.selenium.yml --profile local-web up --abort-on-container-exit
else
echo "web server is a remote instance...."
docker-compose -f docker-compose.selenium.yml --profile remote-web up --abort-on-container-exit
fi
# Stop containers after use
echo_msg
echo_msg "Stopping containers..."
echo_msg
docker-compose -f docker-compose.selenium.yml stop