hey
We are testing our django application in circleci. Our migrations take a while to load and migrate, so we are wondering if one can reuse an existing database?
Our setup looks like this:
version: 2.1
orbs:
python: circleci/python@1.5.0
browser-tools: circleci/browser-tools@1.2.4
executors:
backend:
docker:
- image: cimg/python:3.9.9-browsers
environment:
DATABASE_URL: postgresql://ubuntu@localhost/circle_test
- image: postgres:12.9-alpine
environment:
POSTGRES_USER: ubuntu
POSTGRES_DB: circle_test
POSTGRES_HOST_AUTH_METHOD: trust
workflows:
version: 2
build:
jobs:
- build_backend_and_test:
filters:
branches:
ignore: /^master$/
jobs:
build_backend_and_test:
executor: backend
resource_class: large
steps:
- checkout
- browser-tools/install-chrome
- browser-tools/install-chromedriver
- python/install-packages:
pkg-manager: pip
pip-dependency-file: requirements-dev.txt
pypi-cache: true
cache-version: venv-v3.9-{{ checksum "requirements-dev.txt" }}
- run:
name: "Check that no model changes are missing migrations"
command: |
./manage.py makemigrations --check
- run:
name: "Backend tests"
command: |
./manage.py test --parallel 4 --exclude-tag=functional --timing --verbosity 3 --noinput
MARKET=other_market ./manage.py test --parallel 4 --tag other_market --exclude-tag=functional --timing --verbosity 3
- restore_cache:
key: "this restores frontend files which are needed for the selenium tests"
- run:
name: "Functional tests"
command: |
./manage.py test --parallel 2 --tag functional --verbosity 3
MARKET=other_market ./manage.py test web_ui.functional_tests --parallel 2 --tag other_market --verbosity 3
- store_artifacts:
path: /tmp/artifacts
- store_artifacts:
path: test-results
- store_test_results:
path: test-results
Now this config works, but as you can see, we are running backend tests with ./manage.py test --parallel 4 --exclude-tag=functional --timing --verbosity 3 --noinput
which already creates a database which the correct name. However, when running the functional tests, we dont want tot create the database again, but reuse the existing one. --keepdb
sadly doesnt work.
any ideas?