Search in sources :

Example 6 with Agents

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

the class DefaultSchedulingContext method permittedAgent.

public SchedulingContext permittedAgent(String permittedAgentUuid) {
    Agents permitted = new Agents();
    for (AgentConfig agent : agents) {
        if (agent.getUuid().equals(permittedAgentUuid)) {
            permitted.add(agent);
        }
    }
    DefaultSchedulingContext context = new DefaultSchedulingContext(approvedBy, permitted, profiles);
    context.variables = variables.overrideWith(new EnvironmentVariablesConfig());
    context.rerun = rerun;
    return context;
}
Also used : AgentConfig(com.thoughtworks.go.config.AgentConfig) Agents(com.thoughtworks.go.config.Agents) EnvironmentVariablesConfig(com.thoughtworks.go.config.EnvironmentVariablesConfig)

Example 7 with Agents

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

the class BuildAssignmentServiceTest method setUp.

@Before
public void setUp() throws Exception {
    initMocks(this);
    buildAssignmentService = new BuildAssignmentService(goConfigService, jobInstanceService, scheduleService, agentService, environmentConfigService, transactionTemplate, scheduledPipelineLoader, pipelineService, builderFactory, agentRemoteHandler, elasticAgentPluginService, systemEnvironment);
    elasticProfileId1 = "elastic.profile.id.1";
    elasticProfileId2 = "elastic.profile.id.2";
    elasticAgent = AgentMother.elasticAgent();
    elasticAgentInstance = AgentInstance.createFromConfig(elasticAgent, new SystemEnvironment(), null);
    regularAgentInstance = AgentInstance.createFromConfig(AgentMother.approvedAgent(), new SystemEnvironment(), null);
    elasticProfile1 = new ElasticProfile(elasticProfileId1, elasticAgent.getElasticPluginId());
    elasticProfile2 = new ElasticProfile(elasticProfileId2, elasticAgent.getElasticPluginId());
    jobPlans = new ArrayList<>();
    HashMap<String, ElasticProfile> profiles = new HashMap<>();
    profiles.put(elasticProfile1.getId(), elasticProfile1);
    profiles.put(elasticProfile2.getId(), elasticProfile2);
    schedulingContext = new DefaultSchedulingContext("me", new Agents(elasticAgent), profiles);
    when(jobInstanceService.orderedScheduledBuilds()).thenReturn(jobPlans);
    when(environmentConfigService.filterJobsByAgent(Matchers.eq(jobPlans), any(String.class))).thenReturn(jobPlans);
    when(environmentConfigService.envForPipeline(any(String.class))).thenReturn("");
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) HashMap(java.util.HashMap) Agents(com.thoughtworks.go.config.Agents) ElasticProfile(com.thoughtworks.go.config.elastic.ElasticProfile) Before(org.junit.Before)

Example 8 with Agents

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

the class AgentInstancesTest method shouldNotRemovePendingAgentDuringSync.

@Test
public void shouldNotRemovePendingAgentDuringSync() throws Exception {
    AgentInstances agentInstances = new AgentInstances(systemEnvironment, agentStatusChangeListener, AgentInstanceMother.building());
    agentInstances.add(pending);
    Agents agents = new Agents();
    agentInstances.sync(agents);
    assertThat(agentInstances.size(), is(1));
    assertThat(agentInstances.findAgentAndRefreshStatus("uuid4").getStatus(), is(AgentStatus.Pending));
}
Also used : Agents(com.thoughtworks.go.config.Agents) Test(org.junit.Test)

Example 9 with Agents

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

the class AgentInstancesTest method shouldRemoveAgentWhenAgentIsRemovedFromConfigFile.

@Test
public void shouldRemoveAgentWhenAgentIsRemovedFromConfigFile() throws Exception {
    AgentInstances agentInstances = new AgentInstances(systemEnvironment, agentStatusChangeListener, idle, building);
    Agents oneAgentIsRemoved = new Agents(new AgentConfig("uuid2", "CCeDev01", "10.18.5.1"));
    agentInstances.sync(oneAgentIsRemoved);
    assertThat(agentInstances.size(), is(1));
    assertThat(agentInstances.findAgentAndRefreshStatus("uuid2"), is(idle));
    assertThat(agentInstances.findAgentAndRefreshStatus("uuid1"), is(new NullAgentInstance("uuid1")));
}
Also used : AgentConfig(com.thoughtworks.go.config.AgentConfig) Agents(com.thoughtworks.go.config.Agents) NullAgentInstance(com.thoughtworks.go.domain.NullAgentInstance) Test(org.junit.Test)

Example 10 with Agents

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

the class AgentInstancesTest method shouldAddAgentIntoMemoryAfterAgentIsManuallyAddedInConfigFile.

@Test
public void shouldAddAgentIntoMemoryAfterAgentIsManuallyAddedInConfigFile() throws Exception {
    AgentInstances agentInstances = new AgentInstances(mock(AgentStatusChangeListener.class));
    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) AgentStatusChangeListener(com.thoughtworks.go.listener.AgentStatusChangeListener) Test(org.junit.Test)

Aggregations

Agents (com.thoughtworks.go.config.Agents)21 Test (org.junit.Test)16 AgentConfig (com.thoughtworks.go.config.AgentConfig)13 EnvironmentVariablesConfig (com.thoughtworks.go.config.EnvironmentVariablesConfig)3 TimeProvider (com.thoughtworks.go.util.TimeProvider)3 EnvironmentVariableConfig (com.thoughtworks.go.config.EnvironmentVariableConfig)2 Resources (com.thoughtworks.go.config.Resources)2 StageConfig (com.thoughtworks.go.config.StageConfig)2 Before (org.junit.Before)2 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)1 ConfigSaveValidationContext (com.thoughtworks.go.config.ConfigSaveValidationContext)1 ResourceConfig (com.thoughtworks.go.config.ResourceConfig)1 ElasticProfile (com.thoughtworks.go.config.elastic.ElasticProfile)1 DefaultSchedulingContext (com.thoughtworks.go.domain.DefaultSchedulingContext)1 NullAgentInstance (com.thoughtworks.go.domain.NullAgentInstance)1 Pipeline (com.thoughtworks.go.domain.Pipeline)1 AgentStatusChangeListener (com.thoughtworks.go.listener.AgentStatusChangeListener)1 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)1 HashMap (java.util.HashMap)1 TransactionStatus (org.springframework.transaction.TransactionStatus)1