Search in sources :

Example 16 with AgentConfig

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

the class AgentRuntimeInfoTest method shouldUsingIdleWhenRegistrationRequestIsFromLocalAgent.

@Test
public void shouldUsingIdleWhenRegistrationRequestIsFromLocalAgent() {
    AgentRuntimeInfo agentRuntimeInfo = AgentRuntimeInfo.fromServer(new AgentConfig("uuid", "localhost", "127.0.0.1"), false, "/var/lib", 0L, "linux", false);
    assertThat(agentRuntimeInfo.getRuntimeStatus(), Is.is(AgentRuntimeStatus.Idle));
}
Also used : AgentConfig(com.thoughtworks.go.config.AgentConfig) Test(org.junit.Test)

Example 17 with AgentConfig

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

the class JobInstanceStatusMonitorTest method shouldSendCancelMessageIfJobIsCancelled.

@Test
public void shouldSendCancelMessageIfJobIsCancelled() throws Exception {
    AgentConfig agentConfig = AgentMother.remoteAgent();
    configHelper.addAgent(agentConfig);
    fixture.createPipelineWithFirstStageScheduled();
    AgentRuntimeInfo info = AgentRuntimeInfo.fromServer(agentConfig, true, "location", 1000000l, "OS", false);
    info.setCookie("cookie");
    agentRemoteHandler.process(agent, new Message(Action.ping, MessageEncoding.encodeData(info)));
    buildAssignmentService.onTimer();
    assertThat(agent.messages.size(), is(1));
    Work work = MessageEncoding.decodeWork(agent.messages.get(0).getData());
    assertThat(work, instanceOf(BuildWork.class));
    JobPlan jobPlan = ((BuildWork) work).getAssignment().getPlan();
    final JobInstance instance = jobInstanceService.buildByIdWithTransitions(jobPlan.getJobId());
    transactionTemplate.execute(new TransactionCallbackWithoutResult() {

        @Override
        protected void doInTransactionWithoutResult(TransactionStatus status) {
            jobInstanceService.cancelJob(instance);
        }
    });
    assertThat(agent.messages.size(), is(2));
    assertThat(agent.messages.get(1).getAction(), is(Action.cancelBuild));
}
Also used : AgentConfig(com.thoughtworks.go.config.AgentConfig) Message(com.thoughtworks.go.websocket.Message) JobPlan(com.thoughtworks.go.domain.JobPlan) JobInstance(com.thoughtworks.go.domain.JobInstance) Work(com.thoughtworks.go.remote.work.Work) BuildWork(com.thoughtworks.go.remote.work.BuildWork) TransactionStatus(org.springframework.transaction.TransactionStatus) BuildWork(com.thoughtworks.go.remote.work.BuildWork) TransactionCallbackWithoutResult(org.springframework.transaction.support.TransactionCallbackWithoutResult)

Example 18 with AgentConfig

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

the class ScheduleServiceRescheduleHungJobsTest method activities.

private AgentInstances activities() {
    final AgentInstances activities = new AgentInstances(null);
    SystemEnvironment systemEnvironment = new SystemEnvironment();
    activities.add(AgentInstance.createFromConfig(new AgentConfig("uuid1"), systemEnvironment));
    activities.add(AgentInstance.createFromConfig(new AgentConfig("uuid2"), systemEnvironment));
    return activities;
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) AgentInstances(com.thoughtworks.go.server.domain.AgentInstances) AgentConfig(com.thoughtworks.go.config.AgentConfig)

Example 19 with AgentConfig

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

the class TriStateSelectionTest method shouldHaveActionAddIfAllAgentsHaveThatResource.

@Test
public void shouldHaveActionAddIfAllAgentsHaveThatResource() {
    resources.add(new Resource("all"));
    agents.add(new AgentConfig("uuid1", "host1", "127.0.0.1", new Resources("all")));
    agents.add(new AgentConfig("uuid2", "host2", "127.0.0.2", new Resources("all")));
    List<TriStateSelection> selections = TriStateSelection.forAgentsResources(resources, agents);
    assertThat(selections, hasItem(new TriStateSelection("all", TriStateSelection.Action.add)));
}
Also used : AgentConfig(com.thoughtworks.go.config.AgentConfig) Resource(com.thoughtworks.go.config.Resource) Resources(com.thoughtworks.go.config.Resources) Test(org.junit.Test)

Example 20 with AgentConfig

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

the class AgentRegistrationControllerIntegrationTest method shouldRegisterAgent.

@Test
public void shouldRegisterAgent() throws Exception {
    String uuid = UUID.randomUUID().toString();
    MockHttpServletRequest request = new MockHttpServletRequest();
    controller.agentRequest("hostname", uuid, "sandbox", "100", null, null, null, null, null, null, null, false, request);
    AgentConfig agentConfig = goConfigService.agentByUuid(uuid);
    assertThat(agentConfig.getHostname(), is("hostname"));
}
Also used : AgentConfig(com.thoughtworks.go.config.AgentConfig) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) 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