-
Notifications
You must be signed in to change notification settings - Fork 721
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
JENKINS-73740: Allow admins to disable throttling
Add global configuration to disable throttling.
- Loading branch information
Showing
5 changed files
with
68 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<div> | ||
Check this to enable email throttling which for less important triggers, | ||
will check the number of messages sent and throttle new messages if too | ||
many have been sent. | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,11 +6,7 @@ | |
import static org.hamcrest.Matchers.hasItem; | ||
import static org.hamcrest.Matchers.hasItems; | ||
import static org.hamcrest.Matchers.not; | ||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertFalse; | ||
import static org.junit.Assert.assertNotNull; | ||
import static org.junit.Assert.assertNull; | ||
import static org.junit.Assert.assertTrue; | ||
import static org.junit.Assert.*; | ||
|
||
import edu.umd.cs.findbugs.annotations.NonNull; | ||
import hudson.Launcher; | ||
|
@@ -123,6 +119,7 @@ public void setUp() throws Exception { | |
publisher.getDescriptor().setDefaultSuffix(null); | ||
publisher.getDescriptor().setEmergencyReroute(null); | ||
publisher.getDescriptor().setAllowedDomains(null); | ||
publisher.getDescriptor().setThrottlingEnabled(true); | ||
oldAuthorizationStrategy = j.jenkins.getAuthorizationStrategy(); | ||
oldSecurityRealm = j.jenkins.getSecurityRealm(); | ||
oldAdminAddress = JenkinsLocationConfiguration.get().getAdminAddress(); | ||
|
@@ -1702,8 +1699,8 @@ public void testProjectFromWithDefaultSuffix() throws Exception { | |
} | ||
|
||
@Test | ||
public void testLowerThanLimit() throws Exception { | ||
FreeStyleProject prj = j.createFreeStyleProject("test"); | ||
public void testThrottlingLowerThanLimit() throws Exception { | ||
FreeStyleProject prj = j.createFreeStyleProject("throttle-test"); | ||
prj.getPublishersList().add(publisher); | ||
|
||
publisher.recipientList = "[email protected]"; | ||
|
@@ -1730,8 +1727,8 @@ public void testLowerThanLimit() throws Exception { | |
} | ||
|
||
@Test | ||
public void testEqualsLimit() throws Exception { | ||
FreeStyleProject prj = j.createFreeStyleProject("test2"); | ||
public void testThrottlingEqualsLimit() throws Exception { | ||
FreeStyleProject prj = j.createFreeStyleProject("throttle-test2"); | ||
prj.getPublishersList().add(publisher); | ||
|
||
publisher.recipientList = "[email protected]"; | ||
|
@@ -1760,8 +1757,8 @@ public void testEqualsLimit() throws Exception { | |
} | ||
|
||
@Test | ||
public void testOverLimit() throws Exception { | ||
FreeStyleProject prj = j.createFreeStyleProject("test3"); | ||
public void testThrottlingOverLimit() throws Exception { | ||
FreeStyleProject prj = j.createFreeStyleProject("throttle-test3"); | ||
prj.getPublishersList().add(publisher); | ||
|
||
publisher.recipientList = "[email protected]"; | ||
|
@@ -1789,6 +1786,36 @@ public void testOverLimit() throws Exception { | |
Mailbox.get("[email protected]").size()); | ||
} | ||
|
||
@Test | ||
public void testThrottlingDisabled() throws Exception { | ||
FreeStyleProject prj = j.createFreeStyleProject("throttle-test4"); | ||
prj.getPublishersList().add(publisher); | ||
publisher.getDescriptor().setThrottlingEnabled(false); | ||
|
||
publisher.recipientList = "[email protected]"; | ||
for (int i = 0; i < 130; i++) { | ||
publisher.configuredTriggers.add(new SuccessTrigger( | ||
recProviders, | ||
"$DEFAULT_RECIPIENTS", | ||
"$DEFAULT_REPLYTO", | ||
"$DEFAULT_SUBJECT", | ||
"$DEFAULT_CONTENT", | ||
"", | ||
0, | ||
"project")); | ||
} | ||
|
||
for (EmailTrigger trigger : publisher.configuredTriggers) { | ||
trigger.getEmail().addRecipientProvider(new ListRecipientProvider()); | ||
} | ||
|
||
FreeStyleBuild build = prj.scheduleBuild2(0).get(); | ||
j.assertBuildStatusSuccess(build); | ||
|
||
assertNotEquals(EmailThrottler.THROTTLING_LIMIT, 130); | ||
assertEquals(130, Mailbox.get("[email protected]").size()); | ||
} | ||
|
||
/** | ||
* Similar to {@link SleepBuilder} but only on the first build. (Removing | ||
* the builder between builds is tricky since you would have to wait for the | ||
|