Skip to content

Commit

Permalink
Re-introduce the stage outputs change
Browse files Browse the repository at this point in the history
  • Loading branch information
robfletcher committed Aug 23, 2017
1 parent 3d7f5f5 commit a89c57b
Show file tree
Hide file tree
Showing 79 changed files with 649 additions and 292 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,6 @@ class DeleteApplicationTaskSpec extends Specification {
def taskResult = task.execute(new Stage<>(new Pipeline(), "DeleteApplication", config))

then:
taskResult.stageOutputs.previousState == application
taskResult.context.previousState == application
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ class UpsertApplicationTaskSpec extends Specification {
def result = task.execute(new Stage<>(new Pipeline(), "UpsertApplication", config))

then:
result.stageOutputs.previousState == (initialState ?: [:])
result.stageOutputs.newState == application
result.context.previousState == (initialState ?: [:])
result.context.newState == application

where:
initialState | operation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class MonitorBakeTask implements RetryableTask {
if (isCanceled(newStatus.state) && previousStatus.state == BakeStatus.State.PENDING) {
log.info("Original bake was 'canceled', re-baking (executionId: ${stage.execution.id}, previousStatus: ${previousStatus.state})")
def rebakeResult = createBakeTask.execute(stage)
return new TaskResult(ExecutionStatus.RUNNING, rebakeResult.stageOutputs, rebakeResult.globalOutputs)
return new TaskResult(ExecutionStatus.RUNNING, rebakeResult.context, rebakeResult.outputs)
}

new TaskResult(mapStatus(newStatus), [status: newStatus])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class BakeStageSpec extends Specification {
def taskResult = new BakeStage.CompleteParallelBakeTask().execute(pipelineStage)

then:
taskResult.globalOutputs == [
taskResult.outputs == [
deploymentDetails: [
["ami": 1], ["ami": 2], ["ami": 3]
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class CompletedBakeTaskSpec extends Specification {

then:
result.status == ExecutionStatus.SUCCEEDED
result.outputs.ami == ami
result.context.ami == ami

where:
region = "us-west-1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ class CreateBakeTaskSpec extends Specification {
then:
bake.packageName == 'hodor_1.1_all'
result.outputs.bakePackageName == 'hodor_1.1_all'
result.context.bakePackageName == 'hodor_1.1_all'
where:
triggerInfo | contextInfo
Expand Down Expand Up @@ -324,7 +324,7 @@ class CreateBakeTaskSpec extends Specification {
def result = task.execute(stage)
then:
with(result.outputs.status) {
with(result.context.status) {
id == runningStatus.id
state == runningStatus.state
}
Expand All @@ -340,7 +340,7 @@ class CreateBakeTaskSpec extends Specification {
def result = task.execute(stage)
then:
result.outputs.bakePackageName == bakeConfig.package
result.context.bakePackageName == bakeConfig.package
}
@Unroll
Expand All @@ -359,11 +359,11 @@ class CreateBakeTaskSpec extends Specification {
def result = task.execute(stage)
then:
result.outputs.bakePackageName == "hodor_1.1_all"
result.outputs.buildHost == "http://spinnaker.builds.test.netflix.net/"
result.outputs.job == jobName
result.outputs.buildNumber == "69"
!result.outputs.commitHash
result.context.bakePackageName == "hodor_1.1_all"
result.context.buildHost == "http://spinnaker.builds.test.netflix.net/"
result.context.job == jobName
result.context.buildNumber == "69"
!result.context.commitHash

where:
triggerInfo | contextInfo | jobName
Expand All @@ -389,11 +389,11 @@ class CreateBakeTaskSpec extends Specification {
def result = task.execute(stage)

then:
result.outputs.bakePackageName == "hodor_1.1_all"
result.outputs.buildHost == "http://spinnaker.builds.test.netflix.net/"
result.outputs.job == "SPINNAKER-package-echo"
result.outputs.buildNumber == "69"
result.outputs.commitHash == "f83a447f8d02a40fa84ec9d4d0dccd263d51782d"
result.context.bakePackageName == "hodor_1.1_all"
result.context.buildHost == "http://spinnaker.builds.test.netflix.net/"
result.context.job == "SPINNAKER-package-echo"
result.context.buildNumber == "69"
result.context.commitHash == "f83a447f8d02a40fa84ec9d4d0dccd263d51782d"

where:
triggerInfo | contextInfo
Expand All @@ -417,11 +417,11 @@ class CreateBakeTaskSpec extends Specification {
def result = task.execute(stage)

then:
result.outputs.bakePackageName == "hodor_1.1_all"
result.outputs.buildHost == "http://spinnaker.builds.test.netflix.net/"
result.outputs.job == "SPINNAKER-package-echo"
result.outputs.buildNumber == "69"
result.outputs.commitHash == "1234567f8d02a40fa84ec9d4d0dccd263d51782d"
result.context.bakePackageName == "hodor_1.1_all"
result.context.buildHost == "http://spinnaker.builds.test.netflix.net/"
result.context.job == "SPINNAKER-package-echo"
result.context.buildNumber == "69"
result.context.commitHash == "1234567f8d02a40fa84ec9d4d0dccd263d51782d"

where:
triggerInfo | contextInfo
Expand All @@ -445,11 +445,11 @@ class CreateBakeTaskSpec extends Specification {
def result = task.execute(stage)

then:
result.outputs.bakePackageName == "hodor_1.1_all"
result.outputs.buildHost == "http://spinnaker.builds.test.netflix.net/"
result.outputs.job == "SPINNAKER-package-echo"
result.outputs.buildNumber == "69"
result.outputs.commitHash == "f83a447f8d02a40fa84ec9d4d0dccd263d51782d"
result.context.bakePackageName == "hodor_1.1_all"
result.context.buildHost == "http://spinnaker.builds.test.netflix.net/"
result.context.job == "SPINNAKER-package-echo"
result.context.buildNumber == "69"
result.context.commitHash == "f83a447f8d02a40fa84ec9d4d0dccd263d51782d"

where:
triggerInfo | contextInfo
Expand All @@ -473,11 +473,11 @@ class CreateBakeTaskSpec extends Specification {
def result = task.execute(stage)

then:
result.outputs.bakePackageName == "hodor_1.1_all"
!result.outputs.buildHost
!result.outputs.job
!result.outputs.buildNumber
!result.outputs.commitHash
result.context.bakePackageName == "hodor_1.1_all"
!result.context.buildHost
!result.context.job
!result.context.buildNumber
!result.context.commitHash

where:
triggerInfo | contextInfo | extractBuildDetails
Expand Down Expand Up @@ -617,8 +617,8 @@ class CreateBakeTaskSpec extends Specification {
def result = task.execute(stage)

then:
result.stageOutputs.status == status
result.stageOutputs.previouslyBaked == previouslyBaked
result.context.status == status
result.context.previouslyBaked == previouslyBaked

where:
status | previouslyBaked
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ class MonitorBakeTaskSpec extends Specification {

then:
result.status == ExecutionStatus.RUNNING
(result.stageOutputs as Map) == [stage: 1]
(result.globalOutputs as Map) == [global: 2]
(result.context as Map) == [stage: 1]
(result.outputs as Map) == [global: 2]

where:
state << [BakeStatus.State.CANCELED, BakeStatus.State.CANCELLED]
Expand All @@ -106,7 +106,7 @@ class MonitorBakeTaskSpec extends Specification {
def result = task.execute(stage)

then:
with(result.outputs.status) {
with(result.context.status) {
id == previousStatus.id
state == BakeStatus.State.COMPLETED
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class WaitForClusterDisableTask extends AbstractWaitForClusterWideClouddriverTas
def duration = System.currentTimeMillis() - stage.startTime
if (taskResult.status == ExecutionStatus.SUCCEEDED && duration < MINIMUM_WAIT_TIME_MS) {
// wait at least MINIMUM_WAIT_TIME to account for any necessary connection draining to occur
return new TaskResult(ExecutionStatus.RUNNING, taskResult.stageOutputs, taskResult.globalOutputs)
return new TaskResult(ExecutionStatus.RUNNING, taskResult.context, taskResult.outputs)
}

return taskResult
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ abstract class AbstractInstancesCheckTask extends AbstractCloudProviderAwareTask
serverGroups.each { String region, List<String> serverGroupNames ->
serverGroupNames.each {
if (!oortHelper.getTargetServerGroup(account, it, region, getCloudProvider(stage)).isPresent()) {
log.error("Server group '${region}:${it}' does not exist (forceCacheRefreshResult: ${forceCacheRefreshResult.stageOutputs}")
log.error("Server group '${region}:${it}' does not exist (forceCacheRefreshResult: ${forceCacheRefreshResult.context}")
throw new MissingServerGroupException("Server group '${region}:${it}' does not exist")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class DetermineHealthProvidersTaskSpec extends Specification {

then:
taskResult.status == ExecutionStatus.SUCCEEDED
(taskResult.getStageOutputs() as Map) == expectedStageOutputs
(taskResult.getContext() as Map) == expectedStageOutputs

where:
stageContext | application || expectedStageOutputs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class MigratePipelineClustersTaskSpec extends Specification {
then:
1 * front50Service.getPipelines('theapp') >> [[id: 'def']]
result.status == ExecutionStatus.TERMINAL
result.stageOutputs.exception == "Could not find pipeline with ID abc"
result.context.exception == "Could not find pipeline with ID abc"
}

void 'extracts clusters, sends them to clouddriver, and puts pipeline into context for later retrieval'() {
Expand Down Expand Up @@ -78,7 +78,7 @@ class MigratePipelineClustersTaskSpec extends Specification {
it[0].migrateClusterConfigurations.sources.cluster.id == [1,2,3,4]
it[0].migrateClusterConfigurations.regionMapping == ['us-east-1': 'us-west-1']
}) >> rx.Observable.from([new TaskId(id: "1")])
result.stageOutputs['source.pipeline'] == pipeline
result.context['source.pipeline'] == pipeline
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ class MonitorKatoTaskSpec extends Specification {

then:
result.status
result.stageOutputs.isEmpty()
result.globalOutputs.isEmpty()
result.context.isEmpty()
result.outputs.isEmpty()

where:
context | _
Expand Down Expand Up @@ -135,7 +135,7 @@ class MonitorKatoTaskSpec extends Specification {

then:
result.status == ExecutionStatus.RUNNING
result.stageOutputs['kato.task.notFoundRetryCount'] == 1
result.context['kato.task.notFoundRetryCount'] == 1

where:
taskId = "katoTaskId"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class AbstractWaitForClusterWideClouddriverTaskSpec extends Specification {
1 * oortHelper.getCluster(application, credentials, cluster, cloudProvider) >> Optional.of([serverGroups: serverGroups])

result.status == ExecutionStatus.RUNNING
result.stageOutputs.remainingDeployServerGroups == expected
result.context.remainingDeployServerGroups == expected

where:
serverGroups = [sg('s1', 'r1'), sg('s2', 'r1'), sg('s3', 'r2'), sg('s4', 'r2')]
Expand Down Expand Up @@ -95,7 +95,7 @@ class AbstractWaitForClusterWideClouddriverTaskSpec extends Specification {
1 * oortHelper.getCluster(application, credentials, cluster, cloudProvider) >> Optional.of([serverGroups: [sg('c1')]])

result.status == ExecutionStatus.RUNNING
result.stageOutputs.remainingDeployServerGroups == [dsg('c1')]
result.context.remainingDeployServerGroups == [dsg('c1')]
}

def 'finishes when last serverGroups disappear'() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ class FindImageFromClusterTaskSpec extends Specification {
"LARGEST", FindImageFromClusterTask.SUMMARY_TYPE, false.toString()) >> oortResponse1
1 * oortService.getServerGroupSummary("foo", "test", "foo-test", "cloudProvider", location2.value,
"LARGEST", FindImageFromClusterTask.SUMMARY_TYPE, false.toString()) >> oortResponse2
assertNorth result.globalOutputs?.deploymentDetails?.find {
assertNorth result.outputs?.deploymentDetails?.find {
it.region == "north"
} as Map
assertSouth result.globalOutputs?.deploymentDetails?.find {
assertSouth result.outputs?.deploymentDetails?.find {
it.region == "south"
} as Map

Expand Down Expand Up @@ -199,10 +199,10 @@ class FindImageFromClusterTaskSpec extends Specification {
throw RetrofitError.httpError("http://clouddriver", new Response("http://clouddriver", 404, 'Not Found', [], new TypedString("{}")), null, Map)
}
1 * oortService.findImage("cloudProvider", "ami-012-name-ebs*", "test", null, null) >> imageSearchResult
assertNorth(result.globalOutputs?.deploymentDetails?.find {
assertNorth(result.outputs?.deploymentDetails?.find {
it.region == "north"
} as Map, [imageName: "ami-012-name-ebs"])
assertSouth(result.globalOutputs?.deploymentDetails?.find {
assertSouth(result.outputs?.deploymentDetails?.find {
it.region == "south"
} as Map, [sourceServerGroup: "foo-test", imageName: "ami-012-name-ebs1", foo: "bar"])

Expand Down Expand Up @@ -262,10 +262,10 @@ class FindImageFromClusterTaskSpec extends Specification {
throw RetrofitError.httpError("http://clouddriver", new Response("http://clouddriver", 404, 'Not Found', [], new TypedString("{}")), null, Map)
}
1 * oortService.findImage("cloudProvider", "ami-012-name-ebs*", "test", null, null) >> imageSearchResult
assertNorth(result.globalOutputs?.deploymentDetails?.find {
assertNorth(result.outputs?.deploymentDetails?.find {
it.region == "north"
} as Map, [imageName: "ami-012-name-ebs"])
assertSouth(result.globalOutputs?.deploymentDetails?.find {
assertSouth(result.outputs?.deploymentDetails?.find {
it.region == "south"
} as Map, [sourceServerGroup: "foo-test", imageName: "ami-012-name-ebs1", foo: "bar"])

Expand Down Expand Up @@ -326,10 +326,10 @@ class FindImageFromClusterTaskSpec extends Specification {
}
1 * oortService.findImage("aws", "ami-012-name-ebs*", "test", null, null) >> null
1 * oortService.findImage("aws", "ami-012-name-ebs*", "bakery", null, null) >> imageSearchResult
assertNorth(result.globalOutputs?.deploymentDetails?.find {
assertNorth(result.outputs?.deploymentDetails?.find {
it.region == "north"
} as Map, [imageName: "ami-012-name-ebs"])
assertSouth(result.globalOutputs?.deploymentDetails?.find {
assertSouth(result.outputs?.deploymentDetails?.find {
it.region == "south"
} as Map, [sourceServerGroup: "foo-test", imageName: "ami-012-name-ebs1", foo: "bar"])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class AbstractInstancesCheckTaskSpec extends Specification {
def result = task.execute(stage)

then:
result.stageOutputs.zeroDesiredCapacityCount == expected
result.context.zeroDesiredCapacityCount == expected
1 * task.oortService.getServerGroup("front50", "test", "us-west-1", "front50-v000") >> constructResponse(200, '''
{
"name": "front50-v000",
Expand Down Expand Up @@ -178,7 +178,7 @@ class AbstractInstancesCheckTaskSpec extends Specification {
def result = task.execute(stage)

then:
result.stageOutputs.zeroDesiredCapacityCount == 1
result.context.zeroDesiredCapacityCount == 1
1 * task.oortService.getServerGroup("front50", "test", "us-west-1", "front50-v000") >> constructResponse(200, '''
{
"name": "front50-v000",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class CaptureInstanceUptimeTaskSpec extends Specification {

then:
result.status == ExecutionStatus.SUCCEEDED
(result.stageOutputs as Map) == [instanceUptimes: [:]]
(result.context as Map) == [instanceUptimes: [:]]
}

def "should capture instance uptime for every instanceId"() {
Expand All @@ -55,7 +55,7 @@ class CaptureInstanceUptimeTaskSpec extends Specification {

then:
result.status == ExecutionStatus.SUCCEEDED
(result.stageOutputs as Map) == [instanceUptimes: ["1": 1, "2": 2]]
(result.context as Map) == [instanceUptimes: ["1": 1, "2": 2]]

1 * task.instanceUptimeCommand.uptime("aws", [instanceId: "1"]) >> {
return new InstanceUptimeCommand.InstanceUptimeResult(1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class DeregisterInstancesFromLoadBalancerTaskSpec extends Specification {

then:
result.status == ExecutionStatus.SUCCEEDED
result.outputs."kato.last.task.id" == taskId
result.outputs.interestingHealthProviderNames == ["LoadBalancer", "TargetGroup"]
result.context."kato.last.task.id" == taskId
result.context.interestingHealthProviderNames == ["LoadBalancer", "TargetGroup"]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class RegisterInstancesWithLoadBalancerTaskSpec extends Specification {

then:
result.status == ExecutionStatus.SUCCEEDED
result.outputs."kato.last.task.id" == taskId
result.outputs.interestingHealthProviderNames == ["LoadBalancer", "TargetGroup"]
result.context."kato.last.task.id" == taskId
result.context.interestingHealthProviderNames == ["LoadBalancer", "TargetGroup"]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class DeleteLoadBalancerTaskSpec extends Specification {

then:
result.status == ExecutionStatus.SUCCEEDED
result.outputs."kato.last.task.id" == taskId
result.outputs."delete.account.name" == deleteLoadBalancerConfig.credentials
result.context."kato.last.task.id" == taskId
result.context."delete.account.name" == deleteLoadBalancerConfig.credentials
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class UpsertLoadBalancerResultObjectExtrapolationTaskSpec extends Specification
def result = task.execute(stage)

then:
result.outputs.dnsName == dnsName
result.context.dnsName == dnsName
}

}
Loading

0 comments on commit a89c57b

Please sign in to comment.