Search in sources :

Example 21 with Agents

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

the class JobInstanceSqlMapDaoTest method findByJobIdShouldLoadOriginalJobWhenCopiedForJobRerun.

@Test
public void findByJobIdShouldLoadOriginalJobWhenCopiedForJobRerun() throws Exception {
    Stage firstOldStage = savedPipeline.getStages().get(0);
    Stage newStage = instanceFactory.createStageForRerunOfJobs(firstOldStage, a(JOB_NAME), new DefaultSchedulingContext("loser", new Agents()), pipelineConfig.get(0), new TimeProvider(), "md5");
    stageDao.saveWithJobs(savedPipeline, newStage);
    dbHelper.passStage(newStage);
    JobIdentifier oldJobIdentifierThroughOldJob = jobInstanceDao.findOriginalJobIdentifier(new StageIdentifier(PIPELINE_NAME, null, savedPipeline.getLabel(), STAGE_NAME, String.valueOf(counter)), OTHER_JOB_NAME);
    JobIdentifier oldJobIdentifierThroughCopiedNewJob = jobInstanceDao.findOriginalJobIdentifier(new StageIdentifier(PIPELINE_NAME, null, savedPipeline.getLabel(), STAGE_NAME, String.valueOf(newStage.getCounter())), OTHER_JOB_NAME);
    JobIdentifier newJobIdentifierThroughRerunJob = jobInstanceDao.findOriginalJobIdentifier(new StageIdentifier(PIPELINE_NAME, null, savedPipeline.getLabel(), STAGE_NAME, String.valueOf(newStage.getCounter())), JOB_NAME);
    assertThat(oldJobIdentifierThroughOldJob, is(firstOldStage.getJobInstances().getByName(OTHER_JOB_NAME).getIdentifier()));
    assertThat(oldJobIdentifierThroughCopiedNewJob, is(firstOldStage.getJobInstances().getByName(OTHER_JOB_NAME).getIdentifier()));
    assertThat(newJobIdentifierThroughRerunJob, is(newStage.getJobInstances().getByName(JOB_NAME).getIdentifier()));
}
Also used : TimeProvider(com.thoughtworks.go.util.TimeProvider) Agents(com.thoughtworks.go.config.Agents) Test(org.junit.Test)

Aggregations

Agents (com.thoughtworks.go.config.Agents)21 Test (org.junit.Test)16 AgentConfig (com.thoughtworks.go.config.AgentConfig)13 EnvironmentVariablesConfig (com.thoughtworks.go.config.EnvironmentVariablesConfig)3 TimeProvider (com.thoughtworks.go.util.TimeProvider)3 EnvironmentVariableConfig (com.thoughtworks.go.config.EnvironmentVariableConfig)2 Resources (com.thoughtworks.go.config.Resources)2 StageConfig (com.thoughtworks.go.config.StageConfig)2 Before (org.junit.Before)2 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)1 ConfigSaveValidationContext (com.thoughtworks.go.config.ConfigSaveValidationContext)1 ResourceConfig (com.thoughtworks.go.config.ResourceConfig)1 ElasticProfile (com.thoughtworks.go.config.elastic.ElasticProfile)1 DefaultSchedulingContext (com.thoughtworks.go.domain.DefaultSchedulingContext)1 NullAgentInstance (com.thoughtworks.go.domain.NullAgentInstance)1 Pipeline (com.thoughtworks.go.domain.Pipeline)1 AgentStatusChangeListener (com.thoughtworks.go.listener.AgentStatusChangeListener)1 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)1 HashMap (java.util.HashMap)1 TransactionStatus (org.springframework.transaction.TransactionStatus)1