Package com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data

Examples of com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.GerritSlave


     * message including all the slaves display name.
     */
    @Test
    public void shouldReturnADescriptionWithAllSlaves() {
        List<GerritSlave> slaves = new ArrayList<GerritSlave>();
        slaves.add(new GerritSlave("slaveA", null, 1234));

        WaitingForReplication waitingForReplication = new WaitingForReplication(slaves);
        assertEquals(Messages.WaitingForReplication("slaveA"), waitingForReplication.getShortDescription());

        slaves.add(new GerritSlave("slaveB", null, 1234));
        assertEquals(Messages.WaitingForReplication("slaveA, slaveB"), waitingForReplication.getShortDescription());
    }
View Full Code Here


        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);
View Full Code Here

        abstractProjectMock = mock(AbstractProject.class);
        when(abstractProjectMock.getTrigger(GerritTrigger.class)).thenReturn(gerritTriggerMock);
        if (slaves != null && slaves.length > 0) {
            List<GerritSlave> gerritSlaves = new ArrayList<GerritSlave>();
            for (String slave : slaves) {
                gerritSlaves.add(new GerritSlave(slave + " display name", slave , 0));
            }
            when(gerritTriggerMock.gerritSlavesToWaitFor(any(String.class))).thenReturn(gerritSlaves);
        }
        return new WaitingItem(Calendar.getInstance(), abstractProjectMock, actions);
    }
View Full Code Here

        slaves = gerritTrigger.gerritSlavesToWaitFor(PluginImpl.DEFAULT_SERVER_NAME);
        assertNotNull(slaves);
        assertEquals(0, slaves.size());

        // ReplicationConfig is enabled and slaves are defined
        List<GerritSlave> expectedSlaves = Arrays.asList(new GerritSlave("slave1", "slave1", 1234),
            new GerritSlave("slave2", "slave2", 1234));
        when(replicationConfigMock.isEnableReplication()).thenReturn(true);
        when(replicationConfigMock.isEnableSlaveSelectionInJobs()).thenReturn(false);
        when(replicationConfigMock.getGerritSlaves()).thenReturn(expectedSlaves);
        slaves = gerritTrigger.gerritSlavesToWaitFor(PluginImpl.DEFAULT_SERVER_NAME);
        assertNotNull(slaves);
View Full Code Here

                false, false, "", "", "", "", "", "", "", null, PluginImpl.DEFAULT_SERVER_NAME, "slaveUUID", null,
                false, false, "", null);

        when(replicationConfigMock.isEnableReplication()).thenReturn(true);
        when(replicationConfigMock.isEnableSlaveSelectionInJobs()).thenReturn(true);
        GerritSlave expectedSlave = new GerritSlave("slaveUUID", "slave1", "slave1", 1234);
        when(replicationConfigMock.getGerritSlave("slaveUUID", true)).thenReturn(expectedSlave);
        List<GerritSlave> slaves = gerritTrigger.gerritSlavesToWaitFor(PluginImpl.DEFAULT_SERVER_NAME);
        assertNotNull(slaves);
        assertEquals(1, slaves.size());
        assertEquals(expectedSlave, slaves.get(0));
View Full Code Here

        assertEquals(0, slaves.size());

        // Replication is configured at job level but slave no longer exist
        when(replicationConfigMock.isEnableReplication()).thenReturn(true);
        when(replicationConfigMock.isEnableSlaveSelectionInJobs()).thenReturn(true);
        GerritSlave expectedSlave = new GerritSlave("defaultSlaveUUID", "defaultSlave", "defaultSlave", 1234);
        when(replicationConfigMock.getGerritSlave("slaveUUID", true)).thenReturn(expectedSlave);
        slaves = gerritTrigger.gerritSlavesToWaitFor(PluginImpl.DEFAULT_SERVER_NAME);
        assertNotNull(slaves);
        assertEquals(1, slaves.size());
        assertEquals(expectedSlave, slaves.get(0));
View Full Code Here

        }

        ReplicationConfig replicationConfig = gerritServer.getConfig().getReplicationConfig();
        if (replicationConfig != null && replicationConfig.isEnableReplication()) {
            if (replicationConfig.isEnableSlaveSelectionInJobs()) {
                GerritSlave gerritSlave = replicationConfig.getGerritSlave(gerritSlaveId, true);
                if (gerritSlave != null) {
                    gerritSlaves.add(gerritSlave);
                }
            } else {
                List<GerritSlave> globalSlaves = replicationConfig.getGerritSlaves();
View Full Code Here

    public ReplicationConfig(ReplicationConfig config) {
        enableReplication = config.isEnableReplication();
        if (config.getGerritSlaves() != null) {
            slaves = new LinkedList<GerritSlave>();
            for (GerritSlave slave : config.getGerritSlaves()) {
                GerritSlave slaveCopy = new GerritSlave(slave.getName(), slave.getHost(), slave.getTimeoutInSeconds());
                slaves.add(slaveCopy);
                if (slave.getId().equals(config.getDefaultSlaveId())) {
                    defaultSlaveId = slaveCopy.getId();
                }
            }
        }
        enableSlaveSelectionInJobs = config.isEnableSlaveSelectionInJobs();
    }
View Full Code Here

TOP

Related Classes of com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.GerritSlave

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.