hudson.model.Queue.Executable Java Examples

The following examples show how to use hudson.model.Queue.Executable. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GithubBuildStatusGraphListenerTest.java    From github-autostatus-plugin with MIT License 6 votes vote down vote up
@Test
public void testAtomNode() throws IOException {
    ErrorAction error = mock(ErrorAction.class);
    CpsFlowExecution execution = mock(CpsFlowExecution.class);

    StepAtomNode stageNode = new StepAtomNode(execution, null, mock(FlowNode.class));
    stageNode.addAction(error);

    FlowExecutionOwner owner = mock(FlowExecutionOwner.class);
    when(execution.getOwner()).thenReturn(owner);

    Executable exec = mock(Executable.class);
    when(owner.getExecutable()).thenReturn(exec);

    AbstractBuild build = mock(AbstractBuild.class);
    when(owner.getExecutable()).thenReturn(build);
    when(build.getAction(ExecutionModelAction.class)).thenReturn(null); // not declarative

    BuildStatusAction buildStatusAction = mock(BuildStatusAction.class);
    when(build.getAction(BuildStatusAction.class)).thenReturn(buildStatusAction);

    GithubBuildStatusGraphListener instance = new GithubBuildStatusGraphListener();
    instance.onNewHead(stageNode);
    verify(buildStatusAction).sendNonStageError(any());
}
 
Example #2
Source File: HudsonTestCase.java    From jenkins-test-harness with MIT License 5 votes vote down vote up
/**
 * Waits until Jenkins finishes building everything, including those builds in the queue, or fail the test
 * if the specified timeout milliseconds is exceeded.
 */
protected void waitUntilNoActivityUpTo(int timeout) throws Exception {
    long startTime = System.currentTimeMillis();
    int streak = 0;

    while (true) {
        Thread.sleep(100);
        if (isSomethingHappening())
            streak=0;
        else
            streak++;

        if (streak>2)   // the system is quiet for a while
            return;

        if (System.currentTimeMillis()-startTime > timeout) {
            List<Executable> building = new ArrayList<Executable>();
            for (Computer c : jenkins.getComputers()) {
                for (Executor e : c.getExecutors()) {
                    if (e.isBusy())
                        building.add(e.getCurrentExecutable());
                }
            }
            throw new AssertionError(String.format("Jenkins is still doing something after %dms: queue=%s building=%s",
                    timeout, Arrays.asList(jenkins.getQueue().getItems()), building));
        }
    }
}
 
Example #3
Source File: DbBackedBuild.java    From DotCi with MIT License 4 votes vote down vote up
private boolean isCurrent(final Executor executor) {
    final Executable currentExecutable = executor.getCurrentExecutable();
    return currentExecutable != null && currentExecutable instanceof DbBackedBuild && this.equals(currentExecutable);
}