forked from SeleniumHQ/docker-selenium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.sh
executable file
·64 lines (51 loc) · 1.54 KB
/
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
#!/usr/bin/env bash
DEBUG=''
if [ -n "$1" ] && [ $1 == 'debug' ]; then
DEBUG='-debug'
fi
echo Building test container image
docker build -t selenium/test:local ./Test
echo 'Starting Selenium Hub Container...'
HUB=$(docker run -d selenium/hub:2.52.0)
HUB_NAME=$(docker inspect -f '{{ .Name }}' $HUB | sed s:/::)
echo 'Waiting for Hub to come online...'
docker logs -f $HUB &
sleep 2
echo 'Starting Selenium Chrome node...'
NODE_CHROME=$(docker run -d --link $HUB_NAME:hub selenium/node-chrome$DEBUG:2.52.0)
echo 'Starting Selenium Firefox node...'
NODE_FIREFOX=$(docker run -d --link $HUB_NAME:hub selenium/node-firefox$DEBUG:2.52.0)
docker logs -f $NODE_CHROME &
docker logs -f $NODE_FIREFOX &
echo 'Waiting for nodes to register and come online...'
sleep 2
function test_node {
BROWSER=$1
echo Running $BROWSER test...
TEST_CMD="node smoke-$BROWSER.js"
docker run -it --link $HUB_NAME:hub -e TEST_CMD="$TEST_CMD" selenium/test:local
STATUS=$?
TEST_CONTAINER=$(docker ps -aq | head -1)
if [ ! $STATUS == 0 ]; then
echo Failed
exit 1
fi
if [ ! "$CIRCLECI" == "true" ]; then
echo Removing the test container
docker rm $TEST_CONTAINER
fi
}
test_node chrome $DEBUG
test_node firefox $DEBUG
if [ ! "$CIRCLECI" == "true" ]; then
echo Tearing down Selenium Chrome Node container
docker stop $NODE_CHROME
docker rm $NODE_CHROME
echo Tearing down Selenium Firefox Node container
docker stop $NODE_FIREFOX
docker rm $NODE_FIREFOX
echo Tearing down Selenium Hub container
docker stop $HUB
docker rm $HUB
fi
echo Done