This repository has been archived by the owner on Nov 28, 2024. It is now read-only.
forked from fabric8-ui/fabric8-planner
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlocal_run_functional_tests.sh
executable file
·73 lines (62 loc) · 1.91 KB
/
local_run_functional_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
#!/usr/bin/env bash
LOGFILE=$(pwd)/functional_tests.log
echo Using logfile $LOGFILE
# For the functional tests, we are mocking the core
export NODE_ENV=inmemory
OS=$(uname -a | awk '{print $1;}')
# Download dependencies
echo -n Updating Webdriver and Selenium...
node_modules/protractor/bin/webdriver-manager update
# Start selenium server just for this test run
echo -n Starting Webdriver and Selenium...
(node_modules/protractor/bin/webdriver-manager start >>$LOGFILE 2>&1 &)
# Wait for port 4444 to be listening connections
if [ $OS = 'Darwin' ]
then
while ! (nc -w 1 127.0.0.1 4444 </dev/null >/dev/null 2>&1); do sleep 1; done
else
while ! (ncat -w 1 127.0.0.1 4444 </dev/null >/dev/null 2>&1); do sleep 1; done
fi
echo done.
# Start the web app
echo -n Starting Almighty development server...
(node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --progress --host 0.0.0.0 --port 8088 >>$LOGFILE 2>&1 &)
# Wait for port 8088 to be listening connections
if [ $OS = 'Darwin' ]
then
while ! (nc -w 1 127.0.0.1 8088 </dev/null >/dev/null 2>&1); do sleep 1; done
else
while ! (ncat -w 1 127.0.0.1 8088 </dev/null >/dev/null 2>&1); do sleep 1; done
fi
echo done.
# Retrieve index.html to trigger webpack to build the source
echo -n Building source...
# Wait for the build to finish (index.html is delivered)
curl http://localhost:8088/ -o /dev/null -s
echo done.
# Finally run protractor
echo Running tests...
if [ -z "$1" ]
then
node_modules/protractor/bin/protractor protractor.config.js
else
node_modules/protractor/bin/protractor protractor.config.js --suite $1
fi
TEST_RESULT=$?
# Cleanup webdriver-manager and web app processes
if [ $OS = 'Darwin' ]
then
kill -9 $(lsof -ti tcp:4444)
kill -9 $(lsof -ti tcp:8088)
else
fuser -k -n tcp 4444
fuser -k -n tcp 8088
fi
# Return test result
if [ $TEST_RESULT -eq 0 ]; then
echo 'Functional tests OK'
exit 0
else
echo 'Functional tests FAIL'
exit 1
fi