-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathci.sh
executable file
·119 lines (95 loc) · 3.26 KB
/
ci.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#!/usr/bin/env bash
#
# Execute the integration test suite in a Continuous Integration environment
#
# Option:
# --all: execute the full suite of tests, including slow tests such as Chaos testing
#
set -o pipefail # trace ERR through pipes
set -o errtrace # trace ERR through 'time command' and other functions
set -o errexit ## set -e : exit the script if any statement returns a non-true return value
# This script is used for publish and continuous integration.
get_script_dir () {
SOURCE="${BASH_SOURCE[0]}"
while [[ -h "$SOURCE" ]]; do
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
SOURCE="$( readlink "$SOURCE" )"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE"
done
cd -P "$( dirname "$SOURCE" )"
pwd
}
cd "$(get_script_dir)"
for param in "$@"
do
if [[ "--all" == "$param" ]]; then
test_args=""
echo "INFO: ---all option detected !"
fi
done
if pgrep -lf sshuttle > /dev/null ; then
echo "sshuttle detected. Please close this program as it messes with networking and prevents Docker links to work"
exit 1
fi
if [[ $NO_SUDO || -n "$CIRCLECI" ]]; then
DOCKER_COMPOSE="docker-compose --project-name webanalyticsstarter -f docker-compose-ci.yml"
elif groups "$USER" | grep &>/dev/null '\bdocker\b'; then
DOCKER_COMPOSE="docker-compose --project-name webanalyticsstarter -f docker-compose-ci.yml"
else
DOCKER_COMPOSE="sudo docker-compose --project-name webanalyticsstarter -f docker-compose-ci.yml"
fi
function _cleanup() {
local error_code="$?"
echo "Stopping the containers..."
$DOCKER_COMPOSE stop | true
$DOCKER_COMPOSE down | true
$DOCKER_COMPOSE rm -f > /dev/null 2> /dev/null | true
exit $error_code
}
trap _cleanup EXIT INT TERM
echo "Remove old running containers (if any)..."
$DOCKER_COMPOSE kill
$DOCKER_COMPOSE rm -f
echo "Deploy a Postgres server and wait for it to be ready..."
$DOCKER_COMPOSE up -d db zookeeper
$DOCKER_COMPOSE run wait_zookeeper
$DOCKER_COMPOSE up -d mesos_master
$DOCKER_COMPOSE run wait_mesos_master
$DOCKER_COMPOSE up -d mesos_slave
$DOCKER_COMPOSE run wait_dbs
echo "Create databases..."
$DOCKER_COMPOSE run create_dbs
echo "Migrate woken database..."
$DOCKER_COMPOSE run woken_db_setup
echo "Migrate metadata database..."
$DOCKER_COMPOSE run sample_meta_db_setup
echo "Migrate features database..."
$DOCKER_COMPOSE run sample_data_db_setup
echo "Run containers..."
for i in 1 2 3 4 5 ; do
$DOCKER_COMPOSE up -d chronos
$DOCKER_COMPOSE run wait_chronos
$DOCKER_COMPOSE logs chronos | grep java.util.concurrent.TimeoutException || break
echo "Chronos failed to start, restarting..."
$DOCKER_COMPOSE stop chronos
done
$DOCKER_COMPOSE up -d woken
$DOCKER_COMPOSE run wait_woken
$DOCKER_COMPOSE up -d wokenvalidation
$DOCKER_COMPOSE run wait_wokenvalidation
for i in 1 2 3 4 5 ; do
$DOCKER_COMPOSE logs chronos | grep java.util.concurrent.TimeoutException || break
echo "Chronos failed to start, restarting..."
$DOCKER_COMPOSE stop chronos
$DOCKER_COMPOSE up -d chronos
$DOCKER_COMPOSE run wait_chronos
done
echo "The Algorithm Factory is now running on your system"
FRONTEND_URL=http://frontend \
$DOCKER_COMPOSE up -d portalbackend
$DOCKER_COMPOSE run wait_portal_backend
$DOCKER_COMPOSE up -d frontend
echo "[OK] System startup success!"
echo
# Cleanup
_cleanup