Search in sources :

Example 36 with AgentConfig

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

the class AgentInstanceTest method shouldBeAbleToDenyAgentThatIsRunningCancelledJob.

@Test
public void shouldBeAbleToDenyAgentThatIsRunningCancelledJob() {
    AgentConfig config = new AgentConfig("UUID", "A", "127.0.0.1");
    AgentInstance agent = new AgentInstance(config, LOCAL, systemEnvironment, mock(AgentStatusChangeListener.class));
    agent.cancel();
    AgentBuildingInfo cancelled = agent.getBuildingInfo();
    assertThat(agent.canDisable(), is(true));
    agent.deny();
    assertThat(config.isDisabled(), is(true));
    assertThat(agent.getStatus(), is(AgentStatus.Disabled));
    assertThat(agent.getBuildingInfo(), is(cancelled));
}
Also used : AgentConfig(com.thoughtworks.go.config.AgentConfig) AgentBuildingInfo(com.thoughtworks.go.server.service.AgentBuildingInfo) AgentStatusChangeListener(com.thoughtworks.go.listener.AgentStatusChangeListener) Test(org.junit.Test)

Example 37 with AgentConfig

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

the class AgentInstanceTest method shouldNotMatchJobPlanIfTheAgentWasLaunchedByADifferentPluginFromThatConfiguredForTheJob.

@Test
public void shouldNotMatchJobPlanIfTheAgentWasLaunchedByADifferentPluginFromThatConfiguredForTheJob() {
    AgentConfig agentConfig = new AgentConfig("uuid");
    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.setElasticProfile(new ElasticProfile("foo", "elastic-plugin-id-2"));
    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) ElasticProfile(com.thoughtworks.go.config.elastic.ElasticProfile) Test(org.junit.Test)

Example 38 with AgentConfig

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

the class AgentInstanceTest method shouldSetAgentToIdleWhenItIsApproved.

@Test
public void shouldSetAgentToIdleWhenItIsApproved() {
    AgentInstance pending = AgentInstanceMother.pending();
    AgentConfig config = new AgentConfig(pending.getUuid(), pending.getHostname(), pending.getIpAddress());
    pending.syncConfig(config);
    AgentStatus status = pending.getStatus();
    assertThat(status, is(AgentStatus.Idle));
}
Also used : AgentConfig(com.thoughtworks.go.config.AgentConfig) Test(org.junit.Test)

Example 39 with AgentConfig

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

the class AgentInstanceTest method shouldNotReturnAJobWithMismatchedUuid.

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

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

Example 40 with AgentConfig

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

the class AgentInstanceTest method shouldDenyAgentWhenAgentIsDeniedInConfigFile.

@Test
public void shouldDenyAgentWhenAgentIsDeniedInConfigFile() throws Exception {
    AgentInstance original = AgentInstance.createFromConfig(agentConfig, systemEnvironment, mock(AgentStatusChangeListener.class));
    original.update(buildingRuntimeInfo());
    AgentConfig newAgentConfig = new AgentConfig(agentConfig.getUuid(), agentConfig.getHostname(), agentConfig.getIpAddress());
    newAgentConfig.disable();
    original.syncConfig(newAgentConfig);
    assertThat(original.getStatus(), is(AgentStatus.Disabled));
}
Also used : AgentConfig(com.thoughtworks.go.config.AgentConfig) AgentStatusChangeListener(com.thoughtworks.go.listener.AgentStatusChangeListener) 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