use of com.thoughtworks.go.server.service.AgentRuntimeInfo in project gocd by gocd.
the class BuildWorkEnvironmentVariablesTest method shouldSetUpP4ClientEnvironmentVariableEnvironmentContextCorrectly.
@Test
public void shouldSetUpP4ClientEnvironmentVariableEnvironmentContextCorrectly() {
new SystemEnvironment().setProperty("serviceUrl", "some_random_place");
BuildWork work = getBuildWorkWithP4MaterialRevision(p4Material);
EnvironmentVariableContext environmentVariableContext = new EnvironmentVariableContext();
AgentIdentifier agentIdentifier = new AgentIdentifier("somename", "127.0.0.1", AGENT_UUID);
work.doWork(environmentVariableContext, new AgentWorkContext(agentIdentifier, new FakeBuildRepositoryRemote(), new GoArtifactsManipulatorStub(), new AgentRuntimeInfo(agentIdentifier, AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie", false), packageRepositoryExtension, scmExtension, taskExtension, null, null));
assertThat(environmentVariableContext.getProperty("GO_REVISION"), is("10"));
assertThat(environmentVariableContext.getProperty("GO_SERVER_URL"), is("some_random_place"));
assertThat(environmentVariableContext.getProperty("GO_TRIGGER_USER"), is(TRIGGERED_BY_USER));
assertThat(environmentVariableContext.getProperty("GO_P4_CLIENT"), is(p4Material.clientName(dir)));
}
use of com.thoughtworks.go.server.service.AgentRuntimeInfo in project gocd by gocd.
the class AgentRemoteHandler method processWithoutAcknowledgement.
public void processWithoutAcknowledgement(Agent agent, Message msg) throws Exception {
switch(msg.getAction()) {
case ping:
AgentRuntimeInfo info = MessageEncoding.decodeData(msg.getData(), AgentRuntimeInfo.class);
if (!sessionIds.containsKey(agent)) {
LOGGER.info("{} is connected with websocket {}", info.getIdentifier(), agent);
sessionIds.put(agent, info.getUUId());
this.agentSessions.put(info.getUUId(), agent);
}
if (info.getCookie() == null) {
String cookie = agentCookie.get(agent);
if (cookie == null) {
cookie = buildRepositoryRemote.getCookie(info.getIdentifier(), info.getLocation());
agentCookie.put(agent, cookie);
}
info.setCookie(cookie);
agent.send(new Message(Action.setCookie, MessageEncoding.encodeData(cookie)));
}
AgentInstruction instruction = this.buildRepositoryRemote.ping(info);
if (instruction.isShouldCancelJob()) {
agent.send(new Message(Action.cancelBuild));
}
break;
case reportCurrentStatus:
Report report = MessageEncoding.decodeData(msg.getData(), Report.class);
buildRepositoryRemote.reportCurrentStatus(report.getAgentRuntimeInfo(), findJobIdentifier(report), report.getJobState());
break;
case reportCompleting:
report = MessageEncoding.decodeData(msg.getData(), Report.class);
buildRepositoryRemote.reportCompleting(report.getAgentRuntimeInfo(), findJobIdentifier(report), report.getResult());
break;
case reportCompleted:
report = MessageEncoding.decodeData(msg.getData(), Report.class);
buildRepositoryRemote.reportCompleted(report.getAgentRuntimeInfo(), findJobIdentifier(report), report.getResult());
break;
case consoleOut:
ConsoleTransmission consoleTransmission = MessageEncoding.decodeData(msg.getData(), ConsoleTransmission.class);
File consoleLogFile = consoleService.consoleLogFile(findJobIdentifier(consoleTransmission));
consoleService.updateConsoleLog(consoleLogFile, consoleTransmission.getLineAsStream());
break;
default:
throw new RuntimeException("Unknown action: " + msg.getAction());
}
}
use of com.thoughtworks.go.server.service.AgentRuntimeInfo in project gocd by gocd.
the class AgentInstanceMother method updateOS.
public static AgentInstance updateOS(AgentInstance agentInstance, String operatingSystem) {
AgentConfig agentConfig = agentInstance.agentConfig();
AgentRuntimeInfo newRuntimeInfo = AgentRuntimeInfo.fromServer(agentConfig, true, agentInstance.getLocation(), agentInstance.getUsableSpace(), operatingSystem, false);
newRuntimeInfo.setStatus(agentInstance.getStatus());
agentInstance.update(newRuntimeInfo);
return agentInstance;
}
use of com.thoughtworks.go.server.service.AgentRuntimeInfo in project gocd by gocd.
the class AgentInstanceMother method missing.
public static AgentInstance missing() {
AgentConfig agentConfig = new AgentConfig("1234", "localhost", "192.168.0.1");
AgentInstance instance = AgentInstance.createFromConfig(agentConfig, new SystemEnvironment(), mock(AgentStatusChangeListener.class));
AgentRuntimeInfo newRuntimeInfo = AgentRuntimeInfo.initialState(agentConfig);
newRuntimeInfo.setStatus(AgentStatus.Missing);
instance.update(newRuntimeInfo);
return instance;
}
use of com.thoughtworks.go.server.service.AgentRuntimeInfo in project gocd by gocd.
the class AgentInstanceMother method lostContact.
public static AgentInstance lostContact(String buildLocator) {
AgentConfig agentConfig = new AgentConfig("1234", "localhost", "192.168.0.1");
AgentInstance instance = AgentInstance.createFromConfig(agentConfig, new SystemEnvironment(), mock(AgentStatusChangeListener.class));
AgentRuntimeInfo newRuntimeInfo = AgentRuntimeInfo.initialState(agentConfig);
newRuntimeInfo.setStatus(AgentStatus.LostContact);
newRuntimeInfo.setUsableSpace(1000L);
newRuntimeInfo.setBuildingInfo(new AgentBuildingInfo("buildInfo", buildLocator));
instance.update(newRuntimeInfo);
return instance;
}
Aggregations