forked from mozilla-services/socorro
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.sh
executable file
·65 lines (48 loc) · 1.56 KB
/
test.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
#!/bin/bash
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
# Usage: bin/test.sh
#
# Runs tests.
#
# Note: This should be called from inside a container.
set -euxo pipefail
echo ">>> set up environment"
# Set up environment variables
DATABASE_URL="${DATABASE_URL:-}"
SENTRY_DSN="${SENTRY_DSN:-}"
ELASTICSEARCH_URL="${ELASTICSEARCH_URL:-}"
LOCAL_DEV_AWS_ENDPOINT_URL="${LOCAL_DEV_AWS_ENDPOINT_URL:-}"
export PYTHONPATH=/app/:$PYTHONPATH
PYTEST="$(which pytest)"
PYTHON="$(which python)"
echo ">>> wait for services to be ready"
urlwait "${DATABASE_URL}"
urlwait "${ELASTICSEARCH_URL}"
urlwait "http://${PUBSUB_EMULATOR_HOST}" 10
urlwait "${STORAGE_EMULATOR_HOST}/storage/v1/b" 10
python ./bin/waitfor.py --verbose --codes=200,404 "${SENTRY_DSN}"
python ./bin/waitfor.py --timeout 20 --verbose "${LOCAL_DEV_AWS_ENDPOINT_URL}"
echo ">>> build sqs things and db things"
# Clear SQS for tests
./socorro-cmd sqs delete-all
# Clear Pub/Sub for tests
./socorro-cmd pubsub delete-all
# Set up socorro_test db
./socorro-cmd db drop || true
./socorro-cmd db create
pushd webapp
${PYTHON} manage.py migrate
popd
echo ">>> run tests"
# Run socorro tests
"${PYTEST}"
CLOUD_PROVIDER=GCP "${PYTEST}" -m gcp
# Collect static and then run pytest in the webapp
pushd webapp
${PYTHON} manage.py collectstatic --noinput
"${PYTEST}"
# default cloud provider is aws, now configure gcp and run only impacted tests
CLOUD_PROVIDER=GCP "${PYTEST}" -m gcp
popd