use of com.thoughtworks.go.domain.JobAgentMetadata in project gocd by gocd.
the class JobControllerIntegrationTest method jobDetailModel_shouldHaveTheElasticProfilePluginIdWhenAgentIsNotAssigned.
@Test
public void jobDetailModel_shouldHaveTheElasticProfilePluginIdWhenAgentIsNotAssigned() throws Exception {
Pipeline pipeline = fixture.createPipelineWithFirstStageAssigned();
Stage stage = pipeline.getFirstStage();
JobInstance job = stage.getFirstJob();
GoPluginDescriptor.About about = GoPluginDescriptor.About.builder().name("name").version("0.1").targetGoVersion("17.3.0").description("desc").build();
GoPluginDescriptor descriptor = GoPluginDescriptor.builder().id("plugin_id").about(about).build();
ElasticAgentMetadataStore.instance().setPluginInfo(new ElasticAgentPluginInfo(descriptor, null, null, null, null, new Capabilities(false, true)));
ElasticProfile profile = new ElasticProfile("profile_id", "cluster_profile_id", Collections.EMPTY_LIST);
ClusterProfile clusterProfile = new ClusterProfile("cluster_profile_id", "plugin_id", Collections.EMPTY_LIST);
fixture.addJobAgentMetadata(new JobAgentMetadata(job.getId(), profile, clusterProfile));
ModelAndView modelAndView = controller.jobDetail(pipeline.getName(), String.valueOf(pipeline.getCounter()), stage.getName(), String.valueOf(stage.getCounter()), job.getName());
assertThat(modelAndView.getModel().get("elasticAgentPluginId"), is("plugin_id"));
}
use of com.thoughtworks.go.domain.JobAgentMetadata in project gocd by gocd.
the class JobAgentMetadataSqlMapDaoIntegrationTest method shouldSaveElasticAgentPropertyOnJob.
@Test
public void shouldSaveElasticAgentPropertyOnJob() throws Exception {
ElasticProfile profile = new ElasticProfile("elastic", "clusterProfileId");
ClusterProfile clusterProfile = new ClusterProfile("clusterProfileId", "plugin");
JobAgentMetadata jobAgentMetadata = new JobAgentMetadata(jobId, profile, clusterProfile);
dao.save(jobAgentMetadata);
JobAgentMetadata metadataFromDb = dao.load(jobId);
assertThat(metadataFromDb.elasticProfile(), is(profile));
assertThat(metadataFromDb.clusterProfile(), is(clusterProfile));
assertThat(metadataFromDb, is(jobAgentMetadata));
}
use of com.thoughtworks.go.domain.JobAgentMetadata in project gocd by gocd.
the class JobControllerIntegrationTest method jobDetailModel_shouldHaveTheElasticPluginIdAndElasticAgentIdWhenAgentIsAssigned.
@Test
public void jobDetailModel_shouldHaveTheElasticPluginIdAndElasticAgentIdWhenAgentIsAssigned() throws Exception {
Pipeline pipeline = fixture.createPipelineWithFirstStageAssigned();
Stage stage = pipeline.getFirstStage();
JobInstance job = stage.getFirstJob();
GoPluginDescriptor.About about = GoPluginDescriptor.About.builder().name("name").version("0.1").targetGoVersion("17.3.0").description("desc").build();
GoPluginDescriptor descriptor = GoPluginDescriptor.builder().id("plugin_id").about(about).build();
ElasticAgentMetadataStore.instance().setPluginInfo(new ElasticAgentPluginInfo(descriptor, null, null, null, null, new Capabilities(false, true)));
ElasticProfile profile = new ElasticProfile("profile_id", "cluster_profile_id", Collections.EMPTY_LIST);
ClusterProfile clusterProfile = new ClusterProfile("cluster_profile_id", "plugin_id", Collections.EMPTY_LIST);
fixture.addJobAgentMetadata(new JobAgentMetadata(job.getId(), profile, clusterProfile));
final Agent agent = new Agent(job.getAgentUuid(), "localhost", "127.0.0.1", uuidGenerator.randomUuid());
agent.setElasticAgentId("elastic_agent_id");
agent.setElasticPluginId("plugin_id");
agentService.saveOrUpdate(agent);
ModelAndView modelAndView = controller.jobDetail(pipeline.getName(), String.valueOf(pipeline.getCounter()), stage.getName(), String.valueOf(stage.getCounter()), job.getName());
assertThat(modelAndView.getModel().get("elasticAgentPluginId"), is("plugin_id"));
assertThat(modelAndView.getModel().get("elasticAgentId"), is("elastic_agent_id"));
}
use of com.thoughtworks.go.domain.JobAgentMetadata in project gocd by gocd.
the class JobAgentMetadataSqlMapDaoIntegrationTest method shouldDeleteElasticAgentPropertySetToJob.
@Test
public void shouldDeleteElasticAgentPropertySetToJob() throws Exception {
ElasticProfile profile = new ElasticProfile("elastic", "clusterProfileId", new ConfigurationProperty());
ClusterProfile clusterProfile = new ClusterProfile("clusterProfileId", "plugin", new ConfigurationProperty());
JobAgentMetadata jobAgentMetadata = new JobAgentMetadata(jobId, profile, clusterProfile);
dao.save(jobAgentMetadata);
JobAgentMetadata metadataFromDb = dao.load(jobId);
assertThat(metadataFromDb, is(jobAgentMetadata));
dao.delete(metadataFromDb);
assertThat(dao.load(jobId), is(nullValue()));
}
Aggregations