Search in sources :

Example 11 with AgentBuildingInfo

use of com.thoughtworks.go.server.service.AgentBuildingInfo in project gocd by gocd.

the class BuildWork method initialize.

private void initialize(BuildRepositoryRemote remoteBuildRepository, GoArtifactsManipulator goArtifactsManipulator, AgentRuntimeInfo agentRuntimeInfo, TaskExtension taskExtension) {
    timeProvider = new TimeProvider();
    plan = assignment.getPlan();
    agentRuntimeInfo.busy(new AgentBuildingInfo(plan.getIdentifier().buildLocatorForDisplay(), plan.getIdentifier().buildLocator()));
    workingDirectory = assignment.getWorkingDirectory();
    materialRevisions = assignment.materialRevisions();
    buildLog = new GoControlLog(this.workingDirectory + "/cruise-output");
    goPublisher = new DefaultGoPublisher(goArtifactsManipulator, plan.getIdentifier(), remoteBuildRepository, agentRuntimeInfo);
    builders = new Builders(assignment.getBuilders(), goPublisher, buildLog, taskExtension);
}
Also used : AgentBuildingInfo(com.thoughtworks.go.server.service.AgentBuildingInfo) TimeProvider(com.thoughtworks.go.util.TimeProvider) DefaultGoPublisher(com.thoughtworks.go.work.DefaultGoPublisher)

Example 12 with AgentBuildingInfo

use of com.thoughtworks.go.server.service.AgentBuildingInfo in project gocd by gocd.

the class SleepWork method doWork.

@Override
public void doWork(AgentIdentifier agentIdentifier, BuildRepositoryRemote remoteBuildRepository, GoArtifactsManipulator manipulator, EnvironmentVariableContext environmentVariableContext, AgentRuntimeInfo agentRuntimeInfo, PackageRepositoryExtension packageRepositoryExtension, SCMExtension scmExtension, TaskExtension taskExtension) {
    cancelLatch = new CountDownLatch(1);
    agentRuntimeInfo.busy(new AgentBuildingInfo("sleepwork", "sleepwork1"));
    boolean canceled = false;
    DefaultGoPublisher goPublisher = new DefaultGoPublisher(manipulator, new JobIdentifier(), remoteBuildRepository, agentRuntimeInfo);
    try {
        if (this.sleepInMilliSeconds > 0) {
            canceled = cancelLatch.await(this.sleepInMilliSeconds, TimeUnit.MILLISECONDS);
        }
        String result = canceled ? "done_canceled" : "done";
        manipulator.setProperty(null, new Property(name + "_result", result));
        SystemEnvironment systemEnvironment = new SystemEnvironment();
        if (systemEnvironment.isConsoleLogsThroughWebsocketEnabled() && systemEnvironment.isWebsocketsForAgentsEnabled()) {
            goPublisher.consumeLine(format("Sleeping for %s milliseconds", this.sleepInMilliSeconds));
        }
    } catch (InterruptedException e) {
        throw new RuntimeException(e);
    }
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) AgentBuildingInfo(com.thoughtworks.go.server.service.AgentBuildingInfo) JobIdentifier(com.thoughtworks.go.domain.JobIdentifier) CountDownLatch(java.util.concurrent.CountDownLatch) Property(com.thoughtworks.go.domain.Property)

Example 13 with AgentBuildingInfo

use of com.thoughtworks.go.server.service.AgentBuildingInfo in project gocd by gocd.

the class AgentStatusReportingIntegrationTest method expectedAgentRuntimeInfo.

