Search in sources :

Example 11 with AgentConfig

use of com.thoughtworks.go.config.AgentConfig in project gocd by gocd.

the class AgentInstancesTest method shouldAddAgentIntoMemoryAfterAgentIsManuallyAddedInConfigFile.

@Test
public void shouldAddAgentIntoMemoryAfterAgentIsManuallyAddedInConfigFile() throws Exception {
    AgentInstances agentInstances = new AgentInstances(null);
    AgentConfig agentConfig = new AgentConfig("uuid20", "CCeDev01", "10.18.5.20");
    agentInstances.sync(new Agents(agentConfig));
    assertThat(agentInstances.size(), is(1));
    assertThat(agentInstances.findAgentAndRefreshStatus("uuid20").agentConfig(), is(agentConfig));
}
Also used : AgentConfig(com.thoughtworks.go.config.AgentConfig) Agents(com.thoughtworks.go.config.Agents) Test(org.junit.Test)

Example 12 with AgentConfig

use of com.thoughtworks.go.config.AgentConfig in project gocd by gocd.

the class AgentInstancesTest method shouldSupportConcurrentOperations.

@Test
public void shouldSupportConcurrentOperations() throws Exception {
    final AgentInstances agentInstances = new AgentInstances(null);
    // register 100 agents
    for (int i = 0; i < 100; i++) {
        AgentConfig agentConfig = new AgentConfig("uuid" + i, "CCeDev_" + i, "10.18.5." + i);
        agentInstances.register(AgentRuntimeInfo.fromServer(agentConfig, false, "/var/lib", Long.MAX_VALUE, "linux", false));
    }
    thrown.expect(MaxPendingAgentsLimitReachedException.class);
    thrown.expectMessage("Max pending agents allowed 100, limit reached");
    AgentConfig agentConfig = new AgentConfig("uuid" + 200, "CCeDev_" + 200, "10.18.5." + 200);
    agentInstances.register(AgentRuntimeInfo.fromServer(agentConfig, false, "/var/lib", Long.MAX_VALUE, "linux", false));
}
Also used : AgentConfig(com.thoughtworks.go.config.AgentConfig) Test(org.junit.Test)

Example 13 with AgentConfig

use of com.thoughtworks.go.config.AgentConfig in project gocd by gocd.

the class AgentRuntimeInfoTest method shouldNotMatchRuntimeInfosWithDifferentOperatingSystems.

@Test
public void shouldNotMatchRuntimeInfosWithDifferentOperatingSystems() {
    AgentRuntimeInfo linux = AgentRuntimeInfo.fromServer(new AgentConfig("uuid", "localhost", "176.19.4.1"), true, "/var/lib", 0L, "linux", false);
    AgentRuntimeInfo osx = AgentRuntimeInfo.fromServer(new AgentConfig("uuid", "localhost", "176.19.4.1"), true, "/var/lib", 0L, "foo bar", false);
    assertThat(linux, is(not(osx)));
}
Also used : AgentConfig(com.thoughtworks.go.config.AgentConfig) Test(org.junit.Test)

Example 14 with AgentConfig

use of com.thoughtworks.go.config.AgentConfig in project gocd by gocd.

the class AgentRuntimeInfoTest method shouldUsingIdleWhenRegistrationRequestIsFromAlreadyRegisteredAgent.

@Test
public void shouldUsingIdleWhenRegistrationRequestIsFromAlreadyRegisteredAgent() {
    AgentRuntimeInfo agentRuntimeInfo = AgentRuntimeInfo.fromServer(new AgentConfig("uuid", "localhost", "176.19.4.1"), true, "/var/lib", 0L, "linux", false);
    assertThat(agentRuntimeInfo.getRuntimeStatus(), is(AgentRuntimeStatus.Idle));
}
Also used : AgentConfig(com.thoughtworks.go.config.AgentConfig) Test(org.junit.Test)

Example 15 with AgentConfig

use of com.thoughtworks.go.config.AgentConfig in project gocd by gocd.

the class AgentRuntimeInfoTest method shouldNotifyStatusChangeListenerOnStatusUpdate.

@Test
public void shouldNotifyStatusChangeListenerOnStatusUpdate() {
    final AgentRuntimeStatus[] oldAndNewStatus = new AgentRuntimeStatus[2];
    AgentRuntimeInfo agentRuntimeInfo = AgentRuntimeInfo.fromServer(new AgentConfig("uuid", "localhost", "176.19.4.1"), true, "/var/lib", 0L, "linux", false);
    assertThat(agentRuntimeInfo.getRuntimeStatus(), is(AgentRuntimeStatus.Idle));
    assertThat(oldAndNewStatus[OLD_IDX], is(nullValue()));
    agentRuntimeInfo.setRuntimeStatus(AgentRuntimeStatus.Building, new AgentRuntimeStatus.ChangeListener() {

        public void statusUpdateRequested(AgentRuntimeInfo runtimeInfo, AgentRuntimeStatus newStatus) {
            oldAndNewStatus[OLD_IDX] = runtimeInfo.getRuntimeStatus();
            oldAndNewStatus[NEW_IDX] = newStatus;
        }
    });
    assertThat(oldAndNewStatus[OLD_IDX], is(AgentRuntimeStatus.Idle));
    assertThat(oldAndNewStatus[NEW_IDX], is(AgentRuntimeStatus.Building));
    assertThat(agentRuntimeInfo.getRuntimeStatus(), is(AgentRuntimeStatus.Building));
}
Also used : AgentRuntimeStatus(com.thoughtworks.go.domain.AgentRuntimeStatus) AgentConfig(com.thoughtworks.go.config.AgentConfig) Test(org.junit.Test)

Aggregations

AgentConfig (com.thoughtworks.go.config.AgentConfig)65 Test (org.junit.Test)45 AgentInstance (com.thoughtworks.go.domain.AgentInstance)15 Agents (com.thoughtworks.go.config.Agents)13 Username (com.thoughtworks.go.server.domain.Username)7 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)6 Resource (com.thoughtworks.go.config.Resource)5 Resources (com.thoughtworks.go.config.Resources)5 GoConfigDao (com.thoughtworks.go.config.GoConfigDao)4 SecurityConfig (com.thoughtworks.go.config.SecurityConfig)4 ServerConfig (com.thoughtworks.go.config.ServerConfig)4 UpdateConfigCommand (com.thoughtworks.go.config.UpdateConfigCommand)4 JobInstance (com.thoughtworks.go.domain.JobInstance)4 EnvironmentVariablesConfig (com.thoughtworks.go.config.EnvironmentVariablesConfig)3 NullAgentInstance (com.thoughtworks.go.domain.NullAgentInstance)3 AgentIdentifier (com.thoughtworks.go.remote.AgentIdentifier)3 HttpOperationResult (com.thoughtworks.go.server.service.result.HttpOperationResult)3 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)2 EnvironmentVariableConfig (com.thoughtworks.go.config.EnvironmentVariableConfig)2 StageConfig (com.thoughtworks.go.config.StageConfig)2