openwisp / openwisp/openwisp-utils

[qa] Use a separate database for migration checks

Open
#186 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement Hacktoberfest
Dominant language
Python
Stars
93
Forks
104
Avg merge
14h 10m
Merged PRs (30d)
22

Description

Performing migration checks on user's database sometimes leads to tests failing for sample app of the module.

Here is an example of running migration checks on openwisp-controller

$ SAMPLE_APP=1 openwisp-qa-check \
SAMPLE_APP=1 openwisp-qa-check \
>   --migration-path "./tests/openwisp2/sample_config/migrations/
>                     ./tests/openwisp2/sample_pki/migrations/
>                     ./tests/openwisp2/sample_connection/migrations/
>                     ./tests/openwisp2/sample_geo/migrations/"
SUCCESS: Blank endline check successful!
SUCCESS: Migration name check on "./tests/openwisp2/sample_config/migrations/" with migrations-to-ignore: 0 successful!
SUCCESS: Migration name check on "./tests/openwisp2/sample_pki/migrations/" with migrations-to-ignore: 0 successful!
SUCCESS: Migration name check on "./tests/openwisp2/sample_connection/migrations/" with migrations-to-ignore: 0 successful!
SUCCESS: Migration name check on "./tests/openwisp2/sample_geo/migrations/" with migrations-to-ignore: 0 successful!
SUCCESS: Isort check successful!
SUCCESS: Black check successful!
SUCCESS: Flake8 check successful!
SUCCESS: ReStructuredText check successful!
SUCCESS: Commit message check successful!
Traceback (most recent call last):
  File "tests/manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/home/pandafy/openwisp/venv-controller/lib/python3.8/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
    utility.execute()
  File "/home/pandafy/openwisp/venv-controller/lib/python3.8/site-packages/django/core/management/__init__.py", line 375, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/pandafy/openwisp/venv-controller/lib/python3.8/site-packages/django/core/management/base.py", line 323, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/pandafy/openwisp/venv-controller/lib/python3.8/site-packages/django/core/management/base.py", line 364, in execute
    output = self.handle(*args, **options)
  File "/home/pandafy/openwisp/venv-controller/lib/python3.8/site-packages/django/core/management/base.py", line 83, in wrapped
    res = handle_func(*args, **kwargs)
  File "/home/pandafy/openwisp/venv-controller/lib/python3.8/site-packages/django/core/management/commands/makemigrations.py", line 101, in handle
    loader.check_consistent_history(connection)
  File "/home/pandafy/openwisp/venv-controller/lib/python3.8/site-packages/django/db/migrations/loader.py", line 295, in check_consistent_history
    raise InconsistentMigrationHistory(
django.db.migrations.exceptions.InconsistentMigrationHistory: Migration account.0001_initial is applied before its dependency sample_users.0001_initial on database 'default'.

We should check if we can use an in-memory database for performing these checks

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the openwisp-qa-check migration-check flow and the tests/manage.py entry point, using the sample migration paths in the report as a reproduction. Confirm how the check currently connects to the user's database and define a separate database for its checks; done means the sample app check no longer fails because of the user's migration history.

Written by the indexing model from the issue text.

Assessment

Tech stack
django, python
Domain
databases, testing-qa, tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.