Search in sources :

Example 16 with AgentBuildingInfo

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

the class AgentInstanceMother method building.

public static AgentInstance building(String buildLocator, SystemEnvironment systemEnvironment) {
    AgentConfig buildingAgentConfig = new AgentConfig("uuid3", "CCeDev01", "10.18.5.1", new ResourceConfigs("java"));
    AgentRuntimeInfo agentRuntimeInfo = new AgentRuntimeInfo(buildingAgentConfig.getAgentIdentifier(), AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie", false);
    agentRuntimeInfo.busy(new AgentBuildingInfo("pipeline", buildLocator));
    AgentInstance building = AgentInstance.createFromConfig(buildingAgentConfig, systemEnvironment, mock(AgentStatusChangeListener.class));
    building.update(agentRuntimeInfo);
    return building;
}
Also used : AgentInstance(com.thoughtworks.go.domain.AgentInstance) AgentRuntimeInfo(com.thoughtworks.go.server.service.AgentRuntimeInfo) AgentBuildingInfo(com.thoughtworks.go.server.service.AgentBuildingInfo) AgentStatusChangeListener(com.thoughtworks.go.listener.AgentStatusChangeListener)

Example 17 with AgentBuildingInfo

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

the class AgentInstanceTest method setUp.

@Before
public void setUp() {
    systemEnvironment = new SystemEnvironment();
    agentConfig = new AgentConfig("uuid2", "CCeDev01", DEFAULT_IP_ADDRESS);
    defaultBuildingInfo = new AgentBuildingInfo("pipeline", "buildLocator");
    agentStatusChangeListener = mock(AgentStatusChangeListener.class);
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) AgentConfig(com.thoughtworks.go.config.AgentConfig) AgentBuildingInfo(com.thoughtworks.go.server.service.AgentBuildingInfo) AgentStatusChangeListener(com.thoughtworks.go.listener.AgentStatusChangeListener) Before(org.junit.Before)

Example 18 with AgentBuildingInfo

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

the class AgentWebSocketClientControllerTest method processCancelBuildCommandBuild.

@Test
public void processCancelBuildCommandBuild() throws IOException, InterruptedException {
    ArgumentCaptor<Message> argumentCaptor = ArgumentCaptor.forClass(Message.class);
    agentController = createAgentController();
    agentController.init();
    agentController.getAgentRuntimeInfo().setSupportsBuildCommandProtocol(true);
    final BuildSettings build = new BuildSettings();
    build.setBuildId("b001");
    build.setConsoleUrl("http://foo.bar/console");
    build.setArtifactUploadBaseUrl("http://foo.bar/artifacts");
    build.setPropertyBaseUrl("http://foo.bar/properties");
    build.setBuildLocator("build1");
    build.setBuildLocatorForDisplay("build1ForDisplay");
    build.setConsoleLogCharset("utf-8");
    build.setBuildCommand(BuildCommand.compose(BuildSessionBasedTestCase.execSleepScript(MAX_WAIT_IN_TEST / 1000), BuildCommand.reportCurrentStatus(JobState.Building)));
    Thread buildingThread = new Thread(new Runnable() {

        @Override
        public void run() {
            try {
                agentController.process(new Message(Action.build, MessageEncoding.encodeData(build)));
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    });
    buildingThread.start();
    waitForAgentRuntimeState(agentController.getAgentRuntimeInfo(), AgentRuntimeStatus.Building);
    agentController.process(new Message(Action.cancelBuild));
    buildingThread.join(MAX_WAIT_IN_TEST);
    AgentRuntimeInfo agentRuntimeInfo = cloneAgentRuntimeInfo(agentController.getAgentRuntimeInfo());
    agentRuntimeInfo.busy(new AgentBuildingInfo("build1ForDisplay", "build1"));
    agentRuntimeInfo.cancel();
    verify(webSocketSessionHandler).sendAndWaitForAcknowledgement(argumentCaptor.capture());
    assertThat(agentController.getAgentRuntimeInfo().getRuntimeStatus(), is(AgentRuntimeStatus.Idle));
    Message message = argumentCaptor.getValue();
    assertThat(message.getAcknowledgementId(), notNullValue());
    assertThat(message.getAction(), is(Action.reportCompleted));
    assertThat(message.getData(), is(MessageEncoding.encodeData(new Report(agentRuntimeInfo, "b001", null, JobResult.Cancelled))));
}
Also used : AgentRuntimeInfo(com.thoughtworks.go.server.service.AgentRuntimeInfo) AgentBuildingInfo(com.thoughtworks.go.server.service.AgentBuildingInfo) Test(org.junit.Test)

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