Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Start mocking elasticsearch earlier, before loading django fixtures #10656

Merged
merged 1 commit into from Feb 11, 2019

Conversation

@diox
Copy link
Member

commented Feb 11, 2019

We were mocking es using a pytest autouse fixture, which are apparently called too late, after the loading of django fixtures. This was causing useless index calls, possibly slowing down the tests
slightly.

Fix #10655

Start mocking elasticsearch earlier, before loading django fixtures
We were mocking es using a pytest autouse fixture, which are
apparently called too late, after the loading of django fixtures.
This was causing useless index calls, possibly slowing down the tests
slightly.
@EnTeQuAk
Copy link
Member

left a comment

lgtm if travis agrees

"""Base class for all amo tests."""
client_class = TestClient

def _pre_setup(self):
super(TestCase, self)._pre_setup()
self.client = self.client_class()

This comment has been minimized.

Copy link
@diox

diox Feb 11, 2019

Author Member

Actually... we probably don't need that, that's what django does already...

# Before starting to mock, stop them first. That way we ensure we're not
# trying to mock over an existing mock, which would be problematic since
# we use spec=True.
stop_es_mocks()

This comment has been minimized.

Copy link
@eviljeff

eviljeff Feb 11, 2019

Member

Nit but... this seems a bit wasteful when we know the es mocks won't have started when it's called from TestCase, and wasteful a second time when we're stopping the mocks and starting them again in the autouse fixture. Is there a way of checking that we've initialized the mocks once already? If we can't think of anything I guess it'd be a future enhancement kind of thing.

This comment has been minimized.

Copy link
@diox

diox Feb 11, 2019

Author Member

I tried... there is no public API to check that a patcher has been started :(

@diox diox merged commit ebb2454 into mozilla:master Feb 11, 2019

1 of 2 checks passed

ci/circleci: integration_test Your tests failed on CircleCI
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.