use of com.thoughtworks.go.server.service.AgentRuntimeInfo in project gocd by gocd.
the class MessageTest method encodeAndDecodePingMessage.
@Test
public void encodeAndDecodePingMessage() {
AgentRuntimeInfo info = new AgentRuntimeInfo(new AgentIdentifier("hostName", "ipAddress", "uuid"), null, null, null, false);
byte[] msg = MessageEncoding.encodeMessage(new Message(Action.ping, MessageEncoding.encodeData(info)));
Message decoded = MessageEncoding.decodeMessage(new ByteArrayInputStream(msg));
AgentRuntimeInfo decodedInfo = MessageEncoding.decodeData(decoded.getData(), AgentRuntimeInfo.class);
assertThat(decodedInfo.getIdentifier(), is(info.getIdentifier()));
}
use of com.thoughtworks.go.server.service.AgentRuntimeInfo in project gocd by gocd.
the class GoArtifactsManipulatorTest method setUp.
@Before
public void setUp() throws Exception {
httpService = mock(HttpService.class);
artifactFolder = temporaryFolder.newFolder("artifact_folder");
tempFile = temporaryFolder.newFile("artifact_folder/file.txt");
goArtifactsManipulatorStub = new GoArtifactsManipulatorStub(httpService);
jobIdentifier = new JobIdentifier("pipeline1", 1, "label-1", "stage1", "1", "job1");
AgentRuntimeInfo agentRuntimeInfo = new AgentRuntimeInfo(new AgentIdentifier("h", "1", "u"), AgentRuntimeStatus.Idle, currentWorkingDirectory(), null, false);
goPublisher = new DefaultGoPublisher(goArtifactsManipulatorStub, jobIdentifier, new BuildRepositoryRemoteStub(), agentRuntimeInfo, "utf-8");
}
use of com.thoughtworks.go.server.service.AgentRuntimeInfo in project gocd by gocd.
the class BuildWorkArtifactUploadingTest method shouldUploadFolderWhenMatchedWithWildCards.
@Test
public void shouldUploadFolderWhenMatchedWithWildCards() throws Exception {
List<ArtifactPlan> artifactPlans = new ArrayList<>();
artifactPlans.add(new ArtifactPlan(ArtifactType.file, "logs/pic-*", "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, systemEnvironment.consoleLogCharset());
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", false), packageRepositoryExtension, scmExtension, taskExtension, null, pluginRequestProcessorRegistry));
List<UploadEntry> entries = manipulator.uploadEntries();
assertThat(entries, not(uploadFileToDestination(new File(buildWorkingDirectory.getPath() + "/logs/pic-1/pass.png"), "mypic")));
assertThat(entries, not(uploadFileToDestination(new File(buildWorkingDirectory.getPath() + "/logs/pic-1/fail.png"), "mypic")));
assertThat(entries, not(uploadFileToDestination(new File(buildWorkingDirectory.getPath() + "/logs/pic-2/cancel.png"), "mypic")));
assertThat(entries, not(uploadFileToDestination(new File(buildWorkingDirectory.getPath() + "/logs/pic-2/complete.png"), "mypic")));
assertThat(entries, uploadFileToDestination(new File(buildWorkingDirectory.getPath() + "/logs/pic-1"), "mypic"));
assertThat(entries, uploadFileToDestination(new File(buildWorkingDirectory.getPath() + "/logs/pic-2"), "mypic"));
}
use of com.thoughtworks.go.server.service.AgentRuntimeInfo in project gocd by gocd.
the class BuildWorkArtifactUploadingTest method shouldFailBuildWhenNothingMatched.
@Test
public void shouldFailBuildWhenNothingMatched() throws Exception {
List<ArtifactPlan> artifactPlans = new ArrayList<>();
artifactPlans.add(new ArtifactPlan(ArtifactType.file, "logs/picture", "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, systemEnvironment.consoleLogCharset());
GoArtifactsManipulatorStub manipulator = new GoArtifactsManipulatorStub();
BuildRepositoryRemoteStub repository = new BuildRepositoryRemoteStub();
AgentIdentifier agentIdentifier = new AgentIdentifier("somename", "127.0.0.1", AGENT_UUID);
work.doWork(environmentVariableContext, new AgentWorkContext(agentIdentifier, repository, manipulator, new AgentRuntimeInfo(agentIdentifier, AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie", false), packageRepositoryExtension, scmExtension, taskExtension, null, pluginRequestProcessorRegistry));
List<UploadEntry> entries = manipulator.uploadEntries();
assertThat(entries.size(), is(0));
assertThat(repository.states, containsResult(JobState.Building));
assertThat(repository.states, containsResult(JobState.Completing));
assertThat(repository.results, containsResult(JobResult.Failed));
assertThat(manipulator.consoleOut(), printedRuleDoesNotMatchFailure(buildWorkingDirectory.getPath(), "logs/picture"));
}
use of com.thoughtworks.go.server.service.AgentRuntimeInfo in project gocd by gocd.
the class BuildWorkArtifactUploadingTest method shouldNotUploadFileContainingFolderAgain.
@Test
public void shouldNotUploadFileContainingFolderAgain() throws Exception {
List<ArtifactPlan> artifactPlans = new ArrayList<>();
artifactPlans.add(new ArtifactPlan(ArtifactType.file, "logs/pic/*.png", "mypic"));
BuildAssignment buildAssigment = createAssignment(artifactPlans, new String[] { "logs/pic/fail.png", "logs/pic/pass.png", "README" });
BuildWork work = new BuildWork(buildAssigment, systemEnvironment.consoleLogCharset());
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", false), packageRepositoryExtension, scmExtension, taskExtension, null, pluginRequestProcessorRegistry));
List<UploadEntry> entries = manipulator.uploadEntries();
assertThat(entries, uploadFileToDestination(new File(buildWorkingDirectory.getPath() + "/logs/pic/pass.png"), "mypic"));
assertThat(entries, uploadFileToDestination(new File(buildWorkingDirectory.getPath() + "/logs/pic/fail.png"), "mypic"));
assertThat(entries, not(uploadFileToDestination(new File(buildWorkingDirectory.getPath() + "/logs/pic"), "mypic")));
}
Aggregations