use of com.thoughtworks.go.server.service.AgentRuntimeInfo in project gocd by gocd.
the class JobRunnerTest method shouldDoNothingWhenJobIsNotCancelled.
@Test
public void shouldDoNothingWhenJobIsNotCancelled() {
runner.setWork(work);
runner.handleInstruction(new AgentInstruction(false), new AgentRuntimeInfo(agentIdentifier, AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie", false));
assertThat(work.getCallCount(), is(0));
}
use of com.thoughtworks.go.server.service.AgentRuntimeInfo in project gocd by gocd.
the class AgentInstancesTest method shouldUnderstandFilteringAgentListBasedOnUuid.
@Test
public void shouldUnderstandFilteringAgentListBasedOnUuid() {
AgentInstances instances = new AgentInstances(mock(AgentStatusChangeListener.class));
AgentRuntimeInfo agent1 = AgentRuntimeInfo.fromServer(new AgentConfig("uuid-1", "host-1", "192.168.1.2"), true, "/foo/bar", 100l, "linux", false);
AgentRuntimeInfo agent2 = AgentRuntimeInfo.fromServer(new AgentConfig("uuid-2", "host-2", "192.168.1.3"), true, "/bar/baz", 200l, "linux", false);
AgentRuntimeInfo agent3 = AgentRuntimeInfo.fromServer(new AgentConfig("uuid-3", "host-3", "192.168.1.4"), true, "/baz/quux", 300l, "linux", false);
AgentInstance instance1 = AgentInstance.createFromLiveAgent(agent1, systemEnvironment, mock(AgentStatusChangeListener.class));
instances.add(instance1);
instances.add(AgentInstance.createFromLiveAgent(agent2, systemEnvironment, mock(AgentStatusChangeListener.class)));
AgentInstance instance3 = AgentInstance.createFromLiveAgent(agent3, systemEnvironment, mock(AgentStatusChangeListener.class));
instances.add(instance3);
List<AgentInstance> agents = instances.filter(Arrays.asList("uuid-1", "uuid-3"));
assertThat(agents, hasItems(instance1, instance3));
assertThat(agents.size(), is(2));
}
use of com.thoughtworks.go.server.service.AgentRuntimeInfo in project gocd by gocd.
the class ReportTest method encodeAndDecodeAsMessageData.
@Test
public void encodeAndDecodeAsMessageData() throws Exception {
AgentRuntimeInfo info = new AgentRuntimeInfo(new AgentIdentifier("HostName", "ipAddress", "uuid"), AgentRuntimeStatus.Idle, null, null, true);
JobIdentifier jobIdentifier = new JobIdentifier("pipeline", 1, "pipelinelabel", "stagename", "1", "job", 1L);
Report report = new Report(info, jobIdentifier, JobResult.Passed);
assertThat(MessageEncoding.decodeData(MessageEncoding.encodeData(report), Report.class), is(report));
}
use of com.thoughtworks.go.server.service.AgentRuntimeInfo in project gocd by gocd.
the class BuildWorkTest method shouldRunTasksBasedOnConditions.
@Test
public void shouldRunTasksBasedOnConditions() throws Exception {
buildWork = (BuildWork) getWork(MULTIPLE_TASKS, PIPELINE_NAME);
buildWork.doWork(environmentVariableContext, new AgentWorkContext(agentIdentifier, buildRepository, artifactManipulator, new AgentRuntimeInfo(agentIdentifier, AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie", false), packageRepositoryExtension, scmExtension, taskExtension, null, pluginRequestProcessorRegistry));
String actual = artifactManipulator.consoleOut();
assertThat(actual, containsString("run when status is failed"));
assertThat(actual, printedExcRunIfInfo("command-not-found", "passed"));
assertThat(actual, containsString("run when status is any"));
assertThat(actual, printedExcRunIfInfo("echo", "run when status is any", "failed"));
assertThat(actual, not(containsString("run when status is passed")));
assertThat(actual, not(printedExcRunIfInfo("echo", "run when status is passed", "failed")));
assertThat(actual, not(containsString("run when status is cancelled")));
assertThat(actual, not(printedExcRunIfInfo("echo", "run when status is cancelled", "failed")));
}
use of com.thoughtworks.go.server.service.AgentRuntimeInfo in project gocd by gocd.
the class BuildWorkTest method shouldRunTaskWhenConditionMatches.
@Test
public void shouldRunTaskWhenConditionMatches() throws Exception {
buildWork = (BuildWork) getWork(MULTIPLE_RUN_IFS, PIPELINE_NAME);
buildWork.doWork(environmentVariableContext, new AgentWorkContext(agentIdentifier, buildRepository, artifactManipulator, new AgentRuntimeInfo(agentIdentifier, AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie", false), packageRepositoryExtension, scmExtension, taskExtension, null, pluginRequestProcessorRegistry));
String actual = artifactManipulator.consoleOut();
assertThat(actual, containsString("[go] Task: echo run when status is failed, passed or cancelled"));
assertThat(actual, matches("\\[go] Task status: passed \\(\\d+ ms\\)"));
assertThat(actual, containsString("[go] Current job status: passed"));
assertThat(actual, containsString("run when status is failed, passed or cancelled"));
}
Aggregations