Hey all!

I was writing tests for queries that use replica database, so I tried using 
TEST_MIRROR 
<https://docs.djangoproject.com/en/1.7/topics/testing/advanced/#testing-master-slave-configurations>
 
setting.
TEST_MIRROR promises "connection to slave will be redirected to point at 
default. 
As a result, writes to default will appear on slave". Which happens not to 
be the case for me,
replica queries are not returning expected results.

Is this a bug, or am I missing something?

Here is my example settings:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'testmirror',
        'HOST': '127.0.0.1',
        'PORT': 5432,
    },
    'slave': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'testmirror2',
        'HOST': '127.0.0.1',
        'PORT': 5432,
        'TEST': {
            'MIRROR': 'default'
        }
    }
}

And test that show replica doesn't have same data:

    def test_fixture(self):
        MyModel.objects.create(name=1)
        self.assertEqual(MyModel.objects.using('default').count(),
                         MyModel.objects.using('slave').count())

Example project in github: https://github.com/coagulant/test_mirror
My case can be repeated by simply running python manage.py test

I'm using

Django==1.7.1
psycopg2==2.5.4

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a2b703df-3863-425d-871d-ceebe34c2625%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to