use of com.thoughtworks.go.server.service.AgentBuildingInfo in project gocd by gocd.
the class AgentInstanceMother method building.
public static AgentInstance building(String buildLocator, SystemEnvironment systemEnvironment) {
AgentConfig buildingAgentConfig = new AgentConfig("uuid3", "CCeDev01", "10.18.5.1", new ResourceConfigs("java"));
AgentRuntimeInfo agentRuntimeInfo = new AgentRuntimeInfo(buildingAgentConfig.getAgentIdentifier(), AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie", false);
agentRuntimeInfo.busy(new AgentBuildingInfo("pipeline", buildLocator));
AgentInstance building = AgentInstance.createFromConfig(buildingAgentConfig, systemEnvironment, mock(AgentStatusChangeListener.class));
building.update(agentRuntimeInfo);
return building;
}
use of com.thoughtworks.go.server.service.AgentBuildingInfo in project gocd by gocd.
the class AgentInstanceTest method setUp.
@Before
public void setUp() {
systemEnvironment = new SystemEnvironment();
agentConfig = new AgentConfig("uuid2", "CCeDev01", DEFAULT_IP_ADDRESS);
defaultBuildingInfo = new AgentBuildingInfo("pipeline", "buildLocator");
agentStatusChangeListener = mock(AgentStatusChangeListener.class);
}
use of com.thoughtworks.go.server.service.AgentBuildingInfo in project gocd by gocd.
the class AgentWebSocketClientControllerTest method processCancelBuildCommandBuild.
@Test
public void processCancelBuildCommandBuild() throws IOException, InterruptedException {
ArgumentCaptor<Message> argumentCaptor = ArgumentCaptor.forClass(Message.class);
agentController = createAgentController();
agentController.init();
agentController.getAgentRuntimeInfo().setSupportsBuildCommandProtocol(true);
final BuildSettings build = new BuildSettings();
build.setBuildId("b001");
build.setConsoleUrl("http://foo.bar/console");
build.setArtifactUploadBaseUrl("http://foo.bar/artifacts");
build.setPropertyBaseUrl("http://foo.bar/properties");
build.setBuildLocator("build1");
build.setBuildLocatorForDisplay("build1ForDisplay");
build.setConsoleLogCharset("utf-8");
build.setBuildCommand(BuildCommand.compose(BuildSessionBasedTestCase.execSleepScript(MAX_WAIT_IN_TEST / 1000), BuildCommand.reportCurrentStatus(JobState.Building)));
Thread buildingThread = new Thread(new Runnable() {
@Override
public void run() {
try {
agentController.process(new Message(Action.build, MessageEncoding.encodeData(build)));
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
});
buildingThread.start();
waitForAgentRuntimeState(agentController.getAgentRuntimeInfo(), AgentRuntimeStatus.Building);
agentController.process(new Message(Action.cancelBuild));
buildingThread.join(MAX_WAIT_IN_TEST);
AgentRuntimeInfo agentRuntimeInfo = cloneAgentRuntimeInfo(agentController.getAgentRuntimeInfo());
agentRuntimeInfo.busy(new AgentBuildingInfo("build1ForDisplay", "build1"));
agentRuntimeInfo.cancel();
verify(webSocketSessionHandler).sendAndWaitForAcknowledgement(argumentCaptor.capture());
assertThat(agentController.getAgentRuntimeInfo().getRuntimeStatus(), is(AgentRuntimeStatus.Idle));
Message message = argumentCaptor.getValue();
assertThat(message.getAcknowledgementId(), notNullValue());
assertThat(message.getAction(), is(Action.reportCompleted));
assertThat(message.getData(), is(MessageEncoding.encodeData(new Report(agentRuntimeInfo, "b001", null, JobResult.Cancelled))));
}
Aggregations