-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_tests
executable file
·69 lines (55 loc) · 1.84 KB
/
run_tests
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
#!/bin/bash
export COMPOSE_CONVERT_WINDOWS_PATHS=1
DIR=$(git rev-parse --show-toplevel)
cd $DIR
source "$DIR/devops/packaging/functions.sh"
# q.v. http://stackoverflow.com/a/24067243/1732954
function is_minimum_version () {
[[ "$1" == "$2" ]] && return 0
[[ "$(printf '%s\n' "$@" | sort -V | head -n 1)" != "$1" ]]
}
# Validate the docker-compose version >= 1.9.0 on Windows so that the
# "docker-compose run" works.
min_dc_version="1.9.0"
# Assumption: will get "docker-compose version 1.9.0, build 2585387"
dc_version=$(docker-compose --version | cut -f1 -d, | cut -f 3 -d' ')
if ! is_minimum_version $dc_version $min_dc_version; then
>&2 echo "$dc_version is not at least ${min_dc_version}"
exit 1
fi
function launch-datastores() {
# This is idempotent, so it is safe to do every time
docker-compose up -d datastores
# TODO: Add waits to ensure that the databases are ready to take traffic.
}
if [[ "$@" == "stop" ]]; then
echo "Stopping docker containers ..."
docker-compose down
echo ""
echo "Cleanup dangling volumes ..."
docker volume rm $(docker volume ls -qf dangling=true)
echo ""
echo "Ok"
elif [[ "$@" == "bash" ]]; then
launch-datastores
docker-compose run code bash
elif [[ "$@" == "build" ]]; then
cleanup-line-endings
build-base
docker-compose build
else
# This order is so that we can launch the databases and let them live beyond
# any given test run.
launch-datastores
# TODO: Verify the minimum amount of RAM is available
# - Cannot use 'docker-machine inspect' because that shows the configuration,
# not the actual as set by devops/scripts/update-docker-machine.sh
if [[ "$1" == "integration" ]]; then
shift
docker-compose run --entrypoint bash integration prove $@
elif [[ "$@" == "cover" ]]; then
docker-compose run code cover
else
docker-compose run code prove $@
fi
fi