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

Fix flaky test #7148

Merged
merged 1 commit into from Jun 2, 2020
Merged

Fix flaky test #7148

merged 1 commit into from Jun 2, 2020

Conversation

stsewd
Copy link
Member

@stsewd stsewd commented Jun 1, 2020

Turns out, it was the cache.
If your computer is fast enough,
the same project slug is updated in the same second.

The cache is done at the django level, so not much we can do about it from outside.

With milliseconds hopefully is hard to hit.
Also, set_urlconf to None and to the current urlconf is already done automatically in django 2.2

https://github.com/django/django/blob/stable/2.2.x/django/core/handlers/base.py#L94-L95
https://github.com/django/django/blob/stable/2.2.x/django/core/handlers/base.py#L166

Turns out, it was the cache.
If your computer is fast enough,
the same project slug is updated in the same second.

With milliseconds hopefully is hard to hit.
Also, set_urlconf to None and to the current urlconf is already done automatically in django 2.2

https://github.com/django/django/blob/stable/2.2.x/django/core/handlers/base.py#L94-L95
https://github.com/django/django/blob/stable/2.2.x/django/core/handlers/base.py#L166
@@ -152,7 +149,7 @@ def test_long_bad_subdomain(self):

@pytest.mark.proxito
@override_settings(PUBLIC_DOMAIN='dev.readthedocs.io')
class MiddlewareURLConfTests(RequestFactoryTestMixin, TestCase):
Copy link
Member Author

@stsewd stsewd Jun 1, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't make use of this mixin in any of the tests

@stsewd stsewd requested a review from a team Jun 1, 2020
Copy link
Member

@ericholscher ericholscher left a comment

I don't quite understand what was breaking here. Why would the time set be an issue?

@stsewd
Copy link
Member Author

stsewd commented Jun 2, 2020

@ericholscher the tests use the same project slug, so the next test can be created between the same second, this making use the same cached urlconf module instead of evaluating the new one. You can replicate this by deleting the seconds from the timestamp.

@ericholscher
Copy link
Member

ericholscher commented Jun 2, 2020

Oh I see, that makes sense.

@ericholscher ericholscher merged commit 588e3a1 into master Jun 2, 2020
2 checks passed
@ericholscher ericholscher deleted the fix-flaky-test branch Jun 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants