Search in sources :

Example 31 with AgentRuntimeInfo

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"));
}
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.jupiter.api.Test)

Example 32 with AgentRuntimeInfo

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"));
}
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.jupiter.api.Test)

Example 33 with AgentRuntimeInfo

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");
}
Also used : AgentRuntimeInfo(com.thoughtworks.go.server.service.AgentRuntimeInfo) AgentIdentifier(com.thoughtworks.go.remote.AgentIdentifier) EnvironmentVariableContext(com.thoughtworks.go.util.command.EnvironmentVariableContext) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 34 with AgentRuntimeInfo

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()));
}
Also used : AgentRuntimeInfo(com.thoughtworks.go.server.service.AgentRuntimeInfo) NoWork(com.thoughtworks.go.remote.work.NoWork) BuildAssignmentService(com.thoughtworks.go.server.service.BuildAssignmentService) Test(org.junit.jupiter.api.Test)

Example 35 with AgentRuntimeInfo

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);
}
Also used : AgentRuntimeInfo(com.thoughtworks.go.server.service.AgentRuntimeInfo) AgentStatusChangeListener(com.thoughtworks.go.listener.AgentStatusChangeListener) Test(org.junit.jupiter.api.Test)

Aggregations

AgentRuntimeInfo (com.thoughtworks.go.server.service.AgentRuntimeInfo)150 Test (org.junit.jupiter.api.Test)70 Test (org.junit.Test)52 AgentIdentifier (com.thoughtworks.go.remote.AgentIdentifier)35 AgentStatusChangeListener (com.thoughtworks.go.listener.AgentStatusChangeListener)29 File (java.io.File)17 RemoteInvocation (org.springframework.remoting.support.RemoteInvocation)16 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)14 Agent (com.thoughtworks.go.config.Agent)13 AgentInstruction (com.thoughtworks.go.remote.AgentInstruction)13 FakeBuildRepositoryRemote (com.thoughtworks.go.agent.testhelpers.FakeBuildRepositoryRemote)12 AgentInstance.createFromLiveAgent (com.thoughtworks.go.domain.AgentInstance.createFromLiveAgent)11 JobIdentifier (com.thoughtworks.go.domain.JobIdentifier)11 AgentBuildingInfo (com.thoughtworks.go.server.service.AgentBuildingInfo)11 UploadEntry (com.thoughtworks.go.matchers.UploadEntry)10 ArrayList (java.util.ArrayList)10 StringContains.containsString (org.hamcrest.core.StringContains.containsString)9 AgentInstance (com.thoughtworks.go.domain.AgentInstance)8 EnvironmentVariableContext (com.thoughtworks.go.util.command.EnvironmentVariableContext)8 NullAgentInstance (com.thoughtworks.go.domain.NullAgentInstance)7