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

[JENKINS-71849] Allow NoThrottle to be used even on github.com #653

Merged
merged 4 commits into from
Sep 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -100,22 +100,13 @@ long checkRateLimitImpl(@NonNull GHRateLimit.Record rateLimit, long count, long
NoThrottle(Messages.ApiRateLimitChecker_NoThrottle()) {
@Override
public LocalChecker getChecker(@NonNull TaskListener listener, String apiUrl) {
if (GitHubServerConfig.GITHUB_URL.equals(apiUrl)) {
// If the GitHub public API is being used, this will fallback to ThrottleOnOver
LocalChecker checker = ThrottleOnOver.getChecker(listener, apiUrl);
checker.writeLog(
"GitHub throttling is disabled, which is not allowed for public GitHub usage, "
+ "so ThrottleOnOver will be used instead. To configure a different rate limiting strategy, go to \"GitHub API usage\" under \"Configure System\" in the Jenkins settings.");
return checker;
} else {
return new LocalChecker(listener) {
@Override
long checkRateLimitImpl(@NonNull GHRateLimit.Record rateLimit, long count, long now)
throws InterruptedException {
return now;
}
};
}
return new LocalChecker(listener) {
@Override
long checkRateLimitImpl(@NonNull GHRateLimit.Record rateLimit, long count, long now)
throws InterruptedException {
return now;
}
};
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.jenkinsci.plugins.github.config.GitHubServerConfig;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.kohsuke.github.GHRateLimit;
import org.kohsuke.github.GitHub;
Expand Down Expand Up @@ -159,6 +160,7 @@ private void setupStubs(List<RateLimit> scenarios) throws Exception {
assertEquals(2, initialRequestCount);
}

@Ignore("behavior deliberately modified")
@Test
public void NoCheckerConfigured() throws Exception {
// set up scenarios
Expand Down Expand Up @@ -349,6 +351,7 @@ public void NoThrottleTestShouldNotThrottle404() throws Exception {
*
* @author Marc Salles Navarro
*/
@Ignore("behavior deliberately modified")
@Test
public void NoThrottleTestShouldFallbackToThrottleOnOverForGitHubDotCom() throws Exception {
GitHubConfiguration.get().setApiRateLimitChecker(ApiRateLimitChecker.ThrottleOnOver);
Expand Down
Loading