Search in sources :

Example 76 with AgentConfig

use of com.thoughtworks.go.config.AgentConfig in project gocd by gocd.

the class AgentsTest method shouldFindAgentByUuid.

@Test
public void shouldFindAgentByUuid() {
    Agents agents = new Agents();
    agents.add(new AgentConfig("1", "localhost", "2"));
    assertThat(agents.getAgentByUuid("1").getHostname(), is("localhost"));
}
Also used : AgentConfig(com.thoughtworks.go.config.AgentConfig) Agents(com.thoughtworks.go.config.Agents) Test(org.junit.Test)

Example 77 with AgentConfig

use of com.thoughtworks.go.config.AgentConfig in project gocd by gocd.

the class AgentsTest method shouldGiveAListOfUuids.

@Test
public void shouldGiveAListOfUuids() throws Exception {
    Agents agents = new Agents();
    agents.add(new AgentConfig("1", "localhost", "2"));
    AgentConfig denied = new AgentConfig("2", "localhost", "2");
    denied.setDisabled(true);
    agents.add(denied);
    Set<String> uuids = agents.acceptedUuids();
    assertThat(uuids.size(), is(2));
    assertThat(uuids, hasItem("1"));
    assertThat(uuids, hasItem("2"));
}
Also used : AgentConfig(com.thoughtworks.go.config.AgentConfig) Agents(com.thoughtworks.go.config.Agents) Test(org.junit.Test)

Example 78 with AgentConfig

use of com.thoughtworks.go.config.AgentConfig in project gocd by gocd.

the class UpdateResourceCommand method update.

public CruiseConfig update(CruiseConfig cruiseConfig) throws Exception {
    AgentConfig agentConfig = cruiseConfig.agents().getAgentByUuid(uuid);
    agentConfig.getResourceConfigs().importFromCsv(resources);
    return cruiseConfig;
}
Also used : AgentConfig(com.thoughtworks.go.config.AgentConfig)

Example 79 with AgentConfig

use of com.thoughtworks.go.config.AgentConfig in project gocd by gocd.

the class ScheduleServiceRescheduleHungJobsIntegrationTest method shouldRescheduleHungBuildWhenAgentTryToGetWorkWithSameUuid.

@Test
public void shouldRescheduleHungBuildWhenAgentTryToGetWorkWithSameUuid() throws Exception {
    AgentConfig agentConfig = AgentMother.localAgent();
    AgentInstance instance = agent(agentConfig);
    BuildCause buildCause = modifySomeFiles(evolveConfig);
    dbHelper.saveMaterials(buildCause.getMaterialRevisions());
    Pipeline pipeline = instanceFactory.createPipelineInstance(evolveConfig, buildCause, new DefaultSchedulingContext(DEFAULT_APPROVED_BY), "md5-test", new TimeProvider());
    buildAssignmentService.onTimer();
    Stage stage = pipeline.getFirstStage();
    JobInstance jobInstance = stage.getJobInstances().get(0);
    jobInstance.setAgentUuid(agentConfig.getUuid());
    jobInstance.changeState(JobState.Building);
    pipelineDao.saveWithStages(pipeline);
    buildAssignmentService.onTimer();
    buildAssignmentService.assignWorkToAgent(instance);
    buildAssignmentService.onTimer();
    buildAssignmentService.assignWorkToAgent(instance);
    final Stage reloadedStage = stageDao.stageById(stage.getId());
    final JobInstance rescheduledJob = reloadedStage.getJobInstances().getByName(jobInstance.getName());
    assertThat(rescheduledJob.getState(), is(JobState.Assigned));
}
Also used : AgentConfig(com.thoughtworks.go.config.AgentConfig) TimeProvider(com.thoughtworks.go.util.TimeProvider) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause)

Example 80 with AgentConfig

use of com.thoughtworks.go.config.AgentConfig in project gocd by gocd.

the class ScheduleServiceRescheduleHungJobsIntegrationTest method shouldNotRescheduleCancelledBuilds.

@Test
public void shouldNotRescheduleCancelledBuilds() throws SQLException {
    String agentId = "uuid";
    final Pipeline pipeline = instanceFactory.createPipelineInstance(evolveConfig, modifySomeFiles(evolveConfig), new DefaultSchedulingContext(DEFAULT_APPROVED_BY), "md5-test", new TimeProvider());
    dbHelper.savePipelineWithStagesAndMaterials(pipeline);
    buildAssignmentService.assignWorkToAgent(agent(new AgentConfig(agentId)));
    transactionTemplate.execute(new TransactionCallbackWithoutResult() {

        public void doInTransactionWithoutResult(TransactionStatus status) {
            stageService.cancelStage(stageOf(pipeline));
        }
    });
    scheduleService.rescheduleHungJobs();
    JobInstance reloaded = jobInstanceDao.buildByIdWithTransitions(buildOf(pipeline).getId());
    assertThat(reloaded.getState(), is(JobState.Completed));
    assertThat(reloaded.getResult(), is(JobResult.Cancelled));
}
Also used : AgentConfig(com.thoughtworks.go.config.AgentConfig) TimeProvider(com.thoughtworks.go.util.TimeProvider) TransactionStatus(org.springframework.transaction.TransactionStatus) TransactionCallbackWithoutResult(org.springframework.transaction.support.TransactionCallbackWithoutResult)

Aggregations

AgentConfig (com.thoughtworks.go.config.AgentConfig)90 Test (org.junit.Test)68 AgentInstance (com.thoughtworks.go.domain.AgentInstance)20 Agents (com.thoughtworks.go.config.Agents)13 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)11 AgentStatusChangeListener (com.thoughtworks.go.listener.AgentStatusChangeListener)10 Username (com.thoughtworks.go.server.domain.Username)7 ResponseEntity (org.springframework.http.ResponseEntity)7 ResourceConfig (com.thoughtworks.go.config.ResourceConfig)6 ResourceConfigs (com.thoughtworks.go.config.ResourceConfigs)5 AgentIdentifier (com.thoughtworks.go.remote.AgentIdentifier)5 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)5 GoConfigDao (com.thoughtworks.go.config.GoConfigDao)4 ServerConfig (com.thoughtworks.go.config.ServerConfig)4 UpdateConfigCommand (com.thoughtworks.go.config.UpdateConfigCommand)4 EnvironmentVariablesConfig (com.thoughtworks.go.config.EnvironmentVariablesConfig)3 ElasticProfile (com.thoughtworks.go.config.elastic.ElasticProfile)3 NullAgentInstance (com.thoughtworks.go.domain.NullAgentInstance)3 EnvironmentVariableConfig (com.thoughtworks.go.config.EnvironmentVariableConfig)2 StageConfig (com.thoughtworks.go.config.StageConfig)2