Search in sources :

Example 81 with AgentRuntimeInfo

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()));
}
Also used : AgentRuntimeInfo(com.thoughtworks.go.server.service.AgentRuntimeInfo) ByteArrayInputStream(java.io.ByteArrayInputStream) AgentIdentifier(com.thoughtworks.go.remote.AgentIdentifier) Test(org.junit.Test)

Example 82 with AgentRuntimeInfo

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");
}
Also used : AgentRuntimeInfo(com.thoughtworks.go.server.service.AgentRuntimeInfo) DefaultGoPublisher(com.thoughtworks.go.work.DefaultGoPublisher) HttpService(com.thoughtworks.go.util.HttpService) AgentIdentifier(com.thoughtworks.go.remote.AgentIdentifier) GoArtifactsManipulatorStub(com.thoughtworks.go.remote.work.GoArtifactsManipulatorStub) JobIdentifier(com.thoughtworks.go.domain.JobIdentifier) BuildRepositoryRemoteStub(com.thoughtworks.go.remote.work.BuildRepositoryRemoteStub) Before(org.junit.Before)

Example 83 with AgentRuntimeInfo

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"));
}
Also used : AgentRuntimeInfo(com.thoughtworks.go.server.service.AgentRuntimeInfo) UploadEntry(com.thoughtworks.go.matchers.UploadEntry) ArrayList(java.util.ArrayList) FakeBuildRepositoryRemote(com.thoughtworks.go.agent.testhelpers.FakeBuildRepositoryRemote) AgentIdentifier(com.thoughtworks.go.remote.AgentIdentifier) File(java.io.File) Test(org.junit.Test)

Example 84 with AgentRuntimeInfo

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"));
}
Also used : AgentRuntimeInfo(com.thoughtworks.go.server.service.AgentRuntimeInfo) UploadEntry(com.thoughtworks.go.matchers.UploadEntry) ArrayList(java.util.ArrayList) AgentIdentifier(com.thoughtworks.go.remote.AgentIdentifier) Test(org.junit.Test)

Example 85 with AgentRuntimeInfo

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")));
}
Also used : AgentRuntimeInfo(com.thoughtworks.go.server.service.AgentRuntimeInfo) UploadEntry(com.thoughtworks.go.matchers.UploadEntry) ArrayList(java.util.ArrayList) FakeBuildRepositoryRemote(com.thoughtworks.go.agent.testhelpers.FakeBuildRepositoryRemote) AgentIdentifier(com.thoughtworks.go.remote.AgentIdentifier) File(java.io.File) Test(org.junit.Test)

Aggregations

AgentRuntimeInfo (com.thoughtworks.go.server.service.AgentRuntimeInfo)123 Test (org.junit.Test)101 AgentIdentifier (com.thoughtworks.go.remote.AgentIdentifier)34 AgentStatusChangeListener (com.thoughtworks.go.listener.AgentStatusChangeListener)26 File (java.io.File)16 AgentInstruction (com.thoughtworks.go.remote.AgentInstruction)13 StringContains.containsString (org.hamcrest.core.StringContains.containsString)13 FakeBuildRepositoryRemote (com.thoughtworks.go.agent.testhelpers.FakeBuildRepositoryRemote)12 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)11 UploadEntry (com.thoughtworks.go.matchers.UploadEntry)10 AgentBuildingInfo (com.thoughtworks.go.server.service.AgentBuildingInfo)10 ArrayList (java.util.ArrayList)10 EnvironmentVariableContext (com.thoughtworks.go.util.command.EnvironmentVariableContext)9 AgentInstance (com.thoughtworks.go.domain.AgentInstance)7 Before (org.junit.Before)7 Expectations (org.jmock.Expectations)4 RunIf (com.googlecode.junit.ext.RunIf)3 AgentConfig (com.thoughtworks.go.config.AgentConfig)3 Date (java.util.Date)3 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)3