-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathdpc-test.sh
More file actions
executable file
·89 lines (71 loc) · 3.49 KB
/
dpc-test.sh
File metadata and controls
executable file
·89 lines (71 loc) · 3.49 KB
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
#!/bin/bash
set -Ee
# Current working directory
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
# Configure the Maven log level
export MAVEN_OPTS=-Dorg.slf4j.simpleLogger.defaultLogLevel=info
# Include secure environment variables
set -o allexport
[[ -f ${DIR}/ops/config/decrypted/local.env ]] && source ${DIR}/ops/config/decrypted/local.env
set +o allexport
# Remove jacocoReport directory
if [ -d "${DIR}/jacocoReport" ]; then
rm -r "${DIR}/jacocoReport"
fi
# Create jacocoReport and make accessible for writing output from containers if we're running tests
if [ "$ENV" = 'local' ] || [ "$ENV" = 'github-ci' ]; then
mkdir -p "${DIR}"/jacocoReport/dpc-api
mkdir -p "${DIR}"/jacocoReport/dpc-attribution
mkdir -p "${DIR}"/jacocoReport/dpc-aggregation
chown -R nobody:nobody "${DIR}"/jacocoReport
fi
function _finally {
# don't shut it down if running on ci
if [ "$ENV" != 'github-ci' ]; then
echo "SHUTTING EVERYTHING DOWN"
docker compose -p start-v1-app down
docker volume rm start-v1-app_pgdata16
fi
}
trap _finally EXIT
if [ -n "$REPORT_COVERAGE" ]; then
echo "┌──────────────────────────────────────┐"
echo "│ │"
echo "│ Running Tests and Coverage │"
echo "│ │"
echo "└──────────────────────────────────────┘"
else
echo "┌──────────────────────────────────────────┐"
echo "│ │"
echo "│ Running Tests.... │"
echo "│ REPORT_COVERAGE not set │"
echo "│ │"
echo "└──────────────────────────────────────────┘"
fi
# Build the application
docker compose -p start-v1-app up db --wait
mvn -T 1.5C clean compile -Perror-prone -B -V -ntp
mvn -T 1.5C package -Pci -ntp
# Format the test results
if [ -n "$REPORT_COVERAGE" ]; then
mvn jacoco:report -ntp
fi
docker compose -p start-v1-app down
USE_BFD_MOCK=true docker compose -p start-v1-app up db attribution aggregation --wait
# Run the integration tests
USE_BFD_MOCK=true docker compose -p start-v1-app up --exit-code-from tests tests
echo "Starting api server for end-to-end tests"
USE_BFD_MOCK=true docker compose -p start-v1-app up api --wait
echo "Starting end-to-end tests"
docker run --rm -v $(pwd)/dpc-load-testing:/src --env-file $(pwd)/ops/config/decrypted/local.env --add-host host.docker.internal=host-gateway -e ENVIRONMENT=local -i grafana/k6 run /src/ci-app.js
# Wait for Jacoco to finish writing the output files
docker compose -p start-v1-app down -t 60
# Collect the coverage reports for the Docker integration tests
if [ -n "$REPORT_COVERAGE" ]; then
mvn jacoco:report-integration -Pci -ntp
fi
echo "┌──────────────────────────────────────────┐"
echo "│ │"
echo "│ All Tests Complete │"
echo "│ │"
echo "└──────────────────────────────────────────┘"