Package hudson.model.Queue

Examples of hudson.model.Queue.Item


            }
        });
        FreeStyleProject project = createFreeStyleProject();
        jenkins.getQueue().schedule(project);

        Item item = jenkins.getQueue().getItem(project);
        for (int i = 0; i < 4 * 60 && !item.isBlocked(); i++) {
            Thread.sleep(250);
            item = jenkins.getQueue().getItem(project);
        }
        assertTrue("Not blocked after 60 seconds", item.isBlocked());
        assertEquals("Expected CauseOfBlockage to be returned", "blocked by canRun", item.getWhy());
    }
View Full Code Here


    /**
     * Test that it should not block item without GerritTrigger configured.
     */
    @Test
    public void shouldNotBlockItemWithoutGerritTrigger() {
        Item item = createItemWithOneSlave(new PatchsetCreated());
        when(abstractProjectMock.getTrigger(GerritTrigger.class)).thenReturn(null);
        assertNull("Build should not be blocked", dispatcher.canRun(item));
    }
View Full Code Here

     */
    @Test
    public void shouldNotBlockItemWhenNotConfiguredToWaitForSlaves() {
        PatchsetCreated patchsetCreated = Setup.createPatchsetCreated("someGerritServer", "someProject",
                "refs/changes/1/1/1");
        Item item = createItem(patchsetCreated, null);
        assertNull("Build should not be blocked", dispatcher.canRun(item));
    }
View Full Code Here

     */
    @Test
    public void shouldNotBlockBuildableItem() {
        PatchsetCreated patchsetCreated = Setup.createPatchsetCreated("someGerritServer", "someProject",
                "refs/changes/1/1/1");
        Item item = createItem(patchsetCreated, new String[] {"slaveA", "slaveB", "slaveC"});

        CauseOfBlockage cause = dispatcher.canRun(new Queue.BuildableItem((WaitingItem)item));
        assertNull("Build should not be blocked", cause);
    }
View Full Code Here

     */
    @Test
    public void shouldBlockedItemUntilPatchsetIsReplicatedToSlave() {
        PatchsetCreated patchsetCreated = Setup.createPatchsetCreated("someGerritServer", "someProject",
                "refs/changes/1/1/1");
        Item item = createItem(patchsetCreated, new String[] {"slaveA"});

        //item is blocked
        CauseOfBlockage cause = dispatcher.canRun(item);
        assertNotNull("The item should be blocked", cause);
        assertTrue("Should have returned a WaitingForReplication as CauseOfBlockage",
                cause instanceof WaitingForReplication);
        assertTrue(cause.getShortDescription().contains("slaveA"));

        //send an unrelated event (not RefReplicated)
        dispatcher.gerritEvent(new ChangeAbandoned());
        assertNotNull("the item should be blocked", dispatcher.canRun(item));

        //send an unrelated replication event (other server)
        dispatcher.gerritEvent(Setup.createRefReplicatedEvent("someProject", "refs/changes/1/1/1",
                "someOtherGerritServer", "slaveA", RefReplicated.SUCCEEDED_STATUS));
        assertNotNull("the item should be blocked", dispatcher.canRun(item));

        //send an unrelated replication event (other project)
        dispatcher.gerritEvent(Setup.createRefReplicatedEvent("someOtherProject", "refs/changes/1/1/1",
                "someGerritServer", "slaveA", RefReplicated.SUCCEEDED_STATUS));
        assertNotNull("the item should be blocked", dispatcher.canRun(item));

        //send an unrelated replication event (other ref)
        dispatcher.gerritEvent(Setup.createRefReplicatedEvent("someProject", "refs/changes/2/2/2", "someGerritServer",
                "slaveA", RefReplicated.SUCCEEDED_STATUS));
        assertNotNull("the item should be blocked", dispatcher.canRun(item));

        //send an unrelated replication event (other slave)
        dispatcher.gerritEvent(Setup.createRefReplicatedEvent("someProject", "refs/changes/1/1/1", "someGerritServer",
                "slaveB", RefReplicated.SUCCEEDED_STATUS));
        assertNotNull("the item should be blocked", dispatcher.canRun(item));

        //send a malformed replication event (missing provider)
        RefReplicated refReplicated = Setup.createRefReplicatedEvent("someProject", "refs/changes/1/1/1",
                "someGerritServer", "slaveB", RefReplicated.SUCCEEDED_STATUS);
        refReplicated.setProvider(null);
        dispatcher.gerritEvent(refReplicated);
        assertNotNull("the item should be blocked", dispatcher.canRun(item));

        //send the proper replication event
        dispatcher.gerritEvent(Setup.createRefReplicatedEvent("someProject", "refs/changes/1/1/1", "someGerritServer",
                "slaveA", RefReplicated.SUCCEEDED_STATUS));

        assertNull("Item should not be blocked", dispatcher.canRun(item));
        assertNull("Item should not be tagged with replicationFailedAction",
                item.getAction(ReplicationFailedAction.class));
        verify(queueMock, times(1)).maintain();
    }
