use of com.thoughtworks.go.config.AgentConfig in project gocd by gocd.
the class AgentRuntimeInfoTest method shouldUsingIdleWhenRegistrationRequestIsFromLocalAgent.
@Test
public void shouldUsingIdleWhenRegistrationRequestIsFromLocalAgent() {
AgentRuntimeInfo agentRuntimeInfo = AgentRuntimeInfo.fromServer(new AgentConfig("uuid", "localhost", "127.0.0.1"), false, "/var/lib", 0L, "linux", false);
assertThat(agentRuntimeInfo.getRuntimeStatus(), Is.is(AgentRuntimeStatus.Idle));
}
use of com.thoughtworks.go.config.AgentConfig in project gocd by gocd.
the class JobInstanceStatusMonitorTest method shouldSendCancelMessageIfJobIsCancelled.
@Test
public void shouldSendCancelMessageIfJobIsCancelled() 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));
Work work = MessageEncoding.decodeWork(agent.messages.get(0).getData());
assertThat(work, instanceOf(BuildWork.class));
JobPlan jobPlan = ((BuildWork) work).getAssignment().getPlan();
final JobInstance instance = jobInstanceService.buildByIdWithTransitions(jobPlan.getJobId());
transactionTemplate.execute(new TransactionCallbackWithoutResult() {
@Override
protected void doInTransactionWithoutResult(TransactionStatus status) {
jobInstanceService.cancelJob(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 ScheduleServiceRescheduleHungJobsTest method activities.
private AgentInstances activities() {
final AgentInstances activities = new AgentInstances(null);
SystemEnvironment systemEnvironment = new SystemEnvironment();
activities.add(AgentInstance.createFromConfig(new AgentConfig("uuid1"), systemEnvironment));
activities.add(AgentInstance.createFromConfig(new AgentConfig("uuid2"), systemEnvironment));
return activities;
}
use of com.thoughtworks.go.config.AgentConfig in project gocd by gocd.
the class TriStateSelectionTest method shouldHaveActionAddIfAllAgentsHaveThatResource.
@Test
public void shouldHaveActionAddIfAllAgentsHaveThatResource() {
resources.add(new Resource("all"));
agents.add(new AgentConfig("uuid1", "host1", "127.0.0.1", new Resources("all")));
agents.add(new AgentConfig("uuid2", "host2", "127.0.0.2", new Resources("all")));
List<TriStateSelection> selections = TriStateSelection.forAgentsResources(resources, agents);
assertThat(selections, hasItem(new TriStateSelection("all", TriStateSelection.Action.add)));
}
use of com.thoughtworks.go.config.AgentConfig in project gocd by gocd.
the class AgentRegistrationControllerIntegrationTest method shouldRegisterAgent.
@Test
public void shouldRegisterAgent() throws Exception {
String uuid = UUID.randomUUID().toString();
MockHttpServletRequest request = new MockHttpServletRequest();
controller.agentRequest("hostname", uuid, "sandbox", "100", null, null, null, null, null, null, null, false, request);
AgentConfig agentConfig = goConfigService.agentByUuid(uuid);
assertThat(agentConfig.getHostname(), is("hostname"));
}
Aggregations