openedx / openedx/openedx-platform

[Flaky test] `RegistrationViewTestV2::test_rate_limiting_registration_view`

Open
#36,490 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

flaky-test
Dominant language
Python
Stars
8.2k
Forks
4.4k
Avg merge
6d 18h
Merged PRs (30d)
42

Description

This test fails intermittently and will be deleted according to the Flaky Test Process in https://github.com/openedx/edx-platform/pull/36491

See docs on how to address flaky tests for why this should be fixed and how to go about it.

Failure output:

=================================== FAILURES ===================================
_________ RegistrationViewTestV2.test_rate_limiting_registration_view __________

self = <openedx.core.djangoapps.user_authn.views.tests.test_register.RegistrationViewTestV2 testMethod=test_rate_limiting_registration_view>

    @override_settings(
        CACHES={
            'default': {
                'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
                'LOCATION': 'registration_proxy',
            }
        }
    )
    def test_rate_limiting_registration_view(self):
        """
        Confirm rate limits work as expected for registration
        end point.
        Note that drf's rate limiting makes use of the default cache
        to enforce limits; that's why this test needs a "real"
        default cache (as opposed to the usual-for-tests DummyCache)
        """
        payload = {
            "email": 'email',
            "name": self.NAME,
            "username": self.USERNAME,
            "password": self.PASSWORD,
            "honor_code": "true",
        }
    
        for _ in range(int(settings.REGISTRATION_RATELIMIT.split('/')[0])):
            response = self.client.post(self.url, payload)
            assert response.status_code != 403
    
        response = self.client.post(self.url, payload)
>       assert response.status_code == 403
E       assert 400 == 403
E        +  where 400 = <JsonResponse status_code=400, "application/json">.status_code

openedx/core/djangoapps/user_authn/views/tests/test_register.py:1889: AssertionError
------------------------------ Captured log call -------------------------------
WARNING  django.request:log.py:241 Bad Request: /api/user/v2/account/registration/
WARNING  django.request:log.py:241 Bad Request: /api/user/v2/account/registration/
WARNING  django.request:log.py:241 Bad Request: /api/user/v2/account/registration/
WARNING  django.request:log.py:241 Bad Request: /api/user/v2/account/registration/
WARNING  django.request:log.py:241 Bad Request: /api/user/v2/account/registration/
WARNING  django.request:log.py:241 Bad Request: /api/user/v2/account/registration/
=============================== warnings summary ===============================

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with openedx/core/djangoapps/user_authn/views/tests/test_register.py at RegistrationViewTestV2::test_rate_limiting_registration_view, then run the targeted test and compare the provided failing and passing CI runs. Consult the linked Flaky Test Process and pull request 36491; done means the test is handled according to that process and no longer produces intermittent failures.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.