forked from SeleniumHQ/docker-selenium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.sh
executable file
·95 lines (80 loc) · 2.47 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
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
#!/usr/bin/env bash
DEBUG=''
VERSION=${VERSION:-3.4.0-actinium}
if [ -n "$1" ] && [ $1 == 'debug' ]; then
DEBUG='-debug'
fi
# Due to the dependency GNU sed, we're skipping this part when running
# on Mac OS X.
if [ "$(uname)" != 'Darwin' ] ; then
echo 'Testing shell functions...'
which bats > /dev/null 2>&1
if [ $? -ne 0 ] ; then
echo "Could not find 'bats'. Please install it first, e.g., following https://github.com/sstephenson/bats#installing-bats-from-source."
exit 1
fi
NodeBase/test-functions.sh || exit 1
else
echo 'Skipping shell functions test on Mac OS X.'
fi
echo Building test container image
docker build -t selenium/test:local ./Test
echo 'Starting Selenium Hub Container...'
HUB=$(docker run -d selenium/hub:3.4.0-actinium)
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:${VERSION})
echo 'Starting Selenium Firefox node...'
NODE_FIREFOX=$(docker run -d --link $HUB_NAME:hub selenium/node-firefox$DEBUG:${VERSION})
if [ -z $DEBUG ]; then
echo 'Starting Selenium PhantomJS node...'
NODE_PHANTOMJS=$(docker run -d --link $HUB_NAME:hub selenium/node-phantomjs:${VERSION})
fi
docker logs -f $NODE_CHROME &
docker logs -f $NODE_FIREFOX &
if [ -z $DEBUG ]; then
docker logs -f $NODE_PHANTOMJS &
fi
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 [ ! "${TRAVIS}" == "true" ]; then
echo Removing the test container
docker rm $TEST_CONTAINER
fi
}
test_node chrome $DEBUG
test_node firefox $DEBUG
if [ -z $DEBUG ]; then
test_node phantomjs $DEBUG
fi
if [ ! "${TRAVIS}" == "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
if [ -z $DEBUG ]; then
echo Tearing down Selenium PhantomJS Node container
docker stop $NODE_PHANTOMJS
docker rm $NODE_PHANTOMJS
fi
echo Tearing down Selenium Hub container
docker stop $HUB
docker rm $HUB
fi
echo Done