Monday, October 27, 2014

Re: TEST_MIRROR not working?

I ended up opening a ticket https://code.djangoproject.com/ticket/23718 after fining my testcase actually works against Django 1.3.7

On Sunday, October 26, 2014 10:23:08 PM UTC+3, Ilya Baryshev wrote:
>Ilya: Can you test if using TEST_MIRROR fixes the issue you are seeing?
Both settings have same effect.

I've slightly modified testcase to demonstrate replica queries are not the same as master queries (no fixtures):

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


======================================================================
FAIL: test_fixture (testapp.tests.TestMirror)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/prophet/work/forks/test_mirror/testmirror/testapp/tests.py", line 13, in test_fixture
    MyModel.objects.using('slave').count())
AssertionError: 3 != 2


On Sunday, October 26, 2014 4:21:06 PM UTC+3, Ramiro Morales wrote:

Actually, in 1.7.x both should work.

Ilya: Can you test if using TEST_MIRROR fixes the issue you are seeing?

On Oct 26, 2014 9:19 AM, "Tom Evans" <teva...@googlemail.com> wrote:
On Sat, Oct 25, 2014 at 5:21 PM, Ilya Baryshev <bary...@gmail.com> wrote:
> Hey all!
>
> I was writing tests for queries that use replica database, so I tried using
> TEST_MIRROR 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'

This should be 'TEST_MIRROR': 'default'

Cheers

Tom

--
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...@googlegroups.com.
To post to this group, send email to django...@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/CAFHbX1L%3DU95K4_XreTm%3D2aET3JRPCCeQL1773wgRZ_25eJX7gQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

--
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+unsubscribe@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/77232446-3df5-46bd-890e-e6a17ba38bbf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment