Search in sources :

Example 26 with AgentConfig

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

the class ElasticAgentRequestProcessorTest method shouldProcessDisableAgentRequest.

@Test
public void shouldProcessDisableAgentRequest() throws Exception {
    AgentMetadata agent = new AgentMetadata("foo", null, null, null);
    DefaultGoApiRequest goPluginApiRequest = new DefaultGoApiRequest(PROCESS_DISABLE_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).disableAgents(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 27 with AgentConfig

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

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

the class UpdateAgentStatusTest method setUp.

@Before
public void setUp() throws Exception {
    dbHelper.onSetUp();
    configHelper.onSetUp();
    configHelper.usingCruiseConfigDao(goConfigDao);
    preCondition = new PipelineWithTwoStages(materialRepository, transactionTemplate);
    preCondition.usingConfigHelper(configHelper).usingDbHelper(dbHelper).onSetUp();
    agentService.clearAll();
    agentService.requestRegistration(new Username("bob"), AgentRuntimeInfo.fromServer(new AgentConfig(agentId, "CCEDev01", "10.81.2.1"), false, "/var/lib", 0L, "linux", false));
    agentService.approve(agentId);
}
Also used : AgentConfig(com.thoughtworks.go.config.AgentConfig) PipelineWithTwoStages(com.thoughtworks.go.fixture.PipelineWithTwoStages) Username(com.thoughtworks.go.server.domain.Username) Before(org.junit.Before)

Example 29 with AgentConfig

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

the class AgentConfigServiceTest method shouldEnableMultipleAgents.

@Test
public void shouldEnableMultipleAgents() {
    AgentRuntimeInfo agentRuntimeInfo = AgentRuntimeInfo.fromAgent(new AgentIdentifier("remote-host", "50.40.30.20", "abc"), AgentRuntimeStatus.Unknown, "cookie", false);
    AgentInstance pending = AgentInstance.createFromLiveAgent(agentRuntimeInfo, new SystemEnvironment());
    AgentConfig agentConfig = new AgentConfig("UUID2", "remote-host", "50.40.30.20");
    agentConfig.disable();
    AgentInstance fromConfigFile = AgentInstance.createFromConfig(agentConfig, new SystemEnvironment());
    when(goConfigService.hasAgent(fromConfigFile.getUuid())).thenReturn(true);
    when(goConfigService.hasAgent(pending.getUuid())).thenReturn(false);
    agentConfigService.enableAgents(Username.ANONYMOUS, pending, fromConfigFile);
    GoConfigDao.CompositeConfigCommand command = new GoConfigDao.CompositeConfigCommand(new AgentConfigService.AddAgentCommand(pending.agentConfig()), new AgentConfigService.UpdateAgentApprovalStatus("UUID2", false));
    ArgumentCaptor<AgentsUpdateCommand> captor = ArgumentCaptor.forClass(AgentsUpdateCommand.class);
    verify(goConfigService).updateConfig(captor.capture(), eq(Username.ANONYMOUS));
    AgentsUpdateCommand updateCommand = captor.getValue();
    assertThat(ReflectionUtil.getField(updateCommand, "command"), is(command));
}
Also used : AgentInstance(com.thoughtworks.go.domain.AgentInstance) GoConfigDao(com.thoughtworks.go.config.GoConfigDao) SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) AgentConfig(com.thoughtworks.go.config.AgentConfig) AgentIdentifier(com.thoughtworks.go.remote.AgentIdentifier) AgentsUpdateCommand(com.thoughtworks.go.config.update.AgentsUpdateCommand) Test(org.junit.Test)

Example 30 with AgentConfig

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

the class AgentServiceTest method shouldUnderstandFilteringAgentListBasedOnUuid.

@Test
public void shouldUnderstandFilteringAgentListBasedOnUuid() {
    AgentInstance instance1 = AgentInstance.createFromLiveAgent(AgentRuntimeInfo.fromServer(new AgentConfig("uuid-1", "host-1", "192.168.1.2"), true, "/foo/bar", 100l, "linux", false), new SystemEnvironment());
    AgentInstance instance3 = AgentInstance.createFromLiveAgent(AgentRuntimeInfo.fromServer(new AgentConfig("uuid-3", "host-3", "192.168.1.4"), true, "/baz/quux", 300l, "linux", false), new SystemEnvironment());
    when(agentInstances.filter(Arrays.asList("uuid-1", "uuid-3"))).thenReturn(Arrays.asList(instance1, instance3));
    AgentsViewModel agents = agentService.filter(Arrays.asList("uuid-1", "uuid-3"));
    AgentViewModel view1 = new AgentViewModel(instance1);
    AgentViewModel view2 = new AgentViewModel(instance3);
    assertThat(agents, is(new AgentsViewModel(view1, view2)));
    verify(agentInstances).filter(Arrays.asList("uuid-1", "uuid-3"));
}
Also used : AgentInstance(com.thoughtworks.go.domain.AgentInstance) SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) AgentConfig(com.thoughtworks.go.config.AgentConfig) AgentsViewModel(com.thoughtworks.go.server.ui.AgentsViewModel) AgentViewModel(com.thoughtworks.go.server.ui.AgentViewModel) Test(org.junit.Test)

Aggregations

AgentConfig (com.thoughtworks.go.config.AgentConfig)65 Test (org.junit.Test)45 AgentInstance (com.thoughtworks.go.domain.AgentInstance)15 Agents (com.thoughtworks.go.config.Agents)13 Username (com.thoughtworks.go.server.domain.Username)7 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)6 Resource (com.thoughtworks.go.config.Resource)5 Resources (com.thoughtworks.go.config.Resources)5 GoConfigDao (com.thoughtworks.go.config.GoConfigDao)4 SecurityConfig (com.thoughtworks.go.config.SecurityConfig)4 ServerConfig (com.thoughtworks.go.config.ServerConfig)4 UpdateConfigCommand (com.thoughtworks.go.config.UpdateConfigCommand)4 JobInstance (com.thoughtworks.go.domain.JobInstance)4 EnvironmentVariablesConfig (com.thoughtworks.go.config.EnvironmentVariablesConfig)3 NullAgentInstance (com.thoughtworks.go.domain.NullAgentInstance)3 AgentIdentifier (com.thoughtworks.go.remote.AgentIdentifier)3 HttpOperationResult (com.thoughtworks.go.server.service.result.HttpOperationResult)3 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)2 EnvironmentVariableConfig (com.thoughtworks.go.config.EnvironmentVariableConfig)2 StageConfig (com.thoughtworks.go.config.StageConfig)2