View Full Code Here

        cal.add(Calendar.HOUR, HOURSBEFORECHANGEMERGEDFORPATCHSET);
        Date dateBefore8Hours = cal.getTime();

        ChangeMerged changeMerged = Setup.createChangeMergedWithPatchSetDate("someGerritServer", "someProject",
                "refs/changes/1/1/1", dateBefore8Hours);
        Item item = createItem(changeMerged, new String[] {"slaveA"});

        // item is NOT blocked since patchset createdOn date is older than cache
        // we assume it was
        CauseOfBlockage cause = dispatcher.canRun(item);
        assertNull("The item should NOT be blocked", cause);
View Full Code Here

        cal.add(Calendar.HOUR, HOURBEFOREREPLICATIONCACHECREATED);
        Date dateBefore1Hours = cal.getTime();

        ChangeMerged changeMerged = Setup.createChangeMergedWithPatchSetDate("someGerritServer", "someProject",
                "refs/changes/1/1/1", dateBefore1Hours);
        Item item = createItem(changeMerged, new String[] {"slaveA"});

        // item is NOT blocked since patchset createdOn date is older than cache
        // we assume it was
        CauseOfBlockage cause = dispatcher.canRun(item);
        assertNull("The item should NOT be blocked", cause);
View Full Code Here

        cal.add(Calendar.HOUR, HOURSBEFORECHANGEMERGEDFORPATCHSET);
        Date dateBefore8Hours = cal.getTime();

        DraftPublished dp = Setup.createDraftPublishedWithPatchSetDate("someGerritServer", "someProject",
                "refs/changes/1/1/1", dateBefore8Hours);
        Item item = createItem(dp, new String[] {"slaveA"});

        // item is NOT blocked since patchset createdOn date is older than cache
        // we assume it was
        CauseOfBlockage cause = dispatcher.canRun(item);
        assertNull("The item should NOT be blocked", cause);
View Full Code Here

     * Helper method for ChangeBasedEvent replication
     * @param cbe Change Based event
     */
    private void patchSetIsReplicatedToOneSlaveAfterChangeBasedEvent(ChangeBasedEvent cbe) {

        Item item = createItem(cbe, new String[] {"slaveA"});

        //item is blocked
        CauseOfBlockage cause = dispatcher.canRun(item);
        assertNotNull("The item should be blocked", cause);
        assertTrue("Should have returned a WaitingForReplication as CauseOfBlockage",
                cause instanceof WaitingForReplication);
        assertTrue(cause.getShortDescription().contains("slaveA"));

        //send an unrelated event (not RefReplicated)
        dispatcher.gerritEvent(new ChangeAbandoned());
        assertNotNull("the item should be blocked", dispatcher.canRun(item));

        //send the proper replication event
        dispatcher.gerritEvent(Setup.createRefReplicatedEvent("someProject", "refs/changes/1/1/1", "someGerritServer",
                "slaveA", RefReplicated.SUCCEEDED_STATUS));

        assertNull("Item should not be blocked", dispatcher.canRun(item));
        assertNull("Item should not be tagged with replicationFailedAction",
                item.getAction(ReplicationFailedAction.class));
        verify(queueMock, times(1)).maintain();
    }
View Full Code Here

        dispatcher.gerritEvent(Setup.createRefReplicatedEvent("someProject", "refs/changes/1/1/1", "someGerritServer",
                "slaveA", RefReplicated.SUCCEEDED_STATUS));

        ChangeMerged changeMerged = Setup.createChangeMerged("someGerritServer", "someProject",
                "refs/changes/1/1/1");
        Item item = createItem(changeMerged, new String[] {"slaveA"});

        assertNull("Item should not be blocked", dispatcher.canRun(item));
        assertNull("Item should not be tagged with replicationFailedAction",
                item.getAction(ReplicationFailedAction.class));

    }
View Full Code Here

TOP

Related Classes of hudson.model.Queue.Item

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.