Search in sources :

Example 71 with AgentConfig

use of com.thoughtworks.go.config.AgentConfig 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 72 with AgentConfig

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

the class AgentInstanceTest method shouldReturnAJobPlanWithMatchingUuidSet.

@Test
public void shouldReturnAJobPlanWithMatchingUuidSet() throws Exception {
    AgentConfig config = agentConfig("linux, mercurial");
    AgentInstance agentInstance = new AgentInstance(config, LOCAL, systemEnvironment, null);
    final JobPlan job = jobPlan("pipeline-name", "job-name", "resource", config.getUuid());
    JobPlan matchingJob = agentInstance.firstMatching(new ArrayList<JobPlan>() {

        {
            add(job);
        }
    });
    assertThat(matchingJob, is(job));
}
Also used : AgentConfig(com.thoughtworks.go.config.AgentConfig) Test(org.junit.Test)

Example 73 with AgentConfig

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

the class AgentInstanceTest method shouldNotBeEqualIfUuidIsNotEqual.

@Test
public void shouldNotBeEqualIfUuidIsNotEqual() throws Exception {
    AgentInstance agentA = new AgentInstance(new AgentConfig("UUID", "A", "127.0.0.1"), LOCAL, systemEnvironment, null);
    AgentInstance copyOfAgentA = new AgentInstance(new AgentConfig("UUID", "A", "127.0.0.1"), LOCAL, systemEnvironment, null);
    AgentInstance agentB = new AgentInstance(new AgentConfig("UUID", "B", "127.0.0.2"), LOCAL, systemEnvironment, null);
    assertThat(agentA, is(not(agentB)));
    assertThat(agentB, is(not(agentA)));
    assertThat(agentA, is(copyOfAgentA));
}
Also used : AgentConfig(com.thoughtworks.go.config.AgentConfig) Test(org.junit.Test)

Example 74 with AgentConfig

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

the class AgentInstanceTest method shouldNotMatchJobPlanIfTheAgentIsElasticAndJobHasResourcesDefined.

@Test
public void shouldNotMatchJobPlanIfTheAgentIsElasticAndJobHasResourcesDefined() {
    AgentConfig agentConfig = new AgentConfig("uuid", "hostname", "11.1.1.1", new ResourceConfigs(new ResourceConfig("r1")));
    agentConfig.setElasticAgentId("elastic-agent-id-1");
    String elasticPluginId = "elastic-plugin-id-1";
    agentConfig.setElasticPluginId(elasticPluginId);
    AgentInstance agentInstance = new AgentInstance(agentConfig, REMOTE, mock(SystemEnvironment.class), null);
    DefaultJobPlan jobPlan1 = new DefaultJobPlan();
    jobPlan1.setResources(asList(new Resource("r1")));
    List<JobPlan> jobPlans = asList(jobPlan1, new DefaultJobPlan());
    assertThat(agentInstance.firstMatching(jobPlans), is(nullValue()));
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) AgentConfig(com.thoughtworks.go.config.AgentConfig) ResourceConfig(com.thoughtworks.go.config.ResourceConfig) ResourceConfigs(com.thoughtworks.go.config.ResourceConfigs) Test(org.junit.Test)

Example 75 with AgentConfig

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

the class AgentsTest method shouldValidateDuplicateElasticAgentId.

@Test
public void shouldValidateDuplicateElasticAgentId() throws Exception {
    Agents agents = new Agents();
    AgentConfig elasticAgent1 = new AgentConfig("1", "localhost", "1");
    elasticAgent1.setElasticAgentId("elastic-agent-id");
    elasticAgent1.setElasticPluginId("awesome-elastic-agent");
    AgentConfig elasticAgent2 = new AgentConfig("2", "localhost", "2");
    elasticAgent2.setElasticAgentId("elastic-agent-id");
    elasticAgent2.setElasticPluginId("awesome-elastic-agent");
    agents.add(elasticAgent1);
    agents.add(elasticAgent2);
    agents.validate(new ConfigSaveValidationContext(agents));
    assertThat(elasticAgent1.errors().size(), is(1));
    assertThat(elasticAgent1.errors().getAllOn("elasticAgentId").get(0), is("Duplicate ElasticAgentId found for agents [1, 2]"));
    assertThat(elasticAgent2.errors().size(), is(1));
    assertThat(elasticAgent2.errors().getAllOn("elasticAgentId").get(0), is("Duplicate ElasticAgentId found for agents [1, 2]"));
}
Also used : AgentConfig(com.thoughtworks.go.config.AgentConfig) ConfigSaveValidationContext(com.thoughtworks.go.config.ConfigSaveValidationContext) Agents(com.thoughtworks.go.config.Agents) Test(org.junit.Test)

Aggregations

AgentConfig (com.thoughtworks.go.config.AgentConfig)90 Test (org.junit.Test)68 AgentInstance (com.thoughtworks.go.domain.AgentInstance)20 Agents (com.thoughtworks.go.config.Agents)13 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)11 AgentStatusChangeListener (com.thoughtworks.go.listener.AgentStatusChangeListener)10 Username (com.thoughtworks.go.server.domain.Username)7 ResponseEntity (org.springframework.http.ResponseEntity)7 ResourceConfig (com.thoughtworks.go.config.ResourceConfig)6 ResourceConfigs (com.thoughtworks.go.config.ResourceConfigs)5 AgentIdentifier (com.thoughtworks.go.remote.AgentIdentifier)5 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)5 GoConfigDao (com.thoughtworks.go.config.GoConfigDao)4 ServerConfig (com.thoughtworks.go.config.ServerConfig)4 UpdateConfigCommand (com.thoughtworks.go.config.UpdateConfigCommand)4 EnvironmentVariablesConfig (com.thoughtworks.go.config.EnvironmentVariablesConfig)3 ElasticProfile (com.thoughtworks.go.config.elastic.ElasticProfile)3 NullAgentInstance (com.thoughtworks.go.domain.NullAgentInstance)3 EnvironmentVariableConfig (com.thoughtworks.go.config.EnvironmentVariableConfig)2 StageConfig (com.thoughtworks.go.config.StageConfig)2