*/
@Bug(7649)
public void testMultiplePollingOneBuildAction() throws Exception {
final OneShotEvent buildStarted = new OneShotEvent();
final OneShotEvent buildShouldComplete = new OneShotEvent();
FreeStyleProject p = createFreeStyleProject();
// Make build sleep a while so it blocks new builds
p.getBuildersList().add(new TestBuilder() {
public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException {
buildStarted.signal();
buildShouldComplete.block();
return true;
}
});
SCMTrigger t = new SCMTrigger("@daily");
t.start(p,true);
p.addTrigger(t);
// Start one build to block others
assertTrue(p.scheduleBuild(new UserCause()));
buildStarted.block(); // wait for the build to really start
// Schedule a new build, and trigger it many ways while it sits in queue
Future<FreeStyleBuild> fb = p.scheduleBuild2(0, new UserCause());
assertNotNull(fb);
assertFalse(p.scheduleBuild(new SCMTriggerCause("First poll")));
assertFalse(p.scheduleBuild(new SCMTriggerCause("Second poll")));
assertFalse(p.scheduleBuild(new SCMTriggerCause("Third poll")));
// Wait for 2nd build to finish
buildShouldComplete.signal();
FreeStyleBuild build = fb.get();