-
Notifications
You must be signed in to change notification settings - Fork 77
/
HWIMO-TEST
executable file
·72 lines (61 loc) · 1.98 KB
/
HWIMO-TEST
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
#!/bin/bash -e
# Copyright 2015, EMC, Inc.
checkDependencies(){
mongo_path=$( which mongod )
if [ -z "$mongo_path" ]; then
echo "[ERROR]: the unit test requires mongodb service installed"
exit 1
fi
rabbitmq_path=$( which rabbitmq-server )
if [ -z "$rabbitmq_path" ]; then
echo "[ERROR]: the unit test requires rabbitmq service installed"
exit 1
fi
# mongod works for version after 2.6
# mongodb works for version before 2.6
mongo_status=$(service mongodb status || service mongod status)
export is_mongo_running=$(echo $mongo_status | grep running)
export rabbitmq_status=$(sudo service rabbitmq-server status|grep pid)
}
cleanDatabase(){
mongo pxe --eval "db.dropDatabase()"
mongo monorail-test --eval "db.dropDatabase()"
}
handleDependServices(){
action=$1
if [ -z "$is_mongo_running" ]; then
echo "[INFO]: $action mongodb service"
sudo service mongodb $action || sudo service mongod $action
fi
if [ -z "$rabbitmq_status" ]; then
echo "[INFO]: $action rabbitmq service"
sudo service rabbitmq-server $action
fi
}
prepareDependencies(){
handleDependServices start
sleep 2
cleanDatabase
}
restoreDependencies(){
cleanDatabase
handleDependServices stop
}
build(){
rm -rf node_modules
./install-swagger-ui.sh
npm install
}
unitTest(){
# Checks the code against the jshint options
./node_modules/.bin/jshint -c .jshintrc --reporter=checkstyle lib index.js > checkstyle-result.xml || true
./node_modules/.bin/jshint -c .jshintrc lib index.js || true
# Runs the mocha tests and reports the code coverage.
./node_modules/.bin/istanbul cover -x "**/spec/**" ./node_modules/.bin/_mocha -- $(find spec -name '*-spec.js') --timeout 10000 -R xunit-file --require spec/helper.js
./node_modules/.bin/istanbul report cobertura
}
checkDependencies
prepareDependencies
trap restoreDependencies SIGINT SIGTERM SIGKILL EXIT
build
unitTest