Search in sources :

Example 11 with AgentIdentifier

use of com.thoughtworks.go.remote.AgentIdentifier in project gocd by gocd.

the class ElasticAgentRuntimeInfoTest method shouldUpdateSelfForAnIdleAgent.

@Test
public void shouldUpdateSelfForAnIdleAgent() throws Exception {
    ElasticAgentRuntimeInfo agentRuntimeInfo = new ElasticAgentRuntimeInfo(new AgentIdentifier("localhost", "127.0.0.1", "uuid"), AgentRuntimeStatus.Idle, "/foo/one", null, "42", "go.cd.elastic-agent-plugin.docker");
    ElasticAgentRuntimeInfo newRuntimeInfo = new ElasticAgentRuntimeInfo(new AgentIdentifier("go02", "10.10.10.1", "uuid"), AgentStatus.Building.getRuntimeStatus(), "/foo/two", "cookie", "42", "go.cd.elastic-agent-plugin.docker");
    agentRuntimeInfo.updateSelf(newRuntimeInfo);
    assertThat(agentRuntimeInfo.getBuildingInfo(), is(newRuntimeInfo.getBuildingInfo()));
    assertThat(agentRuntimeInfo.getLocation(), is(newRuntimeInfo.getLocation()));
    assertThat(agentRuntimeInfo.getUsableSpace(), is(newRuntimeInfo.getUsableSpace()));
    assertThat(agentRuntimeInfo.getOperatingSystem(), is(newRuntimeInfo.getOperatingSystem()));
    assertThat(agentRuntimeInfo.getElasticAgentId(), is(newRuntimeInfo.getElasticAgentId()));
    assertThat(agentRuntimeInfo.getElasticPluginId(), is(newRuntimeInfo.getElasticPluginId()));
}
Also used : AgentIdentifier(com.thoughtworks.go.remote.AgentIdentifier) Test(org.junit.Test)

Example 12 with AgentIdentifier

use of com.thoughtworks.go.remote.AgentIdentifier in project gocd by gocd.

the class ElasticAgentRuntimeInfoTest method shouldRefreshUsableSpaceOfAgent.

@Test
public void shouldRefreshUsableSpaceOfAgent() throws Exception {
    AgentIdentifier identifier = new AgentIdentifier("local.in", "127.0.0.1", "uuid-1");
    String workingDirectory = FileUtils.getTempDirectory().getAbsolutePath();
    AgentRuntimeInfo runtimeInfo = ElasticAgentRuntimeInfo.fromAgent(identifier, AgentRuntimeStatus.Idle, workingDirectory, false);
    long space = ElasticAgentRuntimeInfo.usableSpace(workingDirectory);
    assertThat(runtimeInfo.getUsableSpace(), is(space));
}
Also used : AgentIdentifier(com.thoughtworks.go.remote.AgentIdentifier) Test(org.junit.Test)

Example 13 with AgentIdentifier

use of com.thoughtworks.go.remote.AgentIdentifier in project gocd by gocd.

the class BuildAssignmentServiceIntegrationTest method shouldRescheduleAbandonedBuild.

@Test
public void shouldRescheduleAbandonedBuild() throws SQLException {
    AgentIdentifier instance = agent(AgentMother.localAgent());
    Pipeline pipeline = instanceFactory.createPipelineInstance(evolveConfig, modifyNoFiles(evolveConfig), new DefaultSchedulingContext(DEFAULT_APPROVED_BY), md5, new TimeProvider());
    dbHelper.savePipelineWithStagesAndMaterials(pipeline);
    buildAssignmentService.onConfigChange(goConfigService.getCurrentConfig());
    buildAssignmentService.onTimer();
    buildAssignmentService.assignWorkToAgent(instance);
    long firstAssignedBuildId = buildOf(pipeline).getId();
    //somehow agent abandoned its original build...
    buildAssignmentService.assignWorkToAgent(instance);
    JobInstance reloaded = jobInstanceDao.buildByIdWithTransitions(firstAssignedBuildId);
    assertThat(reloaded.getState(), is(JobState.Rescheduled));
    assertThat(reloaded.isIgnored(), is(true));
}
Also used : AgentIdentifier(com.thoughtworks.go.remote.AgentIdentifier)

