Hi everyone,

I have raised few days ago an issue (
https://code.djangoproject.com/ticket/26822) I encountered when using
--keepdb and --parallel option.
I have proposed a patch (https://github.com/django/django/pull/6884), and
after some exchanged with Aymeric Augustin, I have been encouraged to post
to this list.

The context is the following:
- I run the first time the tests on my Django project (1.9.7) with --keepdb
and --parallel option.
- All databases are kept, everything is working as expected.
- I add a new field in a model, generate a new migration and add some tests
related to that field.
- I run again my tests with --keepdb and --parallel option: they are now
failing because this new field has not been created in cloned databases.

After some investigation, I have seen that, in case of keepdb context, in
django/db/backends/*/creation.py, if the cloned databases already exist, we
don't touch them, which leads to this new field not created in cloned ones.

I have proposed in the PR to rebuild the cloned databases, even with keepdb
option, to be sure that we always have the cloned databases with the latest
migration state.

The problem with this method is that it will increase test database
initialization time, as we will now systematically copy all cloned
databases, even with --keepdb option (except the default one).

We could have just documented this limitation, but I don't think that my
situation is a really rare edge case in terms of process, so I was
suggesting to add a new option to be able to reset the cloned databases if
needed (let's name it --parallel-clone-reset).

I don't really like the idea of adding a new option, as it impacts the test
runner, the clone_test_db function signature, ... but I have not found a
better idea to at the same time keep the performances with --keepdb and
--parallel, and handle these newly added migrations to a project.

To summarize my proposal, this option (--parallel-clone-reset, or any other
name) should be used only if you are using --keepdb and --parallel options
at the same time, and when you have added a new migration between 2 test
run.

I'm not sure my explanation was clear enough, but I would really like to
have your feedbacks about it.

Regards,

Romain Garrigues.

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/CAE_LG9y_FXz0Pva2Aa9FHebsqKvE8bbAs-gDgs-jdS6KS0wRkQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to