Django unable to create multiple databases for test in circleci

Viewed 81

I have a Django project which uses 6 databases. For CI/CD, I am using CircleCI. I have written some unit test cases which works fine on my machine (local environment). But when I try to run it in the CircleCI environment, it fails. The reason of failing is Django creates only one database from the six (that also random i.e different one every time). I am not sure what I am doing wrong.

Here is the config, I am using for CircleCI

version: 2.1

orbs:
  python: circleci/python@0.2.1

jobs:
  test-job:
    docker:
      - image: circleci/python:3.8
        environment:
          DATABASE_URL: mysql://root@127.0.0.1:3306/db0
          DB1_DATABASE_URL: mysql://root@127.0.0.1:3306/db1
          DB2_DATABASE_URL: mysql://root@127.0.0.1:3306/db2
          DB3_DATABASE_URL: mysql://root@127.0.0.1:3306/db3
          DB4_DATABASE_URL: mysql://root@127.0.0.1:3306/db4
          DB5_DATABASE_URL: mysql://root@127.0.0.1:3306/db5
          ALLOWED_HOSTS: localhost
          CORS_ORIGIN_WHITELIST: http://localhost:8080
          CONN_MAX_AGE: 150
          DEBUG: False
          QRCODE_URL: http://test.com/
      - image: circleci/mysql:8.0.18
        command: [--default-authentication-plugin=mysql_native_password]
    environment:
      MYSQL_DATABASE: db0
    steps:
      - checkout
      - python/load-cache
      - python/install-deps
      - python/save-cache
      - run:
          command: python manage.py test
          name: Run Test

workflows:
  main:
    jobs:
      - test-job:
          filters:
            branches:
              only:
                - add_test_to_circleci


Any help would be highly appreciated. Thanks in advance!

0 Answers
Related