use of com.thoughtworks.go.websocket.Message in project gocd by gocd.
the class BuildAssignmentServiceIntegrationTest method shouldNotAssignWorkToCanceledAgentsRegisteredInAgentRemoteHandler.
@Test
public void shouldNotAssignWorkToCanceledAgentsRegisteredInAgentRemoteHandler() 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)));
AgentInstance agentInstance = agentService.findAgentAndRefreshStatus(info.getUUId());
agentInstance.cancel();
buildAssignmentService.onTimer();
assertThat("Should not assign work when agent status is Canceled", agent.messages.size(), is(0));
}
use of com.thoughtworks.go.websocket.Message 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());
JobPlan jobPlan = work.getAssignment().getPlan();
final JobInstance instance = jobInstanceService.buildByIdWithTransitions(jobPlan.getJobId());
scheduleService.rescheduleJob(instance);
assertThat(agent.messages.size(), is(2));
assertThat(agent.messages.get(1).getAction(), is(Action.cancelBuild));
}
Aggregations