Skip to content

Commit 7902999

Browse files
committed
Test for flag isolatedStreamExecution for StartPipelineTask
1 parent 9689514 commit 7902999

File tree

2 files changed

+52
-3
lines changed

2 files changed

+52
-3
lines changed

orca-front50/src/main/groovy/com/netflix/spinnaker/orca/front50/tasks/StartPipelineTask.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ class StartPipelineTask implements Task {
124124
stage.id,
125125
getUser(stage.execution)
126126
)
127-
TaskResult.builder(ExecutionStatus.SUCCEEDED).context([executionId: pipeline.id, executionName: pipelineConfig.name]).build()
127+
return TaskResult.builder(ExecutionStatus.SUCCEEDED).context([executionId: pipeline.id, executionName: pipelineConfig.name]).build()
128128
}
129129

130130
def pipeline = dependentPipelineStarter.trigger(
@@ -136,7 +136,7 @@ class StartPipelineTask implements Task {
136136
getUser(stage.execution)
137137
)
138138

139-
TaskResult.builder(ExecutionStatus.SUCCEEDED).context([executionId: pipeline.id, executionName: pipelineConfig.name]).build()
139+
return TaskResult.builder(ExecutionStatus.SUCCEEDED).context([executionId: pipeline.id, executionName: pipelineConfig.name]).build()
140140
}
141141

142142
// There are currently two sources-of-truth for the user:

orca-front50/src/test/groovy/com/netflix/spinnaker/orca/front50/tasks/StartPipelineTaskSpec.groovy

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616

1717
package com.netflix.spinnaker.orca.front50.tasks
1818

19-
2019
import com.netflix.spinnaker.orca.api.pipeline.ExecutionPreprocessor
2120
import com.netflix.spinnaker.orca.front50.DependentPipelineStarter
2221
import com.netflix.spinnaker.orca.front50.Front50Service
22+
import com.netflix.spinnaker.orca.pipeline.model.StageExecutionImpl
2323
import com.netflix.spinnaker.orca.pipeline.util.ContextParameterProcessor
2424
import spock.lang.Specification
2525
import spock.lang.Subject
@@ -111,4 +111,53 @@ class StartPipelineTaskSpec extends Specification {
111111
) || "authenticated_user" || ["account1"]
112112

113113
}
114+
115+
@Unroll
116+
def "should trigger the dependent pipeline with isolatedStreamExecution"() {
117+
given:
118+
def pipelineConfig = [id: "testStrategyId", application: "orca", name: "testStrategy", other: "other"]
119+
120+
1 * front50Service.getStrategies(_) >> [pipelineConfig]
121+
def stage = stage {
122+
type = "whatever"
123+
name = "testing"
124+
context = [
125+
pipelineId : "testStrategyId",
126+
pipelineParameters : [
127+
strategy: true,
128+
zone : "north-pole-1",
129+
],
130+
isolatedStreamExecution: isIsolatedStreamExecution
131+
]
132+
}
133+
134+
stage.getExecution().getStages().add(new StageExecutionImpl(stage.getExecution(), "stage2"))
135+
stage.getExecution().getStages().add(new StageExecutionImpl(stage.getExecution(), "stage3"))
136+
def parentPipelineStageId
137+
def pipelineExecution
138+
139+
when:
140+
def result = task.execute(stage)
141+
142+
then:
143+
dependentPipelineStarter.trigger(*_) >> {
144+
pipelineExecution = it[2]
145+
parentPipelineStageId = it[4]
146+
147+
return pipeline {
148+
id = "testPipelineId"
149+
application = "orca"
150+
}
151+
}
152+
153+
parentPipelineStageId == stage.id
154+
stagesNumber == pipelineExecution.getStages().size()
155+
156+
where:
157+
isIsolatedStreamExecution || stagesNumber
158+
false || 3
159+
true || 1
160+
161+
}
162+
114163
}

0 commit comments

Comments
 (0)