Proposal: testdb cached by hash on migrations dirs

49 views
Skip to first unread message

Andrew Farrell

unread,
Apr 17, 2015, 6:04:00 PM4/17/15
to django-d...@googlegroups.com
Hi Folks,

I've been working on speeding up a django-1.7 applications unit tests to encourage developers to write more of them. Currently, django's strategy for ensuring that its database is fresh for each test run is to create a new test database and run all of the migrations on it. I've noticed that the bulk of the time is spent on spinning up the test database. This was also the case in a previous project that I worked on that ran django-1.4.

I recently had an idea: why not, after running the migrations on the newly-spun-up database, store a representation of that database somewhere that could be more quickly loaded? I suspect this would be particularly useful for an in-memory test database like sqlite, especially if someone was using a tool likewatchdog to automatically run their tests each time they changed one of their applications' files. This cache could be accompanied by a hash of all of the migrations that needed to be run and would only need to change when one of the applications listed in settings.INSTALLED_APPS had a change to its migrations.

This is of course going to be running up against one of the 2 hard things in computer science: cache invalidation. So, I wanted to get y'alls opinions on whether this was worth attempting.

cheers,
Andrew

Tim Graham

unread,
Apr 17, 2015, 6:19:58 PM4/17/15
to django-d...@googlegroups.com
You might like to know about the --keepdb option in Django 1.8: https://docs.djangoproject.com/en/1.8/ref/django-admin/#django-admin-option---keepdb

Andrew Farrell

unread,
Apr 18, 2015, 2:39:39 PM4/18/15
to django-d...@googlegroups.com
Ah, thank you. 
It seems I should have read that part of the release notes more closely.
Also, thank you to Greg Chapple for his work on that.

--
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-develop...@googlegroups.com.
To post to this group, send email to django-d...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/527efd9a-e12f-42e4-93ca-1920b7bef43c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages