Search in sources :

Example 1 with PipelineTimelineEntry

use of com.thoughtworks.go.domain.PipelineTimelineEntry in project gocd by gocd.

the class PipelineRepositoryTest method shouldNotUpdateTimelineEntriesAndEntriesForRollbackUponFailureDuringRetrieval.

@Test
public void shouldNotUpdateTimelineEntriesAndEntriesForRollbackUponFailureDuringRetrieval() throws Exception {
    Object[] pipelineRow1 = { "p1", new BigInteger("1"), new BigInteger("1"), new Date(), "fingerprint", 1.0, "r1", null, new BigInteger("1"), new BigInteger("1") };
    Object[] pipelineRow2 = { "p1", "cause-failure-during-retrieval", new BigInteger("2"), new Date(), "fingerprint", 2.0, "r2", null, new BigInteger("1"), new BigInteger("1") };
    stubPipelineInstancesInDb(pipelineRow1, pipelineRow2);
    ArrayList<PipelineTimelineEntry> tempEntries = new ArrayList<>();
    PipelineTimeline pipelineTimeline = new PipelineTimeline(pipelineRepository, transactionTemplate, transactionSynchronizationManager);
    try {
        pipelineRepository.updatePipelineTimeline(pipelineTimeline, tempEntries);
        fail("Should fail to retrieve pipeline.");
    } catch (ClassCastException e) {
        assertThat(tempEntries.size(), is(0));
        assertThat(pipelineTimeline.instanceCount(new CaseInsensitiveString("p1")), is(0));
    }
}
Also used : ArrayList(java.util.ArrayList) BigInteger(java.math.BigInteger) PipelineTimelineEntry(com.thoughtworks.go.domain.PipelineTimelineEntry) PipelineTimeline(com.thoughtworks.go.server.domain.PipelineTimeline) Date(java.util.Date) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 2 with PipelineTimelineEntry

use of com.thoughtworks.go.domain.PipelineTimelineEntry in project gocd by gocd.

the class PipelineRepositoryTest method shouldUpdateTimelineEntriesAndEntriesForRollback.

@Test
public void shouldUpdateTimelineEntriesAndEntriesForRollback() throws Exception {
    Object[] pipelineRow1 = { "p1", new BigInteger("1"), new BigInteger("1"), new Date(), "fingerprint", 1.0, "r1", null, new BigInteger("1"), new BigInteger("1") };
    Object[] pipelineRow2 = { "p1", new BigInteger("2"), new BigInteger("2"), new Date(), "fingerprint", 2.0, "r2", null, new BigInteger("1"), new BigInteger("1") };
    stubPipelineInstancesInDb(pipelineRow1, pipelineRow2);
    ArrayList<PipelineTimelineEntry> tempEntries = new ArrayList<>();
    PipelineTimeline pipelineTimeline = new PipelineTimeline(pipelineRepository, transactionTemplate, transactionSynchronizationManager);
    pipelineRepository.updatePipelineTimeline(pipelineTimeline, tempEntries);
    PipelineTimelineEntry timelineEntry1 = pipelineTimeline.getEntryFor(new CaseInsensitiveString("p1"), 1);
    PipelineTimelineEntry timelineEntry2 = pipelineTimeline.getEntryFor(new CaseInsensitiveString("p1"), 2);
    assertThat(pipelineTimeline.instanceCount(new CaseInsensitiveString("p1")), is(2));
    assertNotNull(timelineEntry1);
    assertNotNull(timelineEntry2);
    assertThat(tempEntries.size(), is(2));
    assertThat(tempEntries, containsInAnyOrder(timelineEntry1, timelineEntry2));
}
Also used : ArrayList(java.util.ArrayList) BigInteger(java.math.BigInteger) PipelineTimelineEntry(com.thoughtworks.go.domain.PipelineTimelineEntry) PipelineTimeline(com.thoughtworks.go.server.domain.PipelineTimeline) Date(java.util.Date) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 3 with PipelineTimelineEntry

use of com.thoughtworks.go.domain.PipelineTimelineEntry in project gocd by gocd.

the class PipelineRepositoryTest method shouldUpdateTimelineEntriesAndEntriesForRollbackDuringFailureWhileUpdatingTheDb.

