Search in sources :

Example 1 with JobAgentMetadata

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"));
}
Also used : ElasticAgentPluginInfo(com.thoughtworks.go.plugin.domain.elastic.ElasticAgentPluginInfo) JobAgentMetadata(com.thoughtworks.go.domain.JobAgentMetadata) JobInstance(com.thoughtworks.go.domain.JobInstance) Capabilities(com.thoughtworks.go.plugin.domain.elastic.Capabilities) ModelAndView(org.springframework.web.servlet.ModelAndView) Stage(com.thoughtworks.go.domain.Stage) GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) ElasticProfile(com.thoughtworks.go.config.elastic.ElasticProfile) ClusterProfile(com.thoughtworks.go.config.elastic.ClusterProfile) Pipeline(com.thoughtworks.go.domain.Pipeline) Test(org.junit.jupiter.api.Test)

Example 2 with JobAgentMetadata

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));
}
Also used : JobAgentMetadata(com.thoughtworks.go.domain.JobAgentMetadata) ElasticProfile(com.thoughtworks.go.config.elastic.ElasticProfile) ClusterProfile(com.thoughtworks.go.config.elastic.ClusterProfile) Test(org.junit.jupiter.api.Test)

Example 3 with 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"));
}
Also used : Agent(com.thoughtworks.go.config.Agent) ElasticAgentPluginInfo(com.thoughtworks.go.plugin.domain.elastic.ElasticAgentPluginInfo) JobAgentMetadata(com.thoughtworks.go.domain.JobAgentMetadata) JobInstance(com.thoughtworks.go.domain.JobInstance) Capabilities(com.thoughtworks.go.plugin.domain.elastic.Capabilities) ModelAndView(org.springframework.web.servlet.ModelAndView) Stage(com.thoughtworks.go.domain.Stage) GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) ElasticProfile(com.thoughtworks.go.config.elastic.ElasticProfile) ClusterProfile(com.thoughtworks.go.config.elastic.ClusterProfile) Pipeline(com.thoughtworks.go.domain.Pipeline) Test(org.junit.jupiter.api.Test)

Example 4 with JobAgentMetadata

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()));
}
Also used : ConfigurationProperty(com.thoughtworks.go.domain.config.ConfigurationProperty) JobAgentMetadata(com.thoughtworks.go.domain.JobAgentMetadata) ElasticProfile(com.thoughtworks.go.config.elastic.ElasticProfile) ClusterProfile(com.thoughtworks.go.config.elastic.ClusterProfile) Test(org.junit.jupiter.api.Test)

Aggregations

ClusterProfile (com.thoughtworks.go.config.elastic.ClusterProfile)4 ElasticProfile (com.thoughtworks.go.config.elastic.ElasticProfile)4 JobAgentMetadata (com.thoughtworks.go.domain.JobAgentMetadata)4 Test (org.junit.jupiter.api.Test)4 JobInstance (com.thoughtworks.go.domain.JobInstance)2 Pipeline (com.thoughtworks.go.domain.Pipeline)2 Stage (com.thoughtworks.go.domain.Stage)2 Capabilities (com.thoughtworks.go.plugin.domain.elastic.Capabilities)2 ElasticAgentPluginInfo (com.thoughtworks.go.plugin.domain.elastic.ElasticAgentPluginInfo)2 GoPluginDescriptor (com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor)2 ModelAndView (org.springframework.web.servlet.ModelAndView)2 Agent (com.thoughtworks.go.config.Agent)1 ConfigurationProperty (com.thoughtworks.go.domain.config.ConfigurationProperty)1