-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestBrowser
More file actions
274 lines (252 loc) · 8.23 KB
/
testBrowser
File metadata and controls
274 lines (252 loc) · 8.23 KB
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
#!/bin/bash
set -bEu -o pipefail
# Christopher Lee
# "smoke tests" a gbib or gbic Genome Browser with a Selenium Script
# If gbic option is passed, installs a Genome Browser mirror and
# runs a Selenium script against it
# Global vars
pyloc="/Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5"
machine=""
machines=""
loc=""
urlStub="http://127.0.0.1:808"
urlList=()
function testUrl ()
{
curl $1 &> /dev/null
}
# runs vagrant commands to setup all or specific machines
function setupVMs ()
{
if [ $machine == "all" ]; then
vagrant up # with no machine name this starts all machines defined in Vagrantfile
for num in 0 1 2 3; do
urlList[${num}]="${urlStub}${num}"
done
echo ${urlList[@]}
elif [ $machine == "ubuntu" ]; then
vagrant up ubuntu14
vagrant up ubuntu16
urlList=("${urlStub}0" "${urlStub}1")
echo ${urlList[@]}
elif [ $machine == "centos" ]; then
vagrant up centos6
vagrant up centos7
urlList=("${urlStub}2" "${urlStub}3")
echo ${urlList[@]}
fi
}
# installs Genome Browser on specific machine
function installBrowser ()
{
# this works because browserSetup.sh is already present on the machine
# via sync defined in the Vagrantfile
if [ $machine == "all" ]; then
machines=("ubuntu14" "ubuntu16" "centos6" "centos7")
for mach in "${machines[@]}"; do
vagrant ssh $mach -- sudo bash browserSetup.sh -b install
done
elif [ $machine == "ubuntu" ]; then
machines=("ubuntu14" "ubuntu16")
for mach in "${machines[@]}"; do
vagrant ssh $mach -- sudo bash browserSetup.sh -b install
done
elif [ $machine == "centos" ]; then
machines=("centos6" "centos7")
for mach in "${machines[@]}"; do
vagrant ssh $mach -- sudo bash browserSetup.sh -b install
done
fi
}
function tearDownVMs ()
{
vagrant destroy -f
}
function mirrorOffline ()
{
vagrant ssh $mach -- sudo bash browserSetup.sh -o
}
function testOfflineMirror ()
{
# put in some offline specific testing, like making sure nothing loads when no assembly mirrored
# after mirroring a small assembly, click into hgTracks
# This test will take significantly longer since an assembly will be mirrored
echo "Testing an offline mirror. These tests can take a while"
echo ${machines[@]}
exit 0
}
function gbibOffline ()
{
sshpass -f .gbibpassword ssh browser@localhost -p 1235 "bash -ic gbibOffline" 2>&1 | grep -v "bash"
}
function gbibOnline ()
{
sshpass -f .gbibpassword ssh browser@localhost -p 1235 "bash -ic gbibOnline" 2>&1 | grep -v "bash"
}
function testOfflineGbib ()
{
# test mirroring a track
# run a show tables hg19 and look for altLocations to be null
# go to hgTracks and make sure no altLocations track
# use hgMirror to download altLocations
# altLocations should show up for hgTracks chr17
tbl=`sshpass -f .gbibpassword ssh browser@localhost -p 1235 'mysql -Ne "show tables \
like \"altLocations\"" hg19' 2>&1`
if [[ "$tbl" =~ altLocations ]]; then
# altLocations already exists abort
echo "this gbib already contains downloaded tables, try again"
exit 1
else
$pyloc genomeTest.py http://127.0.0.1:1234 offline
if [ $? -eq 0 ]; then
echo "selenium offline tests ran correctly"
tbl=`sshpass -f .gbibpassword ssh browser@localhost -p 1235 'mysql -Ne "show tables \
like \"altLocations\"" hg19' 2>&1`
if [[ "$tbl" =~ altLocations ]]; then
echo "altLocations table successfully downloaded, removing so test can be rerun if needed"
sshpass -f .gbibpassword ssh browser@localhost -p 1235 'mysql -e "drop table altLocations" hg19' 2>&1
fi
else
echo "selenium offline test didn't run successfully"
exit 1
fi
fi
}
function shutDownGbib ()
{
if [[ $(VBoxManage list runningvms) =~ browserbox ]]; then
echo "shutting off gbib because of ctrl-c"
VBoxManage controlvm browserbox poweroff
exit 1
fi
}
function showHelp ()
{
cat << EOF
Usage: $0 [-h] -w [gbic|gbib] -m [ubuntu|centos|all]
-h Show this help and exit
-w website Test which instance of the Genome Browser we are testing.
gbib uses the url http://127.0.0.1:1234
gbic uses the -m parameter to find url
-m machine Which machine to test. By default tests all machines:
Ubuntu 14/16
Centos 6/7
If "ubuntu" or "centos" is given we test both machines of that type.
Only applicable if -w gbic is supplied.
Performs basic automated test of Genome Browser instance:
Loads hgTracks and click into hgGene for Human and Mouse.
Loads an hg19 custom track and checks that hgTracks loads.
Loads a track hub and checks that hgTracks loads.
Runs a blat against hg19.
Runs an isPCR against hg19.
Tests hgConvert and hgLiftOver.
These tests should run reasonably quickly so you can watch that they are running
and completing correcly.
EOF
}
# parse command line
OPTIND=1
while getopts "hw:m:" opt
do
case $opt in
h)
showHelp
exit 0
;;
w)
loc=$OPTARG
;;
m)
machine=$OPTARG
;;
'?')
showHelp >&2
exit 1
;;
esac
done
if [ $OPTIND -eq 1 ]; then
showHelp >&2
exit 1
fi
### MAIN ###
# parse command line for errors and set machines var
if [ "$loc" != "gbib" -a "$loc" != "gbic" ]; then
echo "Wrong -w option. Please use either \"gbib\" or \"gbic\"."
showHelp >&2
exit 1
fi
if [ "$loc" == "gbic" -a "$machine" != "ubuntu" -a "$machine" != "centos" -a "$machine" != "all" ]; then
echo "Wrong machine name specified. Please use either \"all\" \"ubuntu\" or \"centos\"."
showHelp >&2
exit 1
fi
if [ $loc == "gbib" ]; then
# gbib already on for some other purpose
testUrl "http://127.0.0.1:1234"
if [ $? -eq 0 ]; then
echo "gbib already running, starting tests"
# first make sure we can run online test:
gbibOnline
$pyloc genomeTest.py http://127.0.0.1:1234
gbibOffline
testOfflineGbib
gbibOnline
# if gbib was already on we shouldn't turn it off
#VBoxManage controlvm browserbox poweroff
else
trap shutDownGbib SIGINT
# gbib is powered off
if [[ $(VBoxManage list vms) =~ browserbox ]]; then
echo "starting up gbib"
VBoxManage guestproperty set browserbox gbibAutoUpdateOff yes
VBoxManage startvm browserbox --type=headless
else # fresh gbib download
echo "Test of newly downloaded gbib"
wget http://hgwdev.soe.ucsc.edu/gbib/gbib.zip
ditto -xk `pwd`/gbib.zip gbib
VBoxManage registervm `pwd`/gbib/browserbox.vbox
VBoxManage sharedfolder add "browserbox" --name "testHub" --hostpath "`pwd`/testHub" --readonly --automount
VBoxManage guestproperty set browserbox gbibAutoUpdateOff yes
VBoxManage startvm browserbox --type=headless
fi
while true; do
# just wait for gbib to get running
testUrl http://127.0.0.1:1234
if [ $? -eq 0 ]; then
$pyloc genomeTest.py http://127.0.0.1:1234
# offline testing stub
# run a show tables hg19 and look for altLocations to be null
# go to hgTracks and make sure no altLocations track
# use hgMirror to download altLocations
# altLocations should show up for hgTracks chr17
gbibOffline
testOfflineGbib
gbibOnline
VBoxManage controlvm browserbox poweroff
break
fi
done
fi
exit 0
elif [ $loc == "gbic" ]; then # currently for testing purposes
trap tearDownVMs SIGINT
setupVMs
installBrowser
if [ $? -eq 0 ]; then # browser install didn't fail
for url in "${urlList[@]}"; do
testUrl $url
if [ $? -eq 0 ]; then
$pyloc genomeTest.py $url
# offline testing stub
echo
else
echo "$url does not have a browser installed yet. Install one first"
exit 1
fi
done
else
echo "install failed. login to VM and run install with bash -x to see what happened"
exit 1
fi
fi