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;
}
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("");
}
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));
}
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")));
}
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));
}
Aggregations