Search in sources :

Example 51 with AgentIdentifier

use of com.thoughtworks.go.remote.AgentIdentifier in project gocd by gocd.

the class AgentRuntimeInfoTest method dataMapEncodingAndDecoding.

@Test
public void dataMapEncodingAndDecoding() {
    AgentRuntimeInfo info = new AgentRuntimeInfo(new AgentIdentifier("go02", "10.10.10.1", "uuid"), AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie", true);
    AgentRuntimeInfo clonedInfo = MessageEncoding.decodeData(MessageEncoding.encodeData(info), AgentRuntimeInfo.class);
    assertThat(clonedInfo, is(info));
}
Also used : AgentIdentifier(com.thoughtworks.go.remote.AgentIdentifier) Test(org.junit.Test)

Example 52 with AgentIdentifier

use of com.thoughtworks.go.remote.AgentIdentifier in project gocd by gocd.

the class AgentRuntimeInfoTest method shouldInitializeTheFreeSpaceAtAgentSide.

@Test
public void shouldInitializeTheFreeSpaceAtAgentSide() {
    AgentIdentifier id = new AgentConfig("uuid", "localhost", "176.19.4.1").getAgentIdentifier();
    AgentRuntimeInfo agentRuntimeInfo = new AgentRuntimeInfo(id, AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie", false);
    assertThat(agentRuntimeInfo.getUsableSpace(), is(not(0L)));
}
Also used : AgentConfig(com.thoughtworks.go.config.AgentConfig) AgentIdentifier(com.thoughtworks.go.remote.AgentIdentifier) Test(org.junit.Test)

Example 53 with AgentIdentifier

use of com.thoughtworks.go.remote.AgentIdentifier in project gocd by gocd.

the class ElasticAgentRuntimeInfoTest method shouldRefreshOperatingSystemOfAgent.

@Test
public void shouldRefreshOperatingSystemOfAgent() throws Exception {
    AgentIdentifier identifier = new AgentIdentifier("local.in", "127.0.0.1", "uuid-1");
    AgentRuntimeInfo runtimeInfo = ElasticAgentRuntimeInfo.fromAgent(identifier, AgentRuntimeStatus.Idle, "/tmp/foo", false);
    String os = new SystemEnvironment().getOperatingSystemCompleteName();
    assertThat(runtimeInfo.getOperatingSystem(), is(os));
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) AgentIdentifier(com.thoughtworks.go.remote.AgentIdentifier) Test(org.junit.Test)

Example 54 with AgentIdentifier

use of com.thoughtworks.go.remote.AgentIdentifier in project gocd by gocd.

the class ElasticAgentRuntimeInfoTest method dataMapEncodingAndDecoding.

@Test
public void dataMapEncodingAndDecoding() {
    AgentRuntimeInfo info = new ElasticAgentRuntimeInfo(new AgentIdentifier("localhost", "127.0.0.1", "uuid"), AgentRuntimeStatus.Idle, "/foo/one", null, "42", "go.cd.elastic-agent-plugin.docker");
    AgentRuntimeInfo clonedInfo = MessageEncoding.decodeData(MessageEncoding.encodeData(info), AgentRuntimeInfo.class);
    assertThat(clonedInfo, is(info));
}
Also used : AgentIdentifier(com.thoughtworks.go.remote.AgentIdentifier) Test(org.junit.Test)

Example 55 with AgentIdentifier

use of com.thoughtworks.go.remote.AgentIdentifier in project gocd by gocd.

the class WorkFinder method onMessage.

public void onMessage(IdleAgentMessage idleAgentMessage) {
    AgentIdentifier agent = idleAgentMessage.getAgentIdentifier();
    Work work = null;
    long startTime = System.currentTimeMillis();
    try {
        work = buildAssignmentService.assignWorkToAgent(agent);
    } finally {
        if (work == null) {
            work = NO_WORK;
        }
        workAssignmentPerformanceLogger.assignedWorkToAgent(work, agent, startTime, System.currentTimeMillis());
        try {
            assignedWorkTopic.post(new WorkAssignedMessage(agent, work));
        } catch (Throwable e) {
            LOGGER.error(FATAL, null, e);
        }
    }
}
Also used : Work(com.thoughtworks.go.remote.work.Work) NoWork(com.thoughtworks.go.remote.work.NoWork) AgentIdentifier(com.thoughtworks.go.remote.AgentIdentifier)

Aggregations

AgentIdentifier (com.thoughtworks.go.remote.AgentIdentifier)81 Test (org.junit.Test)57 AgentRuntimeInfo (com.thoughtworks.go.server.service.AgentRuntimeInfo)34 FakeBuildRepositoryRemote (com.thoughtworks.go.agent.testhelpers.FakeBuildRepositoryRemote)12 Before (org.junit.Before)11 UploadEntry (com.thoughtworks.go.matchers.UploadEntry)10 ArrayList (java.util.ArrayList)10 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)9 EnvironmentVariableContext (com.thoughtworks.go.util.command.EnvironmentVariableContext)9 File (java.io.File)9 AgentConfig (com.thoughtworks.go.config.AgentConfig)5 AgentInstance (com.thoughtworks.go.domain.AgentInstance)5 AgentStatusChangeListener (com.thoughtworks.go.listener.AgentStatusChangeListener)5 AgentInstruction (com.thoughtworks.go.remote.AgentInstruction)4 NoWork (com.thoughtworks.go.remote.work.NoWork)4 Work (com.thoughtworks.go.remote.work.Work)4 Agent (com.thoughtworks.go.server.domain.Agent)4 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)3 HttpOperationResult (com.thoughtworks.go.server.service.result.HttpOperationResult)3 GoConfigDao (com.thoughtworks.go.config.GoConfigDao)2