@Test
public void shouldUpdateTimelineEntriesAndEntriesForRollbackDuringFailureWhileUpdatingTheDb() throws Exception {
    Object[] pipelineRow1 = { "p1", new BigInteger("1"), new BigInteger("1"), new Date(), "fingerprint", 1.0, "r1", null, new BigInteger("1"), new BigInteger("1") };
    Object[] pipelineRow2 = { "p1", new BigInteger("2"), new BigInteger("2"), new Date(), "fingerprint", 2.0, "r2", null, new BigInteger("1"), new BigInteger("1") };
    stubPipelineInstancesInDb(pipelineRow1, pipelineRow2);
    when(sqlQuery.executeUpdate()).thenThrow(new RuntimeException("Failure during update natural order in db"));
    ArrayList<PipelineTimelineEntry> tempEntries = new ArrayList<>();
    PipelineTimeline pipelineTimeline = new PipelineTimeline(pipelineRepository, transactionTemplate, transactionSynchronizationManager);
    try {
        pipelineRepository.updatePipelineTimeline(pipelineTimeline, tempEntries);
    } catch (RuntimeException e) {
        PipelineTimelineEntry timelineEntry1 = pipelineTimeline.getEntryFor(new CaseInsensitiveString("p1"), 1);
        PipelineTimelineEntry timelineEntry2 = pipelineTimeline.getEntryFor(new CaseInsensitiveString("p1"), 2);
        assertThat(pipelineTimeline.instanceCount(new CaseInsensitiveString("p1")), is(2));
        assertNotNull(timelineEntry1);
        assertNotNull(timelineEntry2);
        assertThat(tempEntries.size(), is(2));
        assertThat(tempEntries, containsInAnyOrder(timelineEntry1, timelineEntry2));
    }
}
Also used : ArrayList(java.util.ArrayList) BigInteger(java.math.BigInteger) PipelineTimelineEntry(com.thoughtworks.go.domain.PipelineTimelineEntry) PipelineTimeline(com.thoughtworks.go.server.domain.PipelineTimeline) Date(java.util.Date) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 4 with PipelineTimelineEntry

use of com.thoughtworks.go.domain.PipelineTimelineEntry in project gocd by gocd.

the class ReportingDependencyFanInNode method addToRevisionQueue.

private void addToRevisionQueue(PipelineTimelineEntry entry, Queue<PipelineTimelineEntry.Revision> revisionQueue, List<ReportingFaninScmMaterial> scmMaterials, ReportingFanInGraphContext context) {
    printPipelineTimelineEntry(entry, context);
    for (Map.Entry<String, List<PipelineTimelineEntry.Revision>> revisionList : entry.revisions().entrySet()) {
        String fingerprint = revisionList.getKey();
        PipelineTimelineEntry.Revision revision = revisionList.getValue().get(0);
        if (isScmMaterial(fingerprint, context)) {
            scmMaterials.add(new ReportingFaninScmMaterial(fingerprint, revision));
            continue;
        }
        if (isDependencyMaterial(fingerprint, context)) {
            revisionQueue.add(revision);
        }
    }
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) PipelineTimelineEntry(com.thoughtworks.go.domain.PipelineTimelineEntry)

Example 5 with PipelineTimelineEntry

use of com.thoughtworks.go.domain.PipelineTimelineEntry in project gocd by gocd.

the class DependencyFanInNode method addToRevisionQueue.

private void addToRevisionQueue(PipelineTimelineEntry entry, Queue<PipelineTimelineEntry.Revision> revisionQueue, List<FaninScmMaterial> scmMaterials, FanInGraphContext context, Set<CaseInsensitiveString> visitedNodes) {
    for (Map.Entry<String, List<PipelineTimelineEntry.Revision>> revisionList : entry.revisions().entrySet()) {
        String fingerprint = revisionList.getKey();
        PipelineTimelineEntry.Revision revision = revisionList.getValue().get(0);
        if (isScmMaterial(fingerprint, context)) {
            scmMaterials.add(new FaninScmMaterial(fingerprint, revision));
            continue;
        }
        if (isDependencyMaterial(fingerprint, context) && !visitedNodes.contains(new CaseInsensitiveString(revision.revision))) {
            revisionQueue.add(revision);
            visitedNodes.add(new CaseInsensitiveString(revision.revision));
        }
    }
}
Also used : CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) PipelineTimelineEntry(com.thoughtworks.go.domain.PipelineTimelineEntry) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString)

Aggregations

PipelineTimelineEntry (com.thoughtworks.go.domain.PipelineTimelineEntry)31 Test (org.junit.Test)18 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)12 ArrayList (java.util.ArrayList)11 DateTime (org.joda.time.DateTime)11 PipelineTimeline (com.thoughtworks.go.server.domain.PipelineTimeline)9 List (java.util.List)6 Date (java.util.Date)5 BigInteger (java.math.BigInteger)4 Map (java.util.Map)4 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)3 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)3 TimelineUpdateListener (com.thoughtworks.go.listener.TimelineUpdateListener)3 HashMap (java.util.HashMap)3 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)2 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)2 HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)2 StageIdentifier (com.thoughtworks.go.domain.StageIdentifier)2 DependencyMaterialRevision (com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision)2 PipelineConfigMother.createPipelineConfig (com.thoughtworks.go.helper.PipelineConfigMother.createPipelineConfig)2