private AgentRuntimeInfo expectedAgentRuntimeInfo() {
    AgentRuntimeInfo info = new AgentRuntimeInfo(agentIdentifier, AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie", false);
    info.setBuildingInfo(new AgentBuildingInfo("pipeline1/100/mingle/100/run-ant", "pipeline1/100/mingle/100/run-ant"));
    info.cancel();
    return info;
}
Also used : AgentRuntimeInfo(com.thoughtworks.go.server.service.AgentRuntimeInfo) AgentBuildingInfo(com.thoughtworks.go.server.service.AgentBuildingInfo)

Example 14 with AgentBuildingInfo

use of com.thoughtworks.go.server.service.AgentBuildingInfo in project gocd by gocd.

the class AgentStatusReportingTest method shouldReportBuildingWhenAgentRunningBuildWork.

@Test
public void shouldReportBuildingWhenAgentRunningBuildWork() throws Exception {
    Work work = BuildWorkTest.getWork(WILL_PASS, BuildWorkTest.PIPELINE_NAME);
    work.doWork(environmentVariableContext, new AgentWorkContext(agentIdentifier, buildRepository, artifactManipulator, agentRuntimeInfo, null, null, null, null, null));
    AgentRuntimeInfo agentRuntimeInfo1 = new AgentRuntimeInfo(agentIdentifier, AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie", false);
    agentRuntimeInfo1.busy(new AgentBuildingInfo("pipeline1/100/mingle/100/run-ant", "pipeline1/100/mingle/100/run-ant"));
    assertThat(agentRuntimeInfo, is(agentRuntimeInfo1));
}
Also used : AgentRuntimeInfo(com.thoughtworks.go.server.service.AgentRuntimeInfo) AgentBuildingInfo(com.thoughtworks.go.server.service.AgentBuildingInfo) Test(org.junit.Test)

Example 15 with AgentBuildingInfo

use of com.thoughtworks.go.server.service.AgentBuildingInfo in project gocd by gocd.

the class AgentInstanceMother method lostContact.

public static AgentInstance lostContact(String buildLocator) {
    AgentConfig agentConfig = new AgentConfig("1234", "localhost", "192.168.0.1");
    AgentInstance instance = AgentInstance.createFromConfig(agentConfig, new SystemEnvironment(), mock(AgentStatusChangeListener.class));
    AgentRuntimeInfo newRuntimeInfo = AgentRuntimeInfo.initialState(agentConfig);
    newRuntimeInfo.setStatus(AgentStatus.LostContact);
    newRuntimeInfo.setUsableSpace(1000L);
    newRuntimeInfo.setBuildingInfo(new AgentBuildingInfo("buildInfo", buildLocator));
    instance.update(newRuntimeInfo);
    return instance;
}
Also used : AgentInstance(com.thoughtworks.go.domain.AgentInstance) SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) AgentRuntimeInfo(com.thoughtworks.go.server.service.AgentRuntimeInfo) AgentBuildingInfo(com.thoughtworks.go.server.service.AgentBuildingInfo) AgentStatusChangeListener(com.thoughtworks.go.listener.AgentStatusChangeListener)

Aggregations

AgentBuildingInfo (com.thoughtworks.go.server.service.AgentBuildingInfo)18 AgentRuntimeInfo (com.thoughtworks.go.server.service.AgentRuntimeInfo)10 Test (org.junit.Test)8 AgentStatusChangeListener (com.thoughtworks.go.listener.AgentStatusChangeListener)5 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)5 AgentConfig (com.thoughtworks.go.config.AgentConfig)2 AgentInstance (com.thoughtworks.go.domain.AgentInstance)2 JobIdentifier (com.thoughtworks.go.domain.JobIdentifier)2 Property (com.thoughtworks.go.domain.Property)2 TimeProvider (com.thoughtworks.go.util.TimeProvider)2 DefaultGoPublisher (com.thoughtworks.go.work.DefaultGoPublisher)2 CountDownLatch (java.util.concurrent.CountDownLatch)2 ArtifactsRepository (com.thoughtworks.go.buildsession.ArtifactsRepository)1 BuildSession (com.thoughtworks.go.buildsession.BuildSession)1 BuildVariables (com.thoughtworks.go.buildsession.BuildVariables)1 ConsoleOutputTransmitter (com.thoughtworks.go.remote.work.ConsoleOutputTransmitter)1 RemoteConsoleAppender (com.thoughtworks.go.remote.work.RemoteConsoleAppender)1 ArtifactsPublisher (com.thoughtworks.go.remote.work.artifact.ArtifactsPublisher)1 TaggedStreamConsumer (com.thoughtworks.go.util.command.TaggedStreamConsumer)1 File (java.io.File)1