-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Expand file tree
/
Copy pathentrypoint-unit-tests-devDocker.sh
More file actions
executable file
·90 lines (61 loc) · 2.79 KB
/
Copy pathentrypoint-unit-tests-devDocker.sh
File metadata and controls
executable file
·90 lines (61 loc) · 2.79 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
90
#!/bin/bash
# Run available unittests with a setup for local dev:
# - Make migrations and apply any needed changes
# - Leave container up after running tests to allow debugging, rerunning tests, etc.
set -x
set -e
set -v
. /secret-file-loader.sh
. /reach_database.sh
cd /app
# Unset the database URL so that we can force the DD_TEST_DATABASE_NAME (see django "DATABASES" configuration in settings.dist.py)
unset DD_DATABASE_URL
# Unset the celery broker URL so that we can force the other DD_CELERY_BROKER settings
unset DD_CELERY_BROKER_URL
wait_for_database_to_be_reachable
python3 manage.py makemigrations --no-input --check --dry-run --verbosity 3 || {
cat <<-EOF
********************************************************************************
You made changes to the models without creating a DB migration for them.
**NEVER** change existing migrations, create a new one.
If you're not familiar with migrations in Django, please read the
great documentation thoroughly:
https://docs.djangoproject.com/en/5.0/topics/migrations/
********************************************************************************
EOF
exit 1
}
python3 manage.py migrate
# do the check with Django stack
python3 manage.py check
python3 manage.py spectacular --fail-on-warn > /dev/null || {
cat <<-EOF
********************************************************************************
You made changes to the REST API without applying the correct schema annotations
These schema annotations are needed to allow for the correct generation of
the OpenAPI (v3) schema's and documentation.
Review the warnings generated by drf-spectacular and see "dojo/api_v2/views.py"
and/or "dojo/api_v2/serializers.py".
You can check for warnings locally by running
python3 manage.py spectacular > /dev/null
This will output only warnings/errors, or nothing if everything is OK.
More info at: https://drf-spectacular.readthedocs.io/en/latest/customization.html
********************************************************************************
EOF
python3 manage.py spectacular > /dev/null
}
echo "Unit Tests"
echo "------------------------------------------------------------"
# Removing parallel and shuffle for now to maintain stability
python3 manage.py test unittests -v 3 --keepdb --no-input --exclude-tag="non-parallel" || {
exit 1;
}
python3 manage.py test unittests -v 3 --keepdb --no-input --tag="non-parallel" || {
exit 1;
}
# you can select a single file to "test" unit tests
# python3 manage.py test unittests.test_importers_performance.TestDojoImporterPerformance --keepdb -v 3 &> /app/dev2.log
# or even a single method
# python3 manage.py test unittests.tools.test_npm_audit_scan_parser.TestNpmAuditParser.test_npm_audit_parser_many_vuln_npm7 --keepdb -v 3
echo "End of tests. Leaving the container up"
tail -f /dev/null