Search in sources :

Example 66 with AgentRuntimeInfo

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

the class AgentInstanceMother method missing.

public static AgentInstance missing() {
    AgentConfig agentConfig = new AgentConfig("1234", "localhost", "192.168.0.1");
    AgentInstance instance = AgentInstance.createFromConfig(agentConfig, new SystemEnvironment());
    AgentRuntimeInfo newRuntimeInfo = AgentRuntimeInfo.initialState(agentConfig);
    newRuntimeInfo.setStatus(AgentStatus.Missing);
    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)

Example 67 with AgentRuntimeInfo

use of com.thoughtworks.go.server.service.AgentRuntimeInfo 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 Resources("java"));
    AgentRuntimeInfo agentRuntimeInfo = new AgentRuntimeInfo(buildingAgentConfig.getAgentIdentifier(), AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie", false);
    agentRuntimeInfo.busy(new AgentBuildingInfo("pipeline", buildLocator));
    AgentInstance building = AgentInstance.createFromConfig(buildingAgentConfig, systemEnvironment);
    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)

Example 68 with AgentRuntimeInfo

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

the class AgentInstanceMother method pending.

public static AgentInstance pending(SystemEnvironment systemEnvironment) {
    AgentRuntimeInfo runtimeInfo = AgentRuntimeInfo.fromServer(new AgentConfig("uuid4", "CCeDev03", "10.18.5.3", new Resources(new Resource("db"), new Resource("web"))), false, "/var/lib", 0L, "linux", false);
    AgentInstance pending = AgentInstance.createFromLiveAgent(runtimeInfo, systemEnvironment);
    pending.pending();
    pending.update(runtimeInfo);
    pending.pending();
    return pending;
}
Also used : AgentInstance(com.thoughtworks.go.domain.AgentInstance) AgentRuntimeInfo(com.thoughtworks.go.server.service.AgentRuntimeInfo)

Example 69 with AgentRuntimeInfo

use of com.thoughtworks.go.server.service.AgentRuntimeInfo 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());
    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)

Example 70 with AgentRuntimeInfo

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

the class AgentRemoteHandler method processWithoutAcknowledgement.

public void processWithoutAcknowledgement(Agent agent, Message msg) throws Exception {
    switch(msg.getAction()) {
        case ping:
            AgentRuntimeInfo info = MessageEncoding.decodeData(msg.getData(), AgentRuntimeInfo.class);
            if (!sessionIds.containsKey(agent)) {
                LOGGER.info("{} is connected with websocket {}", info.getIdentifier(), agent);
                sessionIds.put(agent, info.getUUId());
                this.agentSessions.put(info.getUUId(), agent);
            }
            if (info.getCookie() == null) {
                String cookie = agentCookie.get(agent);
                if (cookie == null) {
                    cookie = buildRepositoryRemote.getCookie(info.getIdentifier(), info.getLocation());
                    agentCookie.put(agent, cookie);
                }
                info.setCookie(cookie);
                agent.send(new Message(Action.setCookie, MessageEncoding.encodeData(cookie)));
            }
            AgentInstruction instruction = this.buildRepositoryRemote.ping(info);
            if (instruction.isShouldCancelJob()) {
                agent.send(new Message(Action.cancelBuild));
            }
            break;
        case reportCurrentStatus:
            Report report = MessageEncoding.decodeData(msg.getData(), Report.class);
            buildRepositoryRemote.reportCurrentStatus(report.getAgentRuntimeInfo(), findJobIdentifier(report), report.getJobState());
            break;
        case reportCompleting:
            report = MessageEncoding.decodeData(msg.getData(), Report.class);
            buildRepositoryRemote.reportCompleting(report.getAgentRuntimeInfo(), findJobIdentifier(report), report.getResult());
            break;
        case reportCompleted:
            report = MessageEncoding.decodeData(msg.getData(), Report.class);
            buildRepositoryRemote.reportCompleted(report.getAgentRuntimeInfo(), findJobIdentifier(report), report.getResult());
            break;
        case consoleOut:
            ConsoleTransmission consoleTransmission = MessageEncoding.decodeData(msg.getData(), ConsoleTransmission.class);
            File consoleLogFile = consoleService.consoleLogFile(findJobIdentifier(consoleTransmission));
            consoleService.updateConsoleLog(consoleLogFile, consoleTransmission.getLineAsStream());
            break;
        default:
            throw new RuntimeException("Unknown action: " + msg.getAction());
    }
}
Also used : AgentRuntimeInfo(com.thoughtworks.go.server.service.AgentRuntimeInfo) AgentInstruction(com.thoughtworks.go.remote.AgentInstruction) File(java.io.File)

Aggregations

AgentRuntimeInfo (com.thoughtworks.go.server.service.AgentRuntimeInfo)112 Test (org.junit.Test)93 AgentIdentifier (com.thoughtworks.go.remote.AgentIdentifier)31 File (java.io.File)14 AgentInstruction (com.thoughtworks.go.remote.AgentInstruction)13 StringContains.containsString (org.hamcrest.core.StringContains.containsString)12 FakeBuildRepositoryRemote (com.thoughtworks.go.agent.testhelpers.FakeBuildRepositoryRemote)11 UploadEntry (com.thoughtworks.go.matchers.UploadEntry)10 AgentBuildingInfo (com.thoughtworks.go.server.service.AgentBuildingInfo)8 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)8 AgentInstance (com.thoughtworks.go.domain.AgentInstance)6 Before (org.junit.Before)5 EnvironmentVariableContext (com.thoughtworks.go.util.command.EnvironmentVariableContext)4 Expectations (org.jmock.Expectations)4 RunIf (com.googlecode.junit.ext.RunIf)3 Date (java.util.Date)3 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)3 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)2 JobIdentifier (com.thoughtworks.go.domain.JobIdentifier)2 Registration (com.thoughtworks.go.security.Registration)2