-
Notifications
You must be signed in to change notification settings - Fork 0
/
development.sh
executable file
·143 lines (111 loc) · 2.65 KB
/
development.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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#!/bin/bash
set -euo pipefail
# allow running from any working directory
WD=$(dirname "$0")
cd "${WD}"
DOCKER_COMPOSE_CMD="docker compose -f ./docker/docker-compose.yml"
function start_prod_database {
$DOCKER_COMPOSE_CMD up --build -d jore4-mapmatchingdb
}
function start_dev_database {
$DOCKER_COMPOSE_CMD up --build -d jore4-mapmatchingdevdb
}
function start_test_database {
$DOCKER_COMPOSE_CMD up --build -d jore4-mapmatchingtestdb
}
function start_prod_database_blocking {
start_prod_database
while ! pg_isready -h localhost -p 19000
do
echo "waiting for pre-populated database to spin up"
sleep 2;
done
}
function start_test_database_blocking {
start_test_database
while ! pg_isready -h localhost -p 20000
do
echo "waiting for test database to spin up"
sleep 2;
done
}
function start {
start_prod_database_blocking
$DOCKER_COMPOSE_CMD up --build -d jore4-mapmatching
}
function start_dev {
start_dev_database
# pre-populated database (same data as in production) is used in integration tests
start_prod_database_blocking
start_test_database_blocking
cd "${WD}/spring-boot" && mvn clean spring-boot:run
}
function run_tests {
# pre-populated database (same data as in production) is used in integration tests
start_prod_database_blocking
start_test_database_blocking
cd "${WD}/spring-boot" && mvn clean verify
}
function stop_all {
$DOCKER_COMPOSE_CMD stop
}
function remove_all {
$DOCKER_COMPOSE_CMD down
}
function generate_jooq() {
cd ./spring-boot
mvn clean process-resources
}
function usage {
echo "
Usage $0 <command>
start
Start pre-populated database (same data as in production) and map-matching service in Docker container
start:dev
Start all databases (development, test, pre-populated) in Docker containers and the app locally via Maven (using 'dev' profile)
start:devdeps
Start all databases (development, test, pre-populated) to be used while developing the application
test
Run JUnit tests via Maven using 'dev' profile. Start pre-populated & test database if not already up.
stop
Stop all map-matching related Docker containers
remove
Stop and remove all map-matching related Docker containers
generate:jooq
Generate jOOQ classes using test database as dependency
help
Show this usage information
"
}
case $1 in
start)
start
;;
start:dev)
start_dev
;;
start:devdeps)
start_dev_database
start_test_database_blocking
start_prod_database_blocking
;;
stop)
stop_all
;;
remove)
remove_all
;;
test)
run_tests
;;
generate:jooq)
start_test_database_blocking
generate_jooq
;;
help)
usage
;;
*)
usage
;;
esac