use of com.thoughtworks.go.server.service.AgentBuildingInfo in project gocd by gocd.
the class SleepWork method doWork.
@Override
public void doWork(EnvironmentVariableContext environmentVariableContext, AgentWorkContext agentWorkContext) {
cancelLatch = new CountDownLatch(1);
agentWorkContext.getAgentRuntimeInfo().busy(new AgentBuildingInfo("sleepwork", "sleepwork1"));
boolean canceled = false;
DefaultGoPublisher goPublisher = new DefaultGoPublisher(agentWorkContext.getArtifactsManipulator(), new JobIdentifier(), agentWorkContext.getRepositoryRemote(), agentWorkContext.getAgentRuntimeInfo(), "utf-8");
try {
if (this.sleepInMilliSeconds > 0) {
canceled = cancelLatch.await(this.sleepInMilliSeconds, TimeUnit.MILLISECONDS);
}
String result = canceled ? "done_canceled" : "done";
agentWorkContext.getArtifactsManipulator().setProperty(null, new Property(name + "_result", result));
SystemEnvironment systemEnvironment = new SystemEnvironment();
if (systemEnvironment.isConsoleLogsThroughWebsocketEnabled() && systemEnvironment.isWebsocketsForAgentsEnabled()) {
goPublisher.consumeLine(format("Sleeping for %s milliseconds", this.sleepInMilliSeconds));
}
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
use of com.thoughtworks.go.server.service.AgentBuildingInfo in project gocd by gocd.
the class AgentStatusReportingTest method expectedAgentRuntimeInfo.
private AgentRuntimeInfo expectedAgentRuntimeInfo() {
AgentRuntimeInfo info = new AgentRuntimeInfo(agentIdentifier, AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie", false);
info.setBuildingInfo(new AgentBuildingInfo("pipeline1/100/mingle/100/run-ant", "pipeline1/100/mingle/100/run-ant"));
info.cancel();
return info;
}
use of com.thoughtworks.go.server.service.AgentBuildingInfo in project gocd by gocd.
the class AgentInstanceTest method shouldBeAbleToDenyAgentThatIsRunningCancelledJob.
@Test
public void shouldBeAbleToDenyAgentThatIsRunningCancelledJob() {
AgentConfig config = new AgentConfig("UUID", "A", "127.0.0.1");
AgentInstance agent = new AgentInstance(config, LOCAL, systemEnvironment, mock(AgentStatusChangeListener.class));
agent.cancel();
AgentBuildingInfo cancelled = agent.getBuildingInfo();
assertThat(agent.canDisable(), is(true));
agent.deny();
assertThat(config.isDisabled(), is(true));
assertThat(agent.getStatus(), is(AgentStatus.Disabled));
assertThat(agent.getBuildingInfo(), is(cancelled));
}
use of com.thoughtworks.go.server.service.AgentBuildingInfo in project gocd by gocd.
the class AgentInstanceTest method shouldUpdateBuildingInfoWhenAgentIsBuilding.
@Test
public void shouldUpdateBuildingInfoWhenAgentIsBuilding() throws Exception {
AgentInstance agentInstance = AgentInstance.createFromConfig(agentConfig, systemEnvironment, mock(AgentStatusChangeListener.class));
AgentRuntimeInfo agentRuntimeInfo = new AgentRuntimeInfo(agentConfig.getAgentIdentifier(), AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie", false);
AgentBuildingInfo buildingInfo = new AgentBuildingInfo("running pipeline/stage/build", "buildLocator");
agentRuntimeInfo.busy(buildingInfo);
agentInstance.update(agentRuntimeInfo);
assertThat(agentInstance.getBuildingInfo(), is(buildingInfo));
}
use of com.thoughtworks.go.server.service.AgentBuildingInfo in project gocd by gocd.
the class AgentInstanceTest method shouldNotifyAgentChangeListenerOnAgentBuilding.
@Test
public void shouldNotifyAgentChangeListenerOnAgentBuilding() throws Exception {
AgentInstance idleAgent = AgentInstance.createFromConfig(agentConfig("abc"), new SystemEnvironment(), agentStatusChangeListener);
idleAgent.building(new AgentBuildingInfo("running pipeline/stage/build", "buildLocator"));
verify(agentStatusChangeListener).onAgentStatusChange(idleAgent);
}
Aggregations