Example 14 with AgentIdentifier

use of com.thoughtworks.go.remote.AgentIdentifier in project gocd by gocd.

the class AgentServiceIntegrationTest method createDisabledAndIdleAgent.

private AgentConfig createDisabledAndIdleAgent(String uuid) {
    AgentConfig agentConfig = new AgentConfig(uuid, "agentName", "127.0.0.9");
    addAgent(agentConfig);
    AgentIdentifier agentIdentifier = agentConfig.getAgentIdentifier();
    String cookie = agentService.assignCookie(agentIdentifier);
    AgentRuntimeInfo agentRuntimeInfo = new AgentRuntimeInfo(agentIdentifier, AgentRuntimeStatus.Idle, currentWorkingDirectory(), cookie, false);
    agentRuntimeInfo.idle();
    agentService.updateRuntimeInfo(agentRuntimeInfo);
    assertTrue(agentService.findAgentAndRefreshStatus(uuid).isIdle());
    agentService.disableAgents(USERNAME, new HttpOperationResult(), Arrays.asList(agentConfig.getUuid()));
    AgentConfig updatedAgent = goConfigDao.load().agents().getAgentByUuid(agentConfig.getUuid());
    assertThat(isDisabled(updatedAgent), is(true));
    return updatedAgent;
}
Also used : HttpOperationResult(com.thoughtworks.go.server.service.result.HttpOperationResult) AgentIdentifier(com.thoughtworks.go.remote.AgentIdentifier)

Example 15 with AgentIdentifier

use of com.thoughtworks.go.remote.AgentIdentifier in project gocd by gocd.

the class AgentServiceIntegrationTest method disable.

private void disable(AgentConfig agentConfig) {
    AgentIdentifier agentIdentifier = agentConfig.getAgentIdentifier();
    String cookie = agentService.assignCookie(agentIdentifier);
    AgentRuntimeInfo agentRuntimeInfo = new AgentRuntimeInfo(agentIdentifier, AgentRuntimeStatus.Idle, currentWorkingDirectory(), cookie, false);
    agentRuntimeInfo.busy(new AgentBuildingInfo("path", "buildLocator"));
    agentService.updateRuntimeInfo(agentRuntimeInfo);
    agentService.disableAgents(USERNAME, new HttpOperationResult(), Arrays.asList(agentConfig.getUuid()));
    assertThat(isDisabled(agentConfig), is(true));
}
Also used : HttpOperationResult(com.thoughtworks.go.server.service.result.HttpOperationResult) AgentIdentifier(com.thoughtworks.go.remote.AgentIdentifier)

Aggregations

AgentIdentifier (com.thoughtworks.go.remote.AgentIdentifier)73 Test (org.junit.Test)53 AgentRuntimeInfo (com.thoughtworks.go.server.service.AgentRuntimeInfo)31 FakeBuildRepositoryRemote (com.thoughtworks.go.agent.testhelpers.FakeBuildRepositoryRemote)11 UploadEntry (com.thoughtworks.go.matchers.UploadEntry)10 File (java.io.File)9 Before (org.junit.Before)8 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)7 EnvironmentVariableContext (com.thoughtworks.go.util.command.EnvironmentVariableContext)6 AgentInstance (com.thoughtworks.go.domain.AgentInstance)4 AgentInstruction (com.thoughtworks.go.remote.AgentInstruction)4 NoWork (com.thoughtworks.go.remote.work.NoWork)4 Work (com.thoughtworks.go.remote.work.Work)4 AgentConfig (com.thoughtworks.go.config.AgentConfig)3 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)3 HttpOperationResult (com.thoughtworks.go.server.service.result.HttpOperationResult)3 GoConfigDao (com.thoughtworks.go.config.GoConfigDao)2 JobIdentifier (com.thoughtworks.go.domain.JobIdentifier)2 AgentCookie (com.thoughtworks.go.server.domain.AgentCookie)2 AgentInstances (com.thoughtworks.go.server.domain.AgentInstances)2