use of com.thoughtworks.go.config.AgentConfig in project gocd by gocd.
the class JobInstanceStatusMonitorTest method shouldSendCancelMessageIfJobIsRescheduled.
@Test
public void shouldSendCancelMessageIfJobIsRescheduled() throws Exception {
AgentConfig agentConfig = AgentMother.remoteAgent();
configHelper.addAgent(agentConfig);
fixture.createPipelineWithFirstStageScheduled();
AgentRuntimeInfo info = AgentRuntimeInfo.fromServer(agentConfig, true, "location", 1000000l, "OS", false);
info.setCookie("cookie");
agentRemoteHandler.process(agent, new Message(Action.ping, MessageEncoding.encodeData(info)));
buildAssignmentService.onTimer();
assertThat(agent.messages.size(), is(1));
assertThat(MessageEncoding.decodeWork(agent.messages.get(0).getData()), instanceOf(BuildWork.class));
BuildWork work = (BuildWork) MessageEncoding.decodeWork(agent.messages.get(0).getData());
BuildAssignment assignment = work.getAssignment();
final JobInstance instance = jobInstanceService.buildByIdWithTransitions(assignment.getJobIdentifier().getBuildId());
scheduleService.rescheduleJob(instance);
assertThat(agent.messages.size(), is(2));
assertThat(agent.messages.get(1).getAction(), is(Action.cancelBuild));
}
use of com.thoughtworks.go.config.AgentConfig in project gocd by gocd.
the class JobAssignmentTest method setupLocalAgent.
private AgentInstance setupLocalAgent() throws UnknownHostException {
AgentConfig agentConfig = AgentMother.localAgent();
configHelper.addAgent(agentConfig);
return AgentInstance.createFromConfig(agentConfig, systemEnvironment, agentStatusChangeListener());
}
use of com.thoughtworks.go.config.AgentConfig in project gocd by gocd.
the class JobControllerIntegrationTest method jobDetailModel_shouldNotHaveTheElasticProfilePluginIdAndElasticAgentIdWhenAgentIsNotElasticAgent.
@Test
public void jobDetailModel_shouldNotHaveTheElasticProfilePluginIdAndElasticAgentIdWhenAgentIsNotElasticAgent() throws Exception {
Pipeline pipeline = fixture.createPipelineWithFirstStageAssigned();
Stage stage = pipeline.getFirstStage();
JobInstance job = stage.getFirstJob();
final AgentConfig agentConfig = new AgentConfig(job.getAgentUuid());
goConfigService.agents().add(agentConfig);
ModelAndView modelAndView = controller.jobDetail(pipeline.getName(), String.valueOf(pipeline.getCounter()), stage.getName(), String.valueOf(stage.getCounter()), job.getName());
assertNull(modelAndView.getModel().get("elasticAgentPluginId"));
assertNull(modelAndView.getModel().get("elasticAgentId"));
}
use of com.thoughtworks.go.config.AgentConfig in project gocd by gocd.
the class JobControllerIntegrationTest method jobDetailModel_shouldHaveTheElasticPluginIdAndElasticAgentIdWhenAgentIsAssigned.
@Test
public void jobDetailModel_shouldHaveTheElasticPluginIdAndElasticAgentIdWhenAgentIsAssigned() throws Exception {
Pipeline pipeline = fixture.createPipelineWithFirstStageAssigned();
Stage stage = pipeline.getFirstStage();
JobInstance job = stage.getFirstJob();
GoPluginDescriptor.About about = new GoPluginDescriptor.About("name", "0.1", "17.3.0", "desc", null, null);
GoPluginDescriptor descriptor = new GoPluginDescriptor("plugin_id", null, about, null, null, false);
ElasticAgentMetadataStore.instance().setPluginInfo(new ElasticAgentPluginInfo(descriptor, null, null, null, new Capabilities(false, true)));
fixture.addJobAgentMetadata(new JobAgentMetadata(job.getId(), new ElasticProfile("profile_id", "plugin_id", Collections.EMPTY_LIST)));
final AgentConfig agentConfig = new AgentConfig(job.getAgentUuid());
agentConfig.setElasticAgentId("elastic_agent_id");
agentConfig.setElasticPluginId("plugin_id");
goConfigService.agents().add(agentConfig);
ModelAndView modelAndView = controller.jobDetail(pipeline.getName(), String.valueOf(pipeline.getCounter()), stage.getName(), String.valueOf(stage.getCounter()), job.getName());
assertThat(modelAndView.getModel().get("elasticAgentPluginId"), is("plugin_id"));
assertThat(modelAndView.getModel().get("elasticAgentId"), is("elastic_agent_id"));
}
use of com.thoughtworks.go.config.AgentConfig in project gocd by gocd.
the class AgentRegistrationControllerIntegrationTest method shouldReIssueCertificateIfRegisteredAgentAsksForRegistration.
@Test
public void shouldReIssueCertificateIfRegisteredAgentAsksForRegistration() throws Exception {
String uuid = UUID.randomUUID().toString();
agentConfigService.addAgent(new AgentConfig(uuid, "hostname", "127.0.01"), Username.ANONYMOUS);
assertTrue(agentService.findAgent(uuid).getAgentConfigStatus().equals(AgentConfigStatus.Enabled));
MockHttpServletRequest request = new MockHttpServletRequest();
final ResponseEntity responseEntity = controller.agentRequest("hostname", uuid, "sandbox", "100", null, null, null, null, null, null, null, false, token(uuid, goConfigService.serverConfig().getTokenGenerationKey()), request);
AgentInstance agentInstance = agentService.findAgent(uuid);
assertTrue(agentInstance.isIdle());
assertThat(responseEntity.getStatusCode(), is(HttpStatus.OK));
assertTrue(RegistrationJSONizer.fromJson(responseEntity.getBody().toString()).isValid());
}
Aggregations