From 88678039627afe186b9c681dd075b88bf0d8eb09 Mon Sep 17 00:00:00 2001 From: Jesse Glick Date: Wed, 11 Jan 2023 17:18:56 -0500 Subject: [PATCH 1/2] [JENKINS-68321] Allow `NoThrottle` to be used even on github.com --- .../ApiRateLimitChecker.java | 23 ++++++------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/src/main/java/org/jenkinsci/plugins/github_branch_source/ApiRateLimitChecker.java b/src/main/java/org/jenkinsci/plugins/github_branch_source/ApiRateLimitChecker.java index 11eaf621e..8ba8c7a8a 100644 --- a/src/main/java/org/jenkinsci/plugins/github_branch_source/ApiRateLimitChecker.java +++ b/src/main/java/org/jenkinsci/plugins/github_branch_source/ApiRateLimitChecker.java @@ -103,22 +103,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; + } + }; } }; From ece6b0c9c3ca6c9161dc83cddefd8ba0b8443cc7 Mon Sep 17 00:00:00 2001 From: Jesse Glick Date: Wed, 11 Jan 2023 18:22:06 -0500 Subject: [PATCH 2/2] Ignoring failing tests --- .../plugins/github_branch_source/ApiRateLimitCheckerTest.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/test/java/org/jenkinsci/plugins/github_branch_source/ApiRateLimitCheckerTest.java b/src/test/java/org/jenkinsci/plugins/github_branch_source/ApiRateLimitCheckerTest.java index a2dec2daf..bf44bee9f 100644 --- a/src/test/java/org/jenkinsci/plugins/github_branch_source/ApiRateLimitCheckerTest.java +++ b/src/test/java/org/jenkinsci/plugins/github_branch_source/ApiRateLimitCheckerTest.java @@ -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; @@ -169,6 +170,7 @@ private void setupStubs(List scenarios) throws Exception { assertEquals(2, initialRequestCount); } + @Ignore("behavior deliberately modified") @Test public void NoCheckerConfigured() throws Exception { // set up scenarios @@ -363,6 +365,7 @@ public void NoThrottleTestShouldNotThrottle404() throws Exception { * * @author Marc Salles Navarro */ + @Ignore("deliberately suppressed behavior") @Test public void NoThrottleTestShouldFallbackToThrottleOnOverForGitHubDotCom() throws Exception { GitHubConfiguration.get().setApiRateLimitChecker(ApiRateLimitChecker.ThrottleOnOver);