Skip to content

Commit

Permalink
fix(sql/repository): return to sorting stages only by refId (#3145)
Browse files Browse the repository at this point in the history
  • Loading branch information
asher committed Sep 12, 2019
1 parent bd27652 commit 2e78490
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ abstract class QueueIntegrationTest {
repository.retrieve(PIPELINE, pipeline.id).apply {
assertThat(status).isEqualTo(SUCCEEDED)
assertThat(stages.size).isEqualTo(2)
assertThat(stages.first().type).isEqualTo(RestrictExecutionDuringTimeWindow.TYPE)
assertThat(stages.map { it.type }).contains(RestrictExecutionDuringTimeWindow.TYPE)
assertThat(stages.map { it.status }).allMatch { it == SUCCEEDED }
}
}
Expand Down Expand Up @@ -612,9 +612,12 @@ abstract class QueueIntegrationTest {
assertSoftly {
assertThat(status).isEqualTo(SUCCEEDED)
assertThat(stages.size).isEqualTo(5)
assertThat(stages.first().type).isEqualTo(RestrictExecutionDuringTimeWindow.TYPE)
assertThat(stages[1..3].map { it.type }).allMatch { it == "dummy" }
assertThat(stages.last().type).isEqualTo("parallel")
assertThat(stages.map { it.type }).containsExactlyInAnyOrder(
RestrictExecutionDuringTimeWindow.TYPE,
"dummy",
"dummy",
"dummy",
"parallel")
assertThat(stages.map { it.status }).allMatch { it == SUCCEEDED }
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.module.kotlin.readValue
import com.netflix.spinnaker.orca.pipeline.model.Execution
import com.netflix.spinnaker.orca.pipeline.model.Stage
import com.netflix.spinnaker.orca.pipeline.model.SyntheticStageOwner.STAGE_AFTER
import com.netflix.spinnaker.orca.pipeline.model.SyntheticStageOwner.STAGE_BEFORE
import org.jooq.DSLContext
import org.slf4j.LoggerFactory
import java.sql.ResultSet
Expand Down Expand Up @@ -77,24 +75,7 @@ class ExecutionMapper(
}

executions.forEach { execution ->
val stages = mutableListOf<Stage>()

stages.addAll(
execution.stages.filter { it.parentStageId == null }
.sortedBy { it.refId }
)

execution.stages.filter { it.parentStageId != null }
.sortedBy { it.refId }
.forEach {
when (it.syntheticStageOwner) {
STAGE_BEFORE -> stages.add(stages.indexOf(it.parent), it)
STAGE_AFTER -> stages.add(stages.indexOf(it.parent) + 1, it)
}
}

execution.stages.clear()
execution.stages.addAll(stages)
execution.stages.sortBy { it.refId }
}
}
}
Expand Down

0 comments on commit 2e78490

Please sign in to comment.