forked from DefectDojo/django-DefectDojo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dc-integration-tests.sh
executable file
·58 lines (52 loc) · 1.69 KB
/
dc-integration-tests.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
#!/usr/bin/env bash
unset TEST_CASE
bash ./docker/docker-compose-check.sh
if [[ $? -eq 1 ]]; then exit 1; fi
usage() {
echo
echo "This script helps with running integration tests."
echo
echo "Options:"
echo " --test-case -t {YOUR_FULLY_QUALIFIED_TEST_CASE}"
echo " --help -h - prints this dialogue."
echo
echo
echo "Example command:"
echo './dc-unittest.sh --test-case "Finding integration tests"'
}
while [[ $# -gt 0 ]]; do
case $1 in
-t|--test-case)
TEST_CASE="$2"
shift # past argument
shift # past value
;;
-h|--help)
usage
exit 0
;;
-*)
echo "Unknown option $1"
usage
exit 1
;;
*)
POSITIONAL_ARGS+=("$1") # save positional arg
shift # past argument
;;
esac
done
echo "Running docker compose unit tests with profile postgres-redis and test case $TEST_CASE ..."
# Compose V2 integrates compose functions into the Docker platform,
# continuing to support most of the previous docker-compose features
# and flags. You can run Compose V2 by replacing the hyphen (-) with
# a space, using docker compose, instead of docker-compose.
echo "Building images..."
./docker/setEnv.sh integration_tests
./dc-build.sh
echo "Setting up DefectDojo with Postgres and Redis..."
DD_INTEGRATION_TEST_FILENAME="$TEST_CASE" docker compose --no-deps -d postgres nginx celerybeat celeryworker mailhog uwsgi redis
echo "Initializing DefectDojo..."
DD_INTEGRATION_TEST_FILENAME="$TEST_CASE" docker compose --no-deps --exit-code-from initializer initializer
echo "Running the integration tests..."
DD_INTEGRATION_TEST_FILENAME="$TEST_CASE" docker compose --no-deps --exit-code-from integration-tests integration-tests