Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add tests for rate-limit headers #1925

Open
Labels
staletestFor issues or missing tests
@nejch

Description

@nejch

Thanks@JohnVillalovos! Would it make sense to add another case to

deftest_rate_limits(gl):
settings=gl.settings.get()
settings.throttle_authenticated_api_enabled=True
settings.throttle_authenticated_api_requests_per_period=1
settings.throttle_authenticated_api_period_in_seconds=3
settings.save()
projects= []
foriinrange(0,20):
projects.append(gl.projects.create({"name":f"{str(i)}ok"}))
withpytest.raises(gitlab.GitlabCreateError)ase:
foriinrange(20,40):
projects.append(
gl.projects.create(
{"name":f"{str(i)}shouldfail"},obey_rate_limit=False
)
)
assert"Retry later"instr(e.value)
settings.throttle_authenticated_api_enabled=False
settings.save()
[project.delete()forprojectinprojects]
with endpoints that don't returnretry-after, e.g.user as mentioned in the issue? Although this might need 14.8 and not sure if it's enabled by default. Just wondering.https://docs.gitlab.com/ee/user/admin_area/settings/rate_limit_on_users_api.html#rate-limits-on-users-api

(If we do this, I would maybe turn the settings into a fixture to use in both tests, and do the cleanup afteryield to make it more reusable, e.g.)

@pytest.fixturedefrate_limit_settings(gl):settings=gl.settings.get()settings.throttle_authenticated_api_enabled=Truesettings.throttle_authenticated_api_requests_per_period=1settings.throttle_authenticated_api_period_in_seconds=3settings.save()yieldsettingssettings.throttle_authenticated_api_enabled=Falsesettings.save()

PS: Interesting, looks like these headers are also useful to avoid 429s altogether, looking at go-gitlab with some fancy rate-limiting code:xanzy/go-gitlab@d8bb0b4

Originally posted by@nejch in#1895 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    staletestFor issues or missing tests

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp