On Jan 20, 5:54 am, David Cramer <dcra...@gmail.com> wrote:
> So a few things we've done to take our test suite from 45 minutes to
> 12:
>
> 1. Implement global fixtures
>
> These get loaded after syncing just like initial data. Obviously this
> is a massive speed up
> as you only reload them in between transaction test cases.

I would really like to push global fixtures forward, and in a way that
would be usable for transactional test cases. The reason is that these
would be really, really useful for LiveServer tests (that is, selenium
tests). The tests which are read-only would be really fast in this
way, while tests that do alter data would be still safe to use.

What would be needed for this? First, of course some API for loading
the global fixtures (maybe post_syncdb could be used for this?) And
then, some way of only flushing the changed models. For change
tracking, pre/post save + m2m_changed signals could be used. Except
they do not match all the cases, bulk_create doesn't send any signals,
and I think .update() doesn't send any signals either. So, a new
signal, model_changed() would be needed, maybe with an
API .model_changed(instances=iterable, action='update/save/bulk_create/
delete/...'). This signal would be useful for cache flushing and
reindexing (Haystack comes in mind here).

I would need to test what speed difference this would make for the
LiveServer test cases I have. I think for my use case, nearly an order
of magnitude speedup could be possible. This is because I load a lot
of "codes" data into the DB.

The sad thing about database state tracking is that it is complex and
prone to errors. Worse, the errors might be hard to track. As said
before, this might be best done as an external project, with the
needed hooks implemented into Django core. The needed changes would be
flush only changed database data and "model_changed" signal or some
other way of tracking state changes. If this proves successful, then
include it into Django core.

 - Anssi

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com.
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en.

Reply via email to