Package hudson.model.Queue

Examples of hudson.model.Queue.Item


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

        DraftPublished dp = Setup.createDraftPublished("someGerritServer", "someProject",
                "refs/changes/1/1/1");
        Item item = createItem(dp, 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


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

        //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"));
        assertTrue(cause.getShortDescription().contains("slaveB"));
        assertTrue(cause.getShortDescription().contains("slaveC"));

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

        //item is still blocked
        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"));
        assertFalse(cause.getShortDescription().contains("slaveB"));
        assertTrue(cause.getShortDescription().contains("slaveC"));

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

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

        //send replication event for slaveC
        dispatcher.gerritEvent(Setup.createRefReplicatedEvent("someProject", "refs/changes/1/1/1", "someGerritServer",
                "slaveC", 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

     */
    @Test
    public void shouldBlockItemUntilSlaveReplicationTimeoutIsReached() throws InterruptedException {
        PatchsetCreated patchsetCreated = Setup.createPatchsetCreated("someGerritServer", "someProject",
                "refs/changes/1/1/1");
        Item item = createItem(patchsetCreated, null);
        //setup slaves to have one with timeout
        List<GerritSlave> gerritSlaves = new ArrayList<GerritSlave>();
        gerritSlaves.add(new GerritSlave("slave1", "host1", 0));
        gerritSlaves.add(new GerritSlave("slave2", "host2", 1)); // slave timeout is 1 second
        when(gerritTriggerMock.gerritSlavesToWaitFor("someGerritServer")).thenReturn(gerritSlaves);

        //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("slave1"));
        assertTrue(cause.getShortDescription().contains("slave2"));

        //wait to reach the timeout
        Thread.sleep(TimeUnit.SECONDS.toMillis(2));

        //timeout reached
        cause = dispatcher.canRun(item);
        assertNull("Item should not be blocked", cause);
        ReplicationFailedAction replicationFailedAction = item.getAction(ReplicationFailedAction.class);
        assertNotNull("Item should be tagged with replicationFailedAction", replicationFailedAction);
        assertTrue(replicationFailedAction.getReason().contains("slave2"));
        verify(queueMock, times(0)).maintain();
    }
View Full Code Here

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

        //item is blocked
        CauseOfBlockage cause = dispatcher.canRun(item);
        assertNotNull("the item should be blocked", cause);
        assertTrue("Should have returned a WaitingForReplication as CauseOfBlockage",
View Full Code Here

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

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

View Full Code Here

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

        RefUpdated refUpdated = Setup.createRefUpdated("someGerritServer", "someProject",
                "master");
        Item item = createItem(refUpdated, new String[] {"slaveA", "slaveB"});

        //item is blocked since the cached replication events are time stamped before the actual event
        CauseOfBlockage cause = dispatcher.canRun(item);
        assertNotNull("the item should be blocked", cause);
        assertTrue("Should have returned a WaitingForReplication as CauseOfBlockage",
View Full Code Here

    public void shouldNotBlockItemWhenElapsedTimeIsGreaterThenCacheExpirationTime() {
        PatchsetCreated patchsetCreated = Setup.createPatchsetCreated("someGerritServer", "someProject",
                "refs/heads/master");
        patchsetCreated.setReceivedOn(System.currentTimeMillis()
                - TimeUnit.MINUTES.toMillis(ReplicationCache.DEFAULT_EXPIRATION_IN_MINUTES));
        Item item = createItem(patchsetCreated, new String[] {"slaveA", "slaveB"});
        assertNull("Item should not be blocked", dispatcher.canRun(item));
        verify(queueMock, times(0)).maintain();
    }
View Full Code Here

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

        //items are blocked
        CauseOfBlockage cause = dispatcher.canRun(item1);
        assertNotNull("the item should be blocked", cause);
        assertTrue("Should have returned a WaitingForReplication as CauseOfBlockage",
                cause instanceof WaitingForReplication);
        cause = dispatcher.canRun(item2);
        assertNotNull("the item should be blocked", cause);
        assertTrue("Should have returned a WaitingForReplication as CauseOfBlockage",
                cause instanceof WaitingForReplication);

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


        assertNull("Item should not be blocked", dispatcher.canRun(item1));
        assertNull("Item should not be tagged with replicationFailedAction",
                item1.getAction(ReplicationFailedAction.class));
        assertNull("Item should not be blocked", dispatcher.canRun(item2));
        assertNull("Item should not be tagged with replicationFailedAction",
                item2.getAction(ReplicationFailedAction.class));
        verify(queueMock, times(1)).maintain();
    }
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.