Search in sources :

Example 41 with AgentConfig

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

the class AgentInstanceTest method shouldNotMatchJobPlanIfJobRequiresElasticAgent_MatchingIsManagedByBuildAssignmentService.

@Test
public void shouldNotMatchJobPlanIfJobRequiresElasticAgent_MatchingIsManagedByBuildAssignmentService() {
    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", elasticPluginId));
    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 42 with AgentConfig

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

the class DefaultSchedulingContextTest method shouldOnlyFindAgentsThatMatchResourcesSpecified.

@Test
public void shouldOnlyFindAgentsThatMatchResourcesSpecified() throws Exception {
    AgentConfig linux = agent("uuid1", "linux");
    AgentConfig windows = agent("uuid2", "windows");
    Agents matchingAgents = new Agents(linux, windows);
    DefaultSchedulingContext context = new DefaultSchedulingContext("approved", matchingAgents);
    assertThat(context.findAgentsMatching(resources("linux")), is(new Agents(linux)));
}
Also used : AgentConfig(com.thoughtworks.go.config.AgentConfig) Agents(com.thoughtworks.go.config.Agents) Test(org.junit.Test)

Example 43 with AgentConfig

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

the class DefaultSchedulingContextTest method shouldFindNoAgentsIfNoneMatch.

@Test
public void shouldFindNoAgentsIfNoneMatch() throws Exception {
    AgentConfig linux = agent("uuid1", "linux");
    AgentConfig windows = agent("uuid2", "windows");
    Agents matchingAgents = new Agents(linux, windows);
    DefaultSchedulingContext context = new DefaultSchedulingContext("approved", matchingAgents);
    assertThat(context.findAgentsMatching(resources("macosx")), is(new Agents()));
}
Also used : AgentConfig(com.thoughtworks.go.config.AgentConfig) Agents(com.thoughtworks.go.config.Agents) Test(org.junit.Test)

Example 44 with AgentConfig

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

the class ElasticAgentRequestProcessorTest method shouldProcessDeleteAgentRequest.

@Test
public void shouldProcessDeleteAgentRequest() throws Exception {
    AgentMetadata agent = new AgentMetadata("foo", null, null, null);
    DefaultGoApiRequest goPluginApiRequest = new DefaultGoApiRequest(PROCESS_DELETE_AGENTS, "1.0", pluginIdentifier);
    goPluginApiRequest.setRequestBody(extension.getElasticAgentMessageConverter(goPluginApiRequest.apiVersion()).listAgentsResponseBody(Arrays.asList(agent)));
    AgentInstance agentInstance = AgentInstance.createFromConfig(new AgentConfig("uuid"), null);
    when(agentService.findElasticAgent("foo", "docker")).thenReturn(agentInstance);
    processor.process(pluginDescriptor, goPluginApiRequest);
    verify(agentConfigService).deleteAgents(processor.usernameFor(pluginDescriptor), agentInstance);
}
Also used : AgentInstance(com.thoughtworks.go.domain.AgentInstance) AgentConfig(com.thoughtworks.go.config.AgentConfig) ElasticAgentMetadata(com.thoughtworks.go.server.domain.ElasticAgentMetadata) AgentMetadata(com.thoughtworks.go.plugin.access.elastic.models.AgentMetadata) DefaultGoApiRequest(com.thoughtworks.go.plugin.api.request.DefaultGoApiRequest) Test(org.junit.Test)

Example 45 with AgentConfig

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

the class AgentRuntimeInfoTest method shouldNotUpdateStatusWhenOldValueIsEqualToNewValue.

@Test
public void shouldNotUpdateStatusWhenOldValueIsEqualToNewValue() {
    AgentRuntimeInfo agentRuntimeInfo = AgentRuntimeInfo.fromServer(new AgentConfig("uuid", "localhost", "176.19.4.1"), true, "/var/lib", 0L, "linux", false);
    assertThat(agentRuntimeInfo.getRuntimeStatus(), is(AgentRuntimeStatus.Idle));
    AgentRuntimeStatus.ChangeListener listener = mock(AgentRuntimeStatus.ChangeListener.class);
    agentRuntimeInfo.setRuntimeStatus(AgentRuntimeStatus.Idle, listener);
    verify(listener, never()).statusUpdateRequested(any(AgentRuntimeInfo.class), any(AgentRuntimeStatus.class));
    assertThat(agentRuntimeInfo.getRuntimeStatus(), is(AgentRuntimeStatus.Idle));
}
Also used : AgentConfig(com.thoughtworks.go.config.AgentConfig) AgentRuntimeStatus(com.thoughtworks.go.domain.AgentRuntimeStatus) 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