use of com.thoughtworks.go.server.service.AgentRuntimeInfo in project gocd by gocd.
the class BuildWorkArtifactUploadingTest method shouldUploadFolderWhenDirectMatch.
@Test
public void shouldUploadFolderWhenDirectMatch() throws Exception {
List<ArtifactPlan> artifactPlans = new ArrayList<>();
artifactPlans.add(new ArtifactPlan(ArtifactPlanType.file, "logs/pic-1", "mypic"));
BuildAssignment buildAssigment = createAssignment(artifactPlans, new String[] { "logs/pic-1/fail.png", "logs/pic-1/pass.png", "logs/pic-2/cancel.png", "logs/pic-2/complete.png", "README" });
BuildWork work = new BuildWork(buildAssigment, StandardCharsets.UTF_8.name());
GoArtifactsManipulatorStub manipulator = new GoArtifactsManipulatorStub();
AgentIdentifier agentIdentifier = new AgentIdentifier("somename", "127.0.0.1", AGENT_UUID);
work.doWork(environmentVariableContext, new AgentWorkContext(agentIdentifier, new FakeBuildRepositoryRemote(), manipulator, new AgentRuntimeInfo(agentIdentifier, AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie"), packageRepositoryExtension, scmExtension, taskExtension, null, pluginRequestProcessorRegistry));
List<UploadEntry> entries = manipulator.uploadEntries();
assertThat(entries, uploadFileToDestination(new File(buildWorkingDirectory.getPath() + "/logs/pic-1"), "mypic"));
}
use of com.thoughtworks.go.server.service.AgentRuntimeInfo in project gocd by gocd.
the class BuildWorkArtifactUploadingTest method shouldUploadFolderWhenTrimedPathDirectMatch.
@Test
public void shouldUploadFolderWhenTrimedPathDirectMatch() throws Exception {
List<ArtifactPlan> artifactPlans = new ArrayList<>();
artifactPlans.add(new ArtifactPlan(ArtifactPlanType.file, "logs/pic-1 ", "mypic"));
BuildAssignment buildAssigment = createAssignment(artifactPlans, new String[] { "logs/pic-1/fail.png", "logs/pic-1/pass.png", "logs/pic-2/cancel.png", "logs/pic-2/complete.png", "README" });
BuildWork work = new BuildWork(buildAssigment, StandardCharsets.UTF_8.name());
GoArtifactsManipulatorStub manipulator = new GoArtifactsManipulatorStub();
AgentIdentifier agentIdentifier = new AgentIdentifier("somename", "127.0.0.1", AGENT_UUID);
work.doWork(environmentVariableContext, new AgentWorkContext(agentIdentifier, new FakeBuildRepositoryRemote(), manipulator, new AgentRuntimeInfo(agentIdentifier, AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie"), packageRepositoryExtension, scmExtension, taskExtension, null, pluginRequestProcessorRegistry));
List<UploadEntry> entries = manipulator.uploadEntries();
assertThat(entries, uploadFileToDestination(new File(buildWorkingDirectory.getPath() + "/logs/pic-1"), "mypic"));
}
use of com.thoughtworks.go.server.service.AgentRuntimeInfo in project gocd by gocd.
the class AgentStatusReportTest method before.
@BeforeEach
public void before() {
agentIdentifier = new AgentIdentifier("localhost", "127.0.0.1", "uuid");
environmentVariableContext = new EnvironmentVariableContext();
artifactManipulator = new GoArtifactsManipulatorStub();
buildRepository = new BuildRepositoryRemoteStub();
this.agentRuntimeInfo = new AgentRuntimeInfo(agentIdentifier, AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie");
}
use of com.thoughtworks.go.server.service.AgentRuntimeInfo in project gocd by gocd.
the class WorkFinderTest method shouldReturnNoWorkInCaseOfAnErrorIsThrown.
@Test
public void shouldReturnNoWorkInCaseOfAnErrorIsThrown() {
BuildAssignmentService assigner = mock(BuildAssignmentService.class);
IdleAgentTopic idleTopic = mock(IdleAgentTopic.class);
WorkAssignedTopic assignedTopic = mock(WorkAssignedTopic.class);
WorkFinder finder = new WorkFinder(assigner, idleTopic, assignedTopic, workAssignmentPerformanceLogger);
AgentRuntimeInfo runtimeInfo = AgentRuntimeInfo.initialState(AgentMother.approvedAgent());
when(assigner.assignWorkToAgent(runtimeInfo.getIdentifier())).thenThrow(new OutOfMemoryError("test error for martians"));
try {
finder.onMessage(new IdleAgentMessage(runtimeInfo));
fail("should have propagated error");
} catch (OutOfMemoryError e) {
String message = e.getMessage();
if (message != null && message.equals("test error for martians")) {
// expected
} else {
throw e;
}
}
verify(assignedTopic).post(new WorkAssignedMessage(runtimeInfo.getIdentifier(), new NoWork()));
}
use of com.thoughtworks.go.server.service.AgentRuntimeInfo in project gocd by gocd.
the class AgentInstanceTest method shouldBecomeIdleAfterApprove.
@Test
void shouldBecomeIdleAfterApprove() {
AgentInstance instance = createFromLiveAgent(new AgentRuntimeInfo(agent.getAgentIdentifier(), AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie"), systemEnvironment, mock(AgentStatusChangeListener.class));
instance.enable();
instance.update(new AgentRuntimeInfo(agent.getAgentIdentifier(), AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie"));
assertThat(instance.getStatus()).isEqualTo(AgentStatus.Idle);
}
Aggregations