diff --git a/orca-api-tck/orca-api-tck.gradle b/orca-api-tck/orca-api-tck.gradle index 5d59ad3d42..c883826f94 100644 --- a/orca-api-tck/orca-api-tck.gradle +++ b/orca-api-tck/orca-api-tck.gradle @@ -33,7 +33,9 @@ dependencies { api("org.springframework.boot:spring-boot-starter-test") api("org.springframework.security:spring-security-test") api("org.springframework.security:spring-security-config") - api("com.ninja-squad:springmockk:+") + api("com.ninja-squad:springmockk:4.0.2") { + force = true + } testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine") } diff --git a/orca-clouddriver/orca-clouddriver.gradle b/orca-clouddriver/orca-clouddriver.gradle index 86022c6c22..e699186798 100644 --- a/orca-clouddriver/orca-clouddriver.gradle +++ b/orca-clouddriver/orca-clouddriver.gradle @@ -32,7 +32,7 @@ dependencies { } implementation("com.amazonaws:aws-java-sdk-lambda") implementation("org.bitbucket.b_c:jose4j:0.9.4") - implementation("javax.validation:validation-api:+") + implementation("jakarta.validation:jakarta.validation-api:3.1.0") implementation("com.netflix.frigga:frigga:+") implementation("org.jetbrains:annotations") implementation("com.fasterxml.jackson.datatype:jackson-datatype-guava") @@ -58,7 +58,9 @@ dependencies { testImplementation("io.spinnaker.fiat:fiat-core:$fiatVersion") testImplementation("dev.minutest:minutest") testImplementation("io.strikt:strikt-core") - testImplementation("io.mockk:mockk") + testImplementation("io.mockk:mockk:1.13.7") { + force true + } testImplementation("ru.lanwen.wiremock:wiremock-junit5:1.3.1") testCompileOnly("org.projectlombok:lombok") diff --git a/orca-clouddriver/src/main/groovy/com/netflix/spinnaker/orca/kato/pipeline/support/SourceResolver.groovy b/orca-clouddriver/src/main/groovy/com/netflix/spinnaker/orca/kato/pipeline/support/SourceResolver.groovy index 513a0ecf97..b3977fc705 100644 --- a/orca-clouddriver/src/main/groovy/com/netflix/spinnaker/orca/kato/pipeline/support/SourceResolver.groovy +++ b/orca-clouddriver/src/main/groovy/com/netflix/spinnaker/orca/kato/pipeline/support/SourceResolver.groovy @@ -111,11 +111,9 @@ class SourceResolver { regionalAsgs = onlyEnabled } - def instanceSize = { ServerGroup asg -> asg.instances?.size() ?: 0 } - def created = { ServerGroup asg -> asg.createdTime ?: 0 } - /*if (stageData.useSourceCapacity) { - regionalAsgs = regionalAsgs.sort { a1, a2 -> instanceSize(a1) <=> instanceSize(a2) ?: created(a2) <=> created(a1) } - }*/ + if (stageData.useSourceCapacity) { + regionalAsgs = regionalAsgs.sort(false, new CompositeComparator([new InstanceCount(), new CreatedTime()])) + } //with useSourceCapacity prefer the largest ASG over the newest ASG def latestAsg = regionalAsgs.last() return new StageData.Source( @@ -135,4 +133,36 @@ class SourceResolver { } } + static class InstanceCount implements Comparator { + @Override + int compare(ServerGroup o1, ServerGroup o2) { + def size1 = o1.instances?.size() ?: 0 + def size2 = o2.instances?.size() ?: 0 + size1 <=> size2 + } + } + + static class CreatedTime implements Comparator { + @Override + int compare(ServerGroup o1, ServerGroup o2) { + def createdTime1 = o1.createdTime ?: 0 + def createdTime2 = o2.createdTime ?: 0 + createdTime2 <=> createdTime1 + } + } + + static class CompositeComparator implements Comparator { + private final List> comparators + + CompositeComparator(List> comparators) { + this.comparators = comparators + } + + @Override + int compare(ServerGroup o1, ServerGroup o2) { + comparators.findResult { it.compare(o1, o2) ?: null } ?: 0 + } + } } + + diff --git a/orca-clouddriver/src/main/groovy/com/netflix/spinnaker/orca/kato/tasks/JarDiffsTask.groovy b/orca-clouddriver/src/main/groovy/com/netflix/spinnaker/orca/kato/tasks/JarDiffsTask.groovy index 80815766bf..99dbdd3f2e 100644 --- a/orca-clouddriver/src/main/groovy/com/netflix/spinnaker/orca/kato/tasks/JarDiffsTask.groovy +++ b/orca-clouddriver/src/main/groovy/com/netflix/spinnaker/orca/kato/tasks/JarDiffsTask.groovy @@ -137,19 +137,19 @@ class JarDiffsTask implements DiffTask { int numberOfInstancesChecked = 0; instances.find { key, instanceInfo -> if (numberOfInstancesChecked++ >= 5) { - log.info("Unable to check jar list after 5 attempts, giving up!") + JarDiffsTask.log.info("Unable to check jar list after 5 attempts, giving up!") return true } String hostName = instanceInfo.privateIpAddress ?: instanceInfo.hostName - log.debug("attempting to get a jar list from : ${key} (${hostName}:${platformPort})") + JarDiffsTask.log.debug("attempting to get a jar list from : ${key} (${hostName}:${platformPort})") def instanceService = createInstanceService("http://${hostName}:${platformPort}") try { def instanceResponse = instanceService.getJars() jarMap = objectMapper.readValue(instanceResponse.body.in().text, Map) return true } catch(Exception e) { - log.debug("could not get a jar list from : ${key} (${hostName}:${platformPort}) - ${e.message}") + JarDiffsTask.log.debug("could not get a jar list from : ${key} (${hostName}:${platformPort}) - ${e.message}") // swallow it so we can try the next instance return false } diff --git a/orca-clouddriver/src/main/groovy/com/netflix/spinnaker/orca/kato/tasks/quip/TriggerQuipTask.groovy b/orca-clouddriver/src/main/groovy/com/netflix/spinnaker/orca/kato/tasks/quip/TriggerQuipTask.groovy index 37c653daba..1f91cfaca9 100644 --- a/orca-clouddriver/src/main/groovy/com/netflix/spinnaker/orca/kato/tasks/quip/TriggerQuipTask.groovy +++ b/orca-clouddriver/src/main/groovy/com/netflix/spinnaker/orca/kato/tasks/quip/TriggerQuipTask.groovy @@ -76,7 +76,7 @@ class TriggerQuipTask extends AbstractQuipTask implements RetryableTask { taskIdMap.put(instanceHostName, ref.substring(1 + ref.lastIndexOf('/'))) patchedInstanceIds << instanceId } catch (SpinnakerServerException e) { - log.warn("Error in Quip request: {}", e.message) + TriggerQuipTask.log.warn("Error in Quip request: {}", e.message) } } } diff --git a/orca-clouddriver/src/main/groovy/com/netflix/spinnaker/orca/kato/tasks/rollingpush/DetermineTerminationCandidatesTask.groovy b/orca-clouddriver/src/main/groovy/com/netflix/spinnaker/orca/kato/tasks/rollingpush/DetermineTerminationCandidatesTask.groovy index 67f71073bf..40ee03f66f 100644 --- a/orca-clouddriver/src/main/groovy/com/netflix/spinnaker/orca/kato/tasks/rollingpush/DetermineTerminationCandidatesTask.groovy +++ b/orca-clouddriver/src/main/groovy/com/netflix/spinnaker/orca/kato/tasks/rollingpush/DetermineTerminationCandidatesTask.groovy @@ -51,7 +51,7 @@ class DetermineTerminationCandidatesTask implements Task { .orElseGet { serverGroupInstances*.instanceId } def terminationInstancePool = knownInstanceIds if (stage.context.termination?.instances) { - terminationInstancePool = knownInstanceIds.intersect(stage.context.termination?.instances) + terminationInstancePool = stage.context.termination?.instances.intersect(knownInstanceIds) if (stage.context.termination.order == 'given') { terminationInstancePool = terminationInstancePool.sort { stage.context.termination.instances.indexOf(it) } } diff --git a/orca-clouddriver/src/main/java/com/netflix/spinnaker/orca/clouddriver/pipeline/image/DeleteImageStage.java b/orca-clouddriver/src/main/java/com/netflix/spinnaker/orca/clouddriver/pipeline/image/DeleteImageStage.java index f32524b121..91ba5fbb6c 100644 --- a/orca-clouddriver/src/main/java/com/netflix/spinnaker/orca/clouddriver/pipeline/image/DeleteImageStage.java +++ b/orca-clouddriver/src/main/java/com/netflix/spinnaker/orca/clouddriver/pipeline/image/DeleteImageStage.java @@ -20,9 +20,9 @@ import com.netflix.spinnaker.orca.api.pipeline.graph.TaskNode; import com.netflix.spinnaker.orca.api.pipeline.models.StageExecution; import com.netflix.spinnaker.orca.clouddriver.tasks.image.DeleteImageTask; +import jakarta.validation.constraints.NotNull; import java.util.Set; import javax.annotation.Nonnull; -import javax.validation.constraints.NotNull; import org.springframework.stereotype.Component; @Component diff --git a/orca-clouddriver/src/main/java/com/netflix/spinnaker/orca/clouddriver/pipeline/job/UpdateJobProcessesStage.java b/orca-clouddriver/src/main/java/com/netflix/spinnaker/orca/clouddriver/pipeline/job/UpdateJobProcessesStage.java index 520bd9d303..140eddbc38 100644 --- a/orca-clouddriver/src/main/java/com/netflix/spinnaker/orca/clouddriver/pipeline/job/UpdateJobProcessesStage.java +++ b/orca-clouddriver/src/main/java/com/netflix/spinnaker/orca/clouddriver/pipeline/job/UpdateJobProcessesStage.java @@ -22,8 +22,8 @@ import com.netflix.spinnaker.orca.clouddriver.tasks.MonitorKatoTask; import com.netflix.spinnaker.orca.clouddriver.tasks.job.UpdateJobProcessesTask; import com.netflix.spinnaker.orca.clouddriver.tasks.servergroup.ServerGroupCacheForceRefreshTask; +import jakarta.validation.constraints.NotNull; import javax.annotation.Nonnull; -import javax.validation.constraints.NotNull; import org.springframework.stereotype.Component; @Component diff --git a/orca-clouddriver/src/main/java/com/netflix/spinnaker/orca/clouddriver/pipeline/launchconfigurations/DeleteLaunchConfigurationStage.java b/orca-clouddriver/src/main/java/com/netflix/spinnaker/orca/clouddriver/pipeline/launchconfigurations/DeleteLaunchConfigurationStage.java index 5bd584fcdd..e341132007 100644 --- a/orca-clouddriver/src/main/java/com/netflix/spinnaker/orca/clouddriver/pipeline/launchconfigurations/DeleteLaunchConfigurationStage.java +++ b/orca-clouddriver/src/main/java/com/netflix/spinnaker/orca/clouddriver/pipeline/launchconfigurations/DeleteLaunchConfigurationStage.java @@ -21,9 +21,9 @@ import com.netflix.spinnaker.orca.api.pipeline.models.StageExecution; import com.netflix.spinnaker.orca.clouddriver.tasks.MonitorKatoTask; import com.netflix.spinnaker.orca.clouddriver.tasks.launchconfigurations.DeleteLaunchConfigurationTask; +import jakarta.validation.constraints.NotNull; import java.util.Set; import javax.annotation.Nonnull; -import javax.validation.constraints.NotNull; import lombok.Data; import org.springframework.stereotype.Component; diff --git a/orca-clouddriver/src/main/java/com/netflix/spinnaker/orca/clouddriver/pipeline/launchtemplates/DeleteLaunchTemplateStage.java b/orca-clouddriver/src/main/java/com/netflix/spinnaker/orca/clouddriver/pipeline/launchtemplates/DeleteLaunchTemplateStage.java index f5c80ca9bf..a1e59f40ef 100644 --- a/orca-clouddriver/src/main/java/com/netflix/spinnaker/orca/clouddriver/pipeline/launchtemplates/DeleteLaunchTemplateStage.java +++ b/orca-clouddriver/src/main/java/com/netflix/spinnaker/orca/clouddriver/pipeline/launchtemplates/DeleteLaunchTemplateStage.java @@ -21,9 +21,9 @@ import com.netflix.spinnaker.orca.api.pipeline.models.StageExecution; import com.netflix.spinnaker.orca.clouddriver.tasks.MonitorKatoTask; import com.netflix.spinnaker.orca.clouddriver.tasks.launchtemplates.DeleteLaunchTemplateTask; +import jakarta.validation.constraints.NotNull; import java.util.Set; import javax.annotation.Nonnull; -import javax.validation.constraints.NotNull; import lombok.Data; import org.springframework.stereotype.Component; diff --git a/orca-clouddriver/src/main/java/com/netflix/spinnaker/orca/clouddriver/pipeline/servergroup/UpsertDisruptionBudgetStage.java b/orca-clouddriver/src/main/java/com/netflix/spinnaker/orca/clouddriver/pipeline/servergroup/UpsertDisruptionBudgetStage.java index 9cb088fb54..77bf742a39 100644 --- a/orca-clouddriver/src/main/java/com/netflix/spinnaker/orca/clouddriver/pipeline/servergroup/UpsertDisruptionBudgetStage.java +++ b/orca-clouddriver/src/main/java/com/netflix/spinnaker/orca/clouddriver/pipeline/servergroup/UpsertDisruptionBudgetStage.java @@ -22,8 +22,8 @@ import com.netflix.spinnaker.orca.clouddriver.tasks.MonitorKatoTask; import com.netflix.spinnaker.orca.clouddriver.tasks.servergroup.ServerGroupCacheForceRefreshTask; import com.netflix.spinnaker.orca.clouddriver.tasks.servergroup.UpsertDisruptionBudgetTask; +import jakarta.validation.constraints.NotNull; import javax.annotation.Nonnull; -import javax.validation.constraints.NotNull; import org.springframework.stereotype.Component; @Component diff --git a/orca-clouddriver/src/main/java/com/netflix/spinnaker/orca/clouddriver/pipeline/snapshot/DeleteSnapshotStage.java b/orca-clouddriver/src/main/java/com/netflix/spinnaker/orca/clouddriver/pipeline/snapshot/DeleteSnapshotStage.java index 72be1d1ada..bc0555aece 100644 --- a/orca-clouddriver/src/main/java/com/netflix/spinnaker/orca/clouddriver/pipeline/snapshot/DeleteSnapshotStage.java +++ b/orca-clouddriver/src/main/java/com/netflix/spinnaker/orca/clouddriver/pipeline/snapshot/DeleteSnapshotStage.java @@ -21,9 +21,9 @@ import com.netflix.spinnaker.orca.api.pipeline.models.StageExecution; import com.netflix.spinnaker.orca.clouddriver.tasks.MonitorKatoTask; import com.netflix.spinnaker.orca.clouddriver.tasks.snapshot.DeleteSnapshotTask; +import jakarta.validation.constraints.NotNull; import java.util.Set; import javax.annotation.Nonnull; -import javax.validation.constraints.NotNull; import org.springframework.stereotype.Component; @Component diff --git a/orca-clouddriver/src/main/java/com/netflix/spinnaker/orca/clouddriver/tasks/image/DeleteImageTask.java b/orca-clouddriver/src/main/java/com/netflix/spinnaker/orca/clouddriver/tasks/image/DeleteImageTask.java index 96f760463f..ded215d278 100644 --- a/orca-clouddriver/src/main/java/com/netflix/spinnaker/orca/clouddriver/tasks/image/DeleteImageTask.java +++ b/orca-clouddriver/src/main/java/com/netflix/spinnaker/orca/clouddriver/tasks/image/DeleteImageTask.java @@ -26,12 +26,12 @@ import com.netflix.spinnaker.orca.clouddriver.model.TaskId; import com.netflix.spinnaker.orca.clouddriver.pipeline.image.DeleteImageStage; import com.netflix.spinnaker.orca.clouddriver.utils.CloudProviderAware; +import jakarta.validation.ConstraintViolation; +import jakarta.validation.Validation; import java.util.*; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; import javax.annotation.Nonnull; -import javax.validation.ConstraintViolation; -import javax.validation.Validation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; diff --git a/orca-pipelinetemplate/src/test/groovy/com/netflix/spinnaker/orca/pipelinetemplate/v1schema/V1SchemaIntegrationSpec.groovy b/orca-pipelinetemplate/src/test/groovy/com/netflix/spinnaker/orca/pipelinetemplate/v1schema/V1SchemaIntegrationSpec.groovy index 84752d8bb7..619ba8ed2d 100644 --- a/orca-pipelinetemplate/src/test/groovy/com/netflix/spinnaker/orca/pipelinetemplate/v1schema/V1SchemaIntegrationSpec.groovy +++ b/orca-pipelinetemplate/src/test/groovy/com/netflix/spinnaker/orca/pipelinetemplate/v1schema/V1SchemaIntegrationSpec.groovy @@ -114,15 +114,15 @@ class V1SchemaIntegrationSpec extends Specification { test = new IntegrationTest(name: name) tests.add(test) } - + InputStream inputStream = new FileInputStream(new File(it.path)); if (it.filename.endsWith('-config.yml')) { - test.configuration = objectMapper.convertValue(yaml.load(it.file.text), TemplateConfiguration) + test.configuration = objectMapper.convertValue(yaml.load(inputStream), TemplateConfiguration) } else if (it.filename.endsWith('-expected.json')) { - test.expected = objectMapper.readValue(it.file, Map) + test.expected = objectMapper.readValue(inputStream, Map) } else if (it.filename.endsWith('-request.json')) { - test.request = objectMapper.readValue(it.file, Map) + test.request = objectMapper.readValue(inputStream, Map) } else { - test.template.add(objectMapper.convertValue(yaml.load(it.file.text), PipelineTemplate)) + test.template.add(objectMapper.convertValue(yaml.load(inputStream), PipelineTemplate)) } } diff --git a/orca-plugins-test/orca-plugins-test.gradle b/orca-plugins-test/orca-plugins-test.gradle index 4bc3f6f1d9..d11ace13f6 100644 --- a/orca-plugins-test/orca-plugins-test.gradle +++ b/orca-plugins-test/orca-plugins-test.gradle @@ -18,7 +18,9 @@ apply from: "$rootDir/gradle/kotlin.gradle" dependencies { implementation(project(":orca-api")) - + api("com.ninja-squad:springmockk:4.0.2") { + force = true + } testImplementation(project(":orca-web")) testImplementation(project(":orca-queue")) testImplementation(project(":orca-clouddriver")) diff --git a/orca-queue-sql/src/test/kotlin/com/netflix/spinnaker/orca/q/sql/SqlQueueIntegrationTest.kt b/orca-queue-sql/src/test/kotlin/com/netflix/spinnaker/orca/q/sql/SqlQueueIntegrationTest.kt index 462694dcd0..b8d2c265b2 100644 --- a/orca-queue-sql/src/test/kotlin/com/netflix/spinnaker/orca/q/sql/SqlQueueIntegrationTest.kt +++ b/orca-queue-sql/src/test/kotlin/com/netflix/spinnaker/orca/q/sql/SqlQueueIntegrationTest.kt @@ -36,6 +36,8 @@ import com.netflix.spinnaker.orca.api.pipeline.models.ExecutionType import com.netflix.spinnaker.orca.config.JedisConfiguration import com.netflix.spinnaker.orca.config.RedisConfiguration import com.netflix.spinnaker.orca.pipeline.persistence.ExecutionRepository +import com.netflix.spinnaker.orca.pipeline.tasks.DependsOnExecutionTask +import com.netflix.spinnaker.orca.pipeline.util.ArtifactUtils import com.netflix.spinnaker.orca.q.QueueIntegrationTest import com.netflix.spinnaker.orca.q.TestConfig import com.netflix.spinnaker.orca.q.migration.ExecutionTypeDeserializer @@ -166,6 +168,7 @@ class SqlTestConfig { @ExtendWith(SpringExtension::class) @SpringBootTest( classes = [ + MissingBeanConfiguration::class, SqlTestConfig::class, SqlProperties::class, TestConfig::class, @@ -189,3 +192,16 @@ class SqlTestConfig { ] ) class SqlQueueIntegrationTest : QueueIntegrationTest() + +@Configuration +internal class MissingBeanConfiguration { + @Bean + fun artifactUtils(): ArtifactUtils { + return ArtifactUtils(null,null,null) + } + + @Bean + fun dependsOnExecutionTask(): DependsOnExecutionTask { + return DependsOnExecutionTask(null) + } +} diff --git a/orca-queue/src/test/kotlin/com/netflix/spinnaker/orca/q/handler/AbortStageHandlerTest.kt b/orca-queue/src/test/kotlin/com/netflix/spinnaker/orca/q/handler/AbortStageHandlerTest.kt index ba395ccdf7..0a2e4d4f93 100644 --- a/orca-queue/src/test/kotlin/com/netflix/spinnaker/orca/q/handler/AbortStageHandlerTest.kt +++ b/orca-queue/src/test/kotlin/com/netflix/spinnaker/orca/q/handler/AbortStageHandlerTest.kt @@ -31,15 +31,8 @@ import com.netflix.spinnaker.orca.q.CompleteExecution import com.netflix.spinnaker.orca.q.CompleteStage import com.netflix.spinnaker.q.Queue import com.netflix.spinnaker.time.fixedClock -import com.nhaarman.mockito_kotlin.any -import com.nhaarman.mockito_kotlin.check -import com.nhaarman.mockito_kotlin.doReturn -import com.nhaarman.mockito_kotlin.mock -import com.nhaarman.mockito_kotlin.never -import com.nhaarman.mockito_kotlin.reset -import com.nhaarman.mockito_kotlin.verify +import com.nhaarman.mockito_kotlin.* import com.nhaarman.mockito_kotlin.verifyZeroInteractions -import com.nhaarman.mockito_kotlin.whenever import org.assertj.core.api.Assertions.assertThat import org.jetbrains.spek.api.dsl.describe import org.jetbrains.spek.api.dsl.given @@ -88,8 +81,8 @@ object AbortStageHandlerTest : SubjectSpek({ } it("does nothing at all") { - verifyZeroInteractions(queue) - verifyZeroInteractions(publisher) + verifyNoMoreInteractions(queue) + verifyNoMoreInteractions(publisher) verify(repository, never()).storeStage(any()) } } diff --git a/orca-queue/src/test/kotlin/com/netflix/spinnaker/orca/q/handler/CancelExecutionHandlerTest.kt b/orca-queue/src/test/kotlin/com/netflix/spinnaker/orca/q/handler/CancelExecutionHandlerTest.kt index 8072a137f6..a78b40424d 100644 --- a/orca-queue/src/test/kotlin/com/netflix/spinnaker/orca/q/handler/CancelExecutionHandlerTest.kt +++ b/orca-queue/src/test/kotlin/com/netflix/spinnaker/orca/q/handler/CancelExecutionHandlerTest.kt @@ -16,9 +16,7 @@ package com.netflix.spinnaker.orca.q.handler -import com.netflix.spinnaker.orca.api.pipeline.models.ExecutionStatus.CANCELED -import com.netflix.spinnaker.orca.api.pipeline.models.ExecutionStatus.PAUSED -import com.netflix.spinnaker.orca.api.pipeline.models.ExecutionStatus.RUNNING +import com.netflix.spinnaker.orca.api.pipeline.models.ExecutionStatus.* import com.netflix.spinnaker.orca.api.pipeline.models.ExecutionType.PIPELINE import com.netflix.spinnaker.orca.api.test.pipeline import com.netflix.spinnaker.orca.api.test.stage @@ -28,13 +26,7 @@ import com.netflix.spinnaker.orca.q.CancelExecution import com.netflix.spinnaker.orca.q.RescheduleExecution import com.netflix.spinnaker.orca.q.ResumeStage import com.netflix.spinnaker.q.Queue -import com.nhaarman.mockito_kotlin.check -import com.nhaarman.mockito_kotlin.doReturn -import com.nhaarman.mockito_kotlin.mock -import com.nhaarman.mockito_kotlin.reset -import com.nhaarman.mockito_kotlin.verify -import com.nhaarman.mockito_kotlin.verifyZeroInteractions -import com.nhaarman.mockito_kotlin.whenever +import com.nhaarman.mockito_kotlin.* import org.assertj.core.api.Assertions.assertThat import org.jetbrains.spek.api.dsl.describe import org.jetbrains.spek.api.dsl.given @@ -97,7 +89,7 @@ object CancelExecutionHandlerTest : SubjectSpek({ } it("does not send any further messages") { - verifyZeroInteractions(queue) + verifyNoMoreInteractions(queue) } } diff --git a/orca-queue/src/test/kotlin/com/netflix/spinnaker/orca/q/handler/CancelStageHandlerTest.kt b/orca-queue/src/test/kotlin/com/netflix/spinnaker/orca/q/handler/CancelStageHandlerTest.kt index 47f5050c54..7b042fc037 100644 --- a/orca-queue/src/test/kotlin/com/netflix/spinnaker/orca/q/handler/CancelStageHandlerTest.kt +++ b/orca-queue/src/test/kotlin/com/netflix/spinnaker/orca/q/handler/CancelStageHandlerTest.kt @@ -21,10 +21,7 @@ import com.netflix.spinnaker.orca.DefaultStageResolver import com.netflix.spinnaker.orca.TaskResolver import com.netflix.spinnaker.orca.api.pipeline.CancellableStage import com.netflix.spinnaker.orca.api.pipeline.graph.StageDefinitionBuilder -import com.netflix.spinnaker.orca.api.pipeline.models.ExecutionStatus.CANCELED -import com.netflix.spinnaker.orca.api.pipeline.models.ExecutionStatus.NOT_STARTED -import com.netflix.spinnaker.orca.api.pipeline.models.ExecutionStatus.SUCCEEDED -import com.netflix.spinnaker.orca.api.pipeline.models.ExecutionStatus.TERMINAL +import com.netflix.spinnaker.orca.api.pipeline.models.ExecutionStatus.* import com.netflix.spinnaker.orca.api.pipeline.models.ExecutionType.PIPELINE import com.netflix.spinnaker.orca.api.test.pipeline import com.netflix.spinnaker.orca.api.test.stage @@ -36,14 +33,7 @@ import com.netflix.spinnaker.orca.q.StageDefinitionBuildersProvider import com.netflix.spinnaker.orca.q.TasksProvider import com.netflix.spinnaker.orca.q.singleTaskStage import com.netflix.spinnaker.q.Queue -import com.nhaarman.mockito_kotlin.any -import com.nhaarman.mockito_kotlin.doReturn -import com.nhaarman.mockito_kotlin.mock -import com.nhaarman.mockito_kotlin.never -import com.nhaarman.mockito_kotlin.reset -import com.nhaarman.mockito_kotlin.verify -import com.nhaarman.mockito_kotlin.verifyZeroInteractions -import com.nhaarman.mockito_kotlin.whenever +import com.nhaarman.mockito_kotlin.* import org.jetbrains.spek.api.dsl.context import org.jetbrains.spek.api.dsl.describe import org.jetbrains.spek.api.dsl.it @@ -131,7 +121,7 @@ object CancelStageHandlerTest : SubjectSpek({ } it("should not push any messages to the queue") { - verifyZeroInteractions(queue) + verifyNoMoreInteractions(queue) } } } @@ -160,7 +150,7 @@ object CancelStageHandlerTest : SubjectSpek({ } it("should not push any messages to the queue") { - verifyZeroInteractions(queue) + verifyNoMoreInteractions(queue) } } } diff --git a/orca-queue/src/test/kotlin/com/netflix/spinnaker/orca/q/handler/CompleteExecutionHandlerTest.kt b/orca-queue/src/test/kotlin/com/netflix/spinnaker/orca/q/handler/CompleteExecutionHandlerTest.kt index 72360b064c..7065330ae2 100644 --- a/orca-queue/src/test/kotlin/com/netflix/spinnaker/orca/q/handler/CompleteExecutionHandlerTest.kt +++ b/orca-queue/src/test/kotlin/com/netflix/spinnaker/orca/q/handler/CompleteExecutionHandlerTest.kt @@ -17,14 +17,7 @@ package com.netflix.spinnaker.orca.q.handler import com.netflix.spectator.api.NoopRegistry -import com.netflix.spinnaker.orca.api.pipeline.models.ExecutionStatus.CANCELED -import com.netflix.spinnaker.orca.api.pipeline.models.ExecutionStatus.FAILED_CONTINUE -import com.netflix.spinnaker.orca.api.pipeline.models.ExecutionStatus.NOT_STARTED -import com.netflix.spinnaker.orca.api.pipeline.models.ExecutionStatus.RUNNING -import com.netflix.spinnaker.orca.api.pipeline.models.ExecutionStatus.SKIPPED -import com.netflix.spinnaker.orca.api.pipeline.models.ExecutionStatus.STOPPED -import com.netflix.spinnaker.orca.api.pipeline.models.ExecutionStatus.SUCCEEDED -import com.netflix.spinnaker.orca.api.pipeline.models.ExecutionStatus.TERMINAL +import com.netflix.spinnaker.orca.api.pipeline.models.ExecutionStatus.* import com.netflix.spinnaker.orca.api.pipeline.models.ExecutionType.PIPELINE import com.netflix.spinnaker.orca.api.test.pipeline import com.netflix.spinnaker.orca.api.test.stage @@ -34,20 +27,7 @@ import com.netflix.spinnaker.orca.q.CancelStage import com.netflix.spinnaker.orca.q.CompleteExecution import com.netflix.spinnaker.orca.q.StartWaitingExecutions import com.netflix.spinnaker.q.Queue -import com.nhaarman.mockito_kotlin.any -import com.nhaarman.mockito_kotlin.check -import com.nhaarman.mockito_kotlin.doReturn -import com.nhaarman.mockito_kotlin.eq -import com.nhaarman.mockito_kotlin.mock -import com.nhaarman.mockito_kotlin.never -import com.nhaarman.mockito_kotlin.reset -import com.nhaarman.mockito_kotlin.verify -import com.nhaarman.mockito_kotlin.verifyNoMoreInteractions -import com.nhaarman.mockito_kotlin.verifyZeroInteractions -import com.nhaarman.mockito_kotlin.whenever -import java.time.Duration -import java.util.UUID -import kotlin.collections.set +import com.nhaarman.mockito_kotlin.* import org.assertj.core.api.Assertions.assertThat import org.jetbrains.spek.api.dsl.describe import org.jetbrains.spek.api.dsl.it @@ -55,8 +35,9 @@ import org.jetbrains.spek.api.dsl.on import org.jetbrains.spek.api.lifecycle.CachingMode.GROUP import org.jetbrains.spek.subject.SubjectSpek import org.springframework.context.ApplicationEventPublisher -import com.nhaarman.mockito_kotlin.times -import com.nhaarman.mockito_kotlin.argumentCaptor +import java.time.Duration +import java.util.* +import kotlin.collections.set object CompleteExecutionHandlerTest : SubjectSpek({ @@ -110,7 +91,7 @@ object CompleteExecutionHandlerTest : SubjectSpek({ } it("does not queue any other commands") { - verifyZeroInteractions(queue) + verifyNoMoreInteractions(queue) } } @@ -175,7 +156,7 @@ object CompleteExecutionHandlerTest : SubjectSpek({ } it("does not publish any events") { - verifyZeroInteractions(publisher) + verifyNoMoreInteractions(publisher) } it("re-queues the message for later evaluation") { @@ -281,7 +262,7 @@ object CompleteExecutionHandlerTest : SubjectSpek({ } it("does not queue any other commands") { - verifyZeroInteractions(queue) + verifyNoMoreInteractions(queue) } } @@ -330,7 +311,7 @@ object CompleteExecutionHandlerTest : SubjectSpek({ } it("does not queue any other commands") { - verifyZeroInteractions(queue) + verifyNoMoreInteractions(queue) } } @@ -375,7 +356,7 @@ object CompleteExecutionHandlerTest : SubjectSpek({ } it("publishes no events") { - verifyZeroInteractions(publisher) + verifyNoMoreInteractions(publisher) } it("re-queues the message") { diff --git a/orca-queue/src/test/kotlin/com/netflix/spinnaker/orca/q/handler/CompleteStageHandlerTest.kt b/orca-queue/src/test/kotlin/com/netflix/spinnaker/orca/q/handler/CompleteStageHandlerTest.kt index 0e5f654e5a..8af6fb1d39 100644 --- a/orca-queue/src/test/kotlin/com/netflix/spinnaker/orca/q/handler/CompleteStageHandlerTest.kt +++ b/orca-queue/src/test/kotlin/com/netflix/spinnaker/orca/q/handler/CompleteStageHandlerTest.kt @@ -16,8 +16,8 @@ package com.netflix.spinnaker.orca.q.handler -import com.netflix.spectator.api.Id import com.netflix.spectator.api.DefaultRegistry +import com.netflix.spectator.api.Id import com.netflix.spinnaker.orca.DefaultStageResolver import com.netflix.spinnaker.orca.NoOpTaskImplementationResolver import com.netflix.spinnaker.orca.api.pipeline.SyntheticStageOwner.STAGE_AFTER @@ -25,14 +25,7 @@ import com.netflix.spinnaker.orca.api.pipeline.SyntheticStageOwner.STAGE_BEFORE import com.netflix.spinnaker.orca.api.pipeline.graph.StageDefinitionBuilder import com.netflix.spinnaker.orca.api.pipeline.graph.StageGraphBuilder import com.netflix.spinnaker.orca.api.pipeline.graph.TaskNode -import com.netflix.spinnaker.orca.api.pipeline.models.ExecutionStatus.CANCELED -import com.netflix.spinnaker.orca.api.pipeline.models.ExecutionStatus.FAILED_CONTINUE -import com.netflix.spinnaker.orca.api.pipeline.models.ExecutionStatus.NOT_STARTED -import com.netflix.spinnaker.orca.api.pipeline.models.ExecutionStatus.RUNNING -import com.netflix.spinnaker.orca.api.pipeline.models.ExecutionStatus.SKIPPED -import com.netflix.spinnaker.orca.api.pipeline.models.ExecutionStatus.STOPPED -import com.netflix.spinnaker.orca.api.pipeline.models.ExecutionStatus.SUCCEEDED -import com.netflix.spinnaker.orca.api.pipeline.models.ExecutionStatus.TERMINAL +import com.netflix.spinnaker.orca.api.pipeline.models.ExecutionStatus.* import com.netflix.spinnaker.orca.api.pipeline.models.ExecutionType.PIPELINE import com.netflix.spinnaker.orca.api.pipeline.models.StageExecution import com.netflix.spinnaker.orca.api.test.pipeline @@ -46,55 +39,20 @@ import com.netflix.spinnaker.orca.pipeline.expressions.PipelineExpressionEvaluat import com.netflix.spinnaker.orca.pipeline.persistence.ExecutionRepository import com.netflix.spinnaker.orca.pipeline.util.ContextParameterProcessor import com.netflix.spinnaker.orca.pipeline.util.StageNavigator -import com.netflix.spinnaker.orca.q.CancelStage -import com.netflix.spinnaker.orca.q.CompleteExecution -import com.netflix.spinnaker.orca.q.CompleteStage -import com.netflix.spinnaker.orca.q.ContinueParentStage -import com.netflix.spinnaker.orca.q.DummyTask -import com.netflix.spinnaker.orca.q.RunTask -import com.netflix.spinnaker.orca.q.StageDefinitionBuildersProvider -import com.netflix.spinnaker.orca.q.StartStage -import com.netflix.spinnaker.orca.q.buildAfterStages -import com.netflix.spinnaker.orca.q.buildBeforeStages -import com.netflix.spinnaker.orca.q.buildFailureStages -import com.netflix.spinnaker.orca.q.buildTasks -import com.netflix.spinnaker.orca.q.get -import com.netflix.spinnaker.orca.q.multiTaskStage -import com.netflix.spinnaker.orca.q.singleTaskStage -import com.netflix.spinnaker.orca.q.stageWithParallelBranches -import com.netflix.spinnaker.orca.q.stageWithSyntheticAfter -import com.netflix.spinnaker.orca.q.stageWithSyntheticBefore -import com.netflix.spinnaker.orca.q.stageWithSyntheticOnFailure +import com.netflix.spinnaker.orca.q.* import com.netflix.spinnaker.q.Message import com.netflix.spinnaker.q.Queue import com.netflix.spinnaker.spek.and import com.netflix.spinnaker.spek.but import com.netflix.spinnaker.time.fixedClock -import com.nhaarman.mockito_kotlin.any -import com.nhaarman.mockito_kotlin.argumentCaptor -import com.nhaarman.mockito_kotlin.atLeastOnce -import com.nhaarman.mockito_kotlin.check -import com.nhaarman.mockito_kotlin.doReturn -import com.nhaarman.mockito_kotlin.isA -import com.nhaarman.mockito_kotlin.mock -import com.nhaarman.mockito_kotlin.never -import com.nhaarman.mockito_kotlin.reset -import com.nhaarman.mockito_kotlin.spy -import com.nhaarman.mockito_kotlin.times -import com.nhaarman.mockito_kotlin.verify -import com.nhaarman.mockito_kotlin.verifyZeroInteractions -import com.nhaarman.mockito_kotlin.whenever -import java.time.Duration.ZERO +import com.nhaarman.mockito_kotlin.* import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.fail -import org.jetbrains.spek.api.dsl.context -import org.jetbrains.spek.api.dsl.describe -import org.jetbrains.spek.api.dsl.given -import org.jetbrains.spek.api.dsl.it -import org.jetbrains.spek.api.dsl.on +import org.jetbrains.spek.api.dsl.* import org.jetbrains.spek.api.lifecycle.CachingMode.GROUP import org.jetbrains.spek.subject.SubjectSpek import org.springframework.context.ApplicationEventPublisher +import java.time.Duration.ZERO object CompleteStageHandlerTest : SubjectSpek({ @@ -214,8 +172,8 @@ object CompleteStageHandlerTest : SubjectSpek({ it("ignores the message") { verify(repository, never()).storeStage(any()) - verifyZeroInteractions(queue) - verifyZeroInteractions(publisher) + verifyNoMoreInteractions(queue) + verifyNoMoreInteractions(publisher) } } diff --git a/orca-queue/src/test/kotlin/com/netflix/spinnaker/orca/q/handler/CompleteTaskHandlerTest.kt b/orca-queue/src/test/kotlin/com/netflix/spinnaker/orca/q/handler/CompleteTaskHandlerTest.kt index 612682338f..7aca658801 100644 --- a/orca-queue/src/test/kotlin/com/netflix/spinnaker/orca/q/handler/CompleteTaskHandlerTest.kt +++ b/orca-queue/src/test/kotlin/com/netflix/spinnaker/orca/q/handler/CompleteTaskHandlerTest.kt @@ -19,14 +19,7 @@ package com.netflix.spinnaker.orca.q.handler import com.netflix.spectator.api.NoopRegistry import com.netflix.spinnaker.orca.DefaultStageResolver import com.netflix.spinnaker.orca.NoOpTaskImplementationResolver -import com.netflix.spinnaker.orca.api.pipeline.models.ExecutionStatus.CANCELED -import com.netflix.spinnaker.orca.api.pipeline.models.ExecutionStatus.FAILED_CONTINUE -import com.netflix.spinnaker.orca.api.pipeline.models.ExecutionStatus.NOT_STARTED -import com.netflix.spinnaker.orca.api.pipeline.models.ExecutionStatus.REDIRECT -import com.netflix.spinnaker.orca.api.pipeline.models.ExecutionStatus.SKIPPED -import com.netflix.spinnaker.orca.api.pipeline.models.ExecutionStatus.STOPPED -import com.netflix.spinnaker.orca.api.pipeline.models.ExecutionStatus.SUCCEEDED -import com.netflix.spinnaker.orca.api.pipeline.models.ExecutionStatus.TERMINAL +import com.netflix.spinnaker.orca.api.pipeline.models.ExecutionStatus.* import com.netflix.spinnaker.orca.api.pipeline.models.ExecutionType.PIPELINE import com.netflix.spinnaker.orca.api.pipeline.models.TaskExecution import com.netflix.spinnaker.orca.api.test.pipeline @@ -36,29 +29,11 @@ import com.netflix.spinnaker.orca.pipeline.DefaultStageDefinitionBuilderFactory import com.netflix.spinnaker.orca.pipeline.model.TaskExecutionImpl import com.netflix.spinnaker.orca.pipeline.persistence.ExecutionRepository import com.netflix.spinnaker.orca.pipeline.util.ContextParameterProcessor -import com.netflix.spinnaker.orca.q.CompleteStage -import com.netflix.spinnaker.orca.q.CompleteTask -import com.netflix.spinnaker.orca.q.RunTask -import com.netflix.spinnaker.orca.q.SkipStage -import com.netflix.spinnaker.orca.q.StageDefinitionBuildersProvider -import com.netflix.spinnaker.orca.q.StartTask -import com.netflix.spinnaker.orca.q.buildTasks -import com.netflix.spinnaker.orca.q.get -import com.netflix.spinnaker.orca.q.multiTaskStage -import com.netflix.spinnaker.orca.q.rollingPushStage -import com.netflix.spinnaker.orca.q.singleTaskStage +import com.netflix.spinnaker.orca.q.* import com.netflix.spinnaker.q.Queue import com.netflix.spinnaker.spek.and import com.netflix.spinnaker.time.fixedClock -import com.nhaarman.mockito_kotlin.any -import com.nhaarman.mockito_kotlin.check -import com.nhaarman.mockito_kotlin.doReturn -import com.nhaarman.mockito_kotlin.mock -import com.nhaarman.mockito_kotlin.never -import com.nhaarman.mockito_kotlin.reset -import com.nhaarman.mockito_kotlin.verify -import com.nhaarman.mockito_kotlin.verifyZeroInteractions -import com.nhaarman.mockito_kotlin.whenever +import com.nhaarman.mockito_kotlin.* import org.assertj.core.api.Assertions.assertThat import org.jetbrains.spek.api.dsl.describe import org.jetbrains.spek.api.dsl.given @@ -251,7 +226,7 @@ object CompleteTaskHandlerTest : SubjectSpek({ } it("does not publish an event") { - verifyZeroInteractions(publisher) + verifyNoMoreInteractions(publisher) } } } diff --git a/orca-queue/src/test/kotlin/com/netflix/spinnaker/orca/q/handler/ConfigurationErrorHandlerTest.kt b/orca-queue/src/test/kotlin/com/netflix/spinnaker/orca/q/handler/ConfigurationErrorHandlerTest.kt index 40529040b9..a57fc3e760 100644 --- a/orca-queue/src/test/kotlin/com/netflix/spinnaker/orca/q/handler/ConfigurationErrorHandlerTest.kt +++ b/orca-queue/src/test/kotlin/com/netflix/spinnaker/orca/q/handler/ConfigurationErrorHandlerTest.kt @@ -19,18 +19,12 @@ package com.netflix.spinnaker.orca.q.handler import com.netflix.spinnaker.orca.api.pipeline.models.ExecutionStatus.TERMINAL import com.netflix.spinnaker.orca.api.pipeline.models.ExecutionType.PIPELINE import com.netflix.spinnaker.orca.pipeline.persistence.ExecutionRepository -import com.netflix.spinnaker.orca.q.ConfigurationError -import com.netflix.spinnaker.orca.q.InvalidExecutionId -import com.netflix.spinnaker.orca.q.InvalidStageId -import com.netflix.spinnaker.orca.q.InvalidTask -import com.netflix.spinnaker.orca.q.InvalidTaskId -import com.netflix.spinnaker.orca.q.InvalidTaskType -import com.netflix.spinnaker.orca.q.NoDownstreamTasks +import com.netflix.spinnaker.orca.q.* import com.netflix.spinnaker.q.Queue import com.nhaarman.mockito_kotlin.mock import com.nhaarman.mockito_kotlin.reset import com.nhaarman.mockito_kotlin.verify -import com.nhaarman.mockito_kotlin.verifyZeroInteractions +import com.nhaarman.mockito_kotlin.verifyNoMoreInteractions import org.jetbrains.spek.api.dsl.describe import org.jetbrains.spek.api.dsl.it import org.jetbrains.spek.api.dsl.on @@ -57,11 +51,11 @@ object ConfigurationErrorHandlerTest : SubjectSpek({ } it("does not try to update the execution status") { - verifyZeroInteractions(repository) + verifyNoMoreInteractions(repository) } it("does not push any messages to the queue") { - verifyZeroInteractions(queue) + verifyNoMoreInteractions(queue) } } } @@ -84,7 +78,7 @@ object ConfigurationErrorHandlerTest : SubjectSpek({ } it("does not push any messages to the queue") { - verifyZeroInteractions(queue) + verifyNoMoreInteractions(queue) } } } diff --git a/orca-queue/src/test/kotlin/com/netflix/spinnaker/orca/q/handler/ContinueParentStageHandlerTest.kt b/orca-queue/src/test/kotlin/com/netflix/spinnaker/orca/q/handler/ContinueParentStageHandlerTest.kt index 36d3006e1f..597f20fcb3 100644 --- a/orca-queue/src/test/kotlin/com/netflix/spinnaker/orca/q/handler/ContinueParentStageHandlerTest.kt +++ b/orca-queue/src/test/kotlin/com/netflix/spinnaker/orca/q/handler/ContinueParentStageHandlerTest.kt @@ -19,39 +19,23 @@ package com.netflix.spinnaker.orca.q.handler import com.netflix.spinnaker.orca.NoOpTaskImplementationResolver import com.netflix.spinnaker.orca.api.pipeline.SyntheticStageOwner.STAGE_AFTER import com.netflix.spinnaker.orca.api.pipeline.SyntheticStageOwner.STAGE_BEFORE -import com.netflix.spinnaker.orca.api.pipeline.models.ExecutionStatus.FAILED_CONTINUE -import com.netflix.spinnaker.orca.api.pipeline.models.ExecutionStatus.RUNNING -import com.netflix.spinnaker.orca.api.pipeline.models.ExecutionStatus.SUCCEEDED -import com.netflix.spinnaker.orca.api.pipeline.models.ExecutionStatus.TERMINAL +import com.netflix.spinnaker.orca.api.pipeline.models.ExecutionStatus.* import com.netflix.spinnaker.orca.api.pipeline.models.ExecutionType.PIPELINE import com.netflix.spinnaker.orca.api.test.pipeline import com.netflix.spinnaker.orca.api.test.stage import com.netflix.spinnaker.orca.ext.beforeStages import com.netflix.spinnaker.orca.pipeline.persistence.ExecutionRepository -import com.netflix.spinnaker.orca.q.CompleteStage -import com.netflix.spinnaker.orca.q.ContinueParentStage -import com.netflix.spinnaker.orca.q.StartTask -import com.netflix.spinnaker.orca.q.buildAfterStages -import com.netflix.spinnaker.orca.q.buildBeforeStages -import com.netflix.spinnaker.orca.q.buildTasks -import com.netflix.spinnaker.orca.q.stageWithParallelAfter -import com.netflix.spinnaker.orca.q.stageWithSyntheticBefore -import com.netflix.spinnaker.orca.q.stageWithSyntheticBeforeAndNoTasks +import com.netflix.spinnaker.orca.q.* import com.netflix.spinnaker.q.Queue import com.netflix.spinnaker.spek.and -import com.nhaarman.mockito_kotlin.doReturn -import com.nhaarman.mockito_kotlin.mock -import com.nhaarman.mockito_kotlin.reset -import com.nhaarman.mockito_kotlin.verify -import com.nhaarman.mockito_kotlin.verifyZeroInteractions -import com.nhaarman.mockito_kotlin.whenever -import java.time.Duration +import com.nhaarman.mockito_kotlin.* import org.jetbrains.spek.api.dsl.describe import org.jetbrains.spek.api.dsl.given import org.jetbrains.spek.api.dsl.it import org.jetbrains.spek.api.dsl.on import org.jetbrains.spek.api.lifecycle.CachingMode import org.jetbrains.spek.subject.SubjectSpek +import java.time.Duration object ContinueParentStageHandlerTest : SubjectSpek({ @@ -121,7 +105,7 @@ object ContinueParentStageHandlerTest : SubjectSpek( } it("does not re-queue the message") { - verifyZeroInteractions(queue) + verifyNoMoreInteractions(queue) } } @@ -170,7 +154,7 @@ object ContinueParentStageHandlerTest : SubjectSpek( } it("ignores the message") { - verifyZeroInteractions(queue) + verifyNoMoreInteractions(queue) } } } diff --git a/orca-queue/src/test/kotlin/com/netflix/spinnaker/orca/q/handler/DeadMessageHandlerTest.kt b/orca-queue/src/test/kotlin/com/netflix/spinnaker/orca/q/handler/DeadMessageHandlerTest.kt index c3faa28a90..e2667b82ba 100644 --- a/orca-queue/src/test/kotlin/com/netflix/spinnaker/orca/q/handler/DeadMessageHandlerTest.kt +++ b/orca-queue/src/test/kotlin/com/netflix/spinnaker/orca/q/handler/DeadMessageHandlerTest.kt @@ -18,18 +18,12 @@ package com.netflix.spinnaker.orca.q.handler import com.netflix.spinnaker.orca.api.pipeline.models.ExecutionStatus.TERMINAL import com.netflix.spinnaker.orca.api.pipeline.models.ExecutionType.PIPELINE -import com.netflix.spinnaker.orca.q.AbortStage -import com.netflix.spinnaker.orca.q.CompleteExecution -import com.netflix.spinnaker.orca.q.CompleteTask -import com.netflix.spinnaker.orca.q.DummyTask -import com.netflix.spinnaker.orca.q.RunTask -import com.netflix.spinnaker.orca.q.StartExecution -import com.netflix.spinnaker.orca.q.StartStage +import com.netflix.spinnaker.orca.q.* import com.netflix.spinnaker.q.Queue import com.nhaarman.mockito_kotlin.mock import com.nhaarman.mockito_kotlin.reset import com.nhaarman.mockito_kotlin.verify -import com.nhaarman.mockito_kotlin.verifyZeroInteractions +import com.nhaarman.mockito_kotlin.verifyNoMoreInteractions import org.jetbrains.spek.api.dsl.describe import org.jetbrains.spek.api.dsl.it import org.jetbrains.spek.api.dsl.on @@ -100,7 +94,7 @@ object DeadMessageHandlerTest : SubjectSpek({ } it("does nothing") { - verifyZeroInteractions(queue) + verifyNoMoreInteractions(queue) } } }) diff --git a/orca-queue/src/test/kotlin/com/netflix/spinnaker/orca/q/handler/PauseStageHandlerTest.kt b/orca-queue/src/test/kotlin/com/netflix/spinnaker/orca/q/handler/PauseStageHandlerTest.kt index c1ba2db49d..a4fdb2d109 100644 --- a/orca-queue/src/test/kotlin/com/netflix/spinnaker/orca/q/handler/PauseStageHandlerTest.kt +++ b/orca-queue/src/test/kotlin/com/netflix/spinnaker/orca/q/handler/PauseStageHandlerTest.kt @@ -26,14 +26,7 @@ import com.netflix.spinnaker.orca.q.buildBeforeStages import com.netflix.spinnaker.orca.q.singleTaskStage import com.netflix.spinnaker.orca.q.stageWithSyntheticBefore import com.netflix.spinnaker.q.Queue -import com.nhaarman.mockito_kotlin.check -import com.nhaarman.mockito_kotlin.doReturn -import com.nhaarman.mockito_kotlin.mock -import com.nhaarman.mockito_kotlin.reset -import com.nhaarman.mockito_kotlin.verify -import com.nhaarman.mockito_kotlin.verifyNoMoreInteractions -import com.nhaarman.mockito_kotlin.verifyZeroInteractions -import com.nhaarman.mockito_kotlin.whenever +import com.nhaarman.mockito_kotlin.* import org.assertj.core.api.Assertions.assertThat import org.jetbrains.spek.api.dsl.context import org.jetbrains.spek.api.dsl.describe @@ -87,7 +80,7 @@ object PauseStageHandlerTest : SubjectSpek({ } it("does not take any further action") { - verifyZeroInteractions(queue) + verifyNoMoreInteractions(queue) } } diff --git a/orca-queue/src/test/kotlin/com/netflix/spinnaker/orca/q/handler/SkipStageHandlerTest.kt b/orca-queue/src/test/kotlin/com/netflix/spinnaker/orca/q/handler/SkipStageHandlerTest.kt index a6ed879694..9d8ba338f8 100644 --- a/orca-queue/src/test/kotlin/com/netflix/spinnaker/orca/q/handler/SkipStageHandlerTest.kt +++ b/orca-queue/src/test/kotlin/com/netflix/spinnaker/orca/q/handler/SkipStageHandlerTest.kt @@ -16,34 +16,16 @@ package com.netflix.spinnaker.orca.q.handler -import com.netflix.spinnaker.orca.api.pipeline.models.ExecutionStatus.FAILED_CONTINUE -import com.netflix.spinnaker.orca.api.pipeline.models.ExecutionStatus.RUNNING -import com.netflix.spinnaker.orca.api.pipeline.models.ExecutionStatus.SKIPPED -import com.netflix.spinnaker.orca.api.pipeline.models.ExecutionStatus.SUCCEEDED -import com.netflix.spinnaker.orca.api.pipeline.models.ExecutionStatus.TERMINAL +import com.netflix.spinnaker.orca.api.pipeline.models.ExecutionStatus.* import com.netflix.spinnaker.orca.api.pipeline.models.ExecutionType.PIPELINE import com.netflix.spinnaker.orca.api.test.pipeline import com.netflix.spinnaker.orca.api.test.stage import com.netflix.spinnaker.orca.events.StageComplete import com.netflix.spinnaker.orca.pipeline.persistence.ExecutionRepository -import com.netflix.spinnaker.orca.q.CompleteExecution -import com.netflix.spinnaker.orca.q.RunTask -import com.netflix.spinnaker.orca.q.SkipStage -import com.netflix.spinnaker.orca.q.StartStage -import com.netflix.spinnaker.orca.q.get +import com.netflix.spinnaker.orca.q.* import com.netflix.spinnaker.q.Queue import com.netflix.spinnaker.time.fixedClock -import com.nhaarman.mockito_kotlin.any -import com.nhaarman.mockito_kotlin.argumentCaptor -import com.nhaarman.mockito_kotlin.check -import com.nhaarman.mockito_kotlin.doReturn -import com.nhaarman.mockito_kotlin.mock -import com.nhaarman.mockito_kotlin.never -import com.nhaarman.mockito_kotlin.reset -import com.nhaarman.mockito_kotlin.times -import com.nhaarman.mockito_kotlin.verify -import com.nhaarman.mockito_kotlin.verifyZeroInteractions -import com.nhaarman.mockito_kotlin.whenever +import com.nhaarman.mockito_kotlin.* import org.assertj.core.api.Assertions.assertThat import org.jetbrains.spek.api.dsl.describe import org.jetbrains.spek.api.dsl.given @@ -91,8 +73,8 @@ object SkipStageHandlerTest : SubjectSpek({ it("ignores the message") { verify(repository, never()).storeStage(any()) - verifyZeroInteractions(queue) - verifyZeroInteractions(publisher) + verifyNoMoreInteractions(queue) + verifyNoMoreInteractions(publisher) } } diff --git a/orca-queue/src/test/kotlin/com/netflix/spinnaker/orca/q/handler/StartStageHandlerTest.kt b/orca-queue/src/test/kotlin/com/netflix/spinnaker/orca/q/handler/StartStageHandlerTest.kt index ccf7b8615d..c0b99ef1be 100644 --- a/orca-queue/src/test/kotlin/com/netflix/spinnaker/orca/q/handler/StartStageHandlerTest.kt +++ b/orca-queue/src/test/kotlin/com/netflix/spinnaker/orca/q/handler/StartStageHandlerTest.kt @@ -23,10 +23,7 @@ import com.netflix.spinnaker.assertj.assertSoftly import com.netflix.spinnaker.orca.DefaultStageResolver import com.netflix.spinnaker.orca.NoOpTaskImplementationResolver import com.netflix.spinnaker.orca.api.pipeline.SyntheticStageOwner.STAGE_BEFORE -import com.netflix.spinnaker.orca.api.pipeline.models.ExecutionStatus.FAILED_CONTINUE -import com.netflix.spinnaker.orca.api.pipeline.models.ExecutionStatus.RUNNING -import com.netflix.spinnaker.orca.api.pipeline.models.ExecutionStatus.SUCCEEDED -import com.netflix.spinnaker.orca.api.pipeline.models.ExecutionStatus.TERMINAL +import com.netflix.spinnaker.orca.api.pipeline.models.ExecutionStatus.* import com.netflix.spinnaker.orca.api.pipeline.models.ExecutionType.PIPELINE import com.netflix.spinnaker.orca.api.pipeline.models.StageExecution import com.netflix.spinnaker.orca.api.pipeline.models.TaskExecution @@ -40,58 +37,17 @@ import com.netflix.spinnaker.orca.pipeline.persistence.ExecutionNotFoundExceptio import com.netflix.spinnaker.orca.pipeline.persistence.ExecutionRepository import com.netflix.spinnaker.orca.pipeline.util.ContextParameterProcessor import com.netflix.spinnaker.orca.pipeline.util.StageNavigator -import com.netflix.spinnaker.orca.q.CompleteExecution -import com.netflix.spinnaker.orca.q.CompleteStage -import com.netflix.spinnaker.orca.q.DummyTask -import com.netflix.spinnaker.orca.q.InvalidExecutionId -import com.netflix.spinnaker.orca.q.InvalidStageId -import com.netflix.spinnaker.orca.q.SkipStage -import com.netflix.spinnaker.orca.q.StageDefinitionBuildersProvider -import com.netflix.spinnaker.orca.q.StartStage -import com.netflix.spinnaker.orca.q.StartTask -import com.netflix.spinnaker.orca.q.buildBeforeStages -import com.netflix.spinnaker.orca.q.buildTasks -import com.netflix.spinnaker.orca.q.failPlanningStage -import com.netflix.spinnaker.orca.q.get -import com.netflix.spinnaker.orca.q.multiTaskStage -import com.netflix.spinnaker.orca.q.rollingPushStage -import com.netflix.spinnaker.orca.q.singleTaskStage -import com.netflix.spinnaker.orca.q.stageWithParallelBranches -import com.netflix.spinnaker.orca.q.stageWithSyntheticAfter -import com.netflix.spinnaker.orca.q.stageWithSyntheticAfterAndNoTasks -import com.netflix.spinnaker.orca.q.stageWithSyntheticBefore -import com.netflix.spinnaker.orca.q.webhookStage -import com.netflix.spinnaker.orca.q.zeroTaskStage +import com.netflix.spinnaker.orca.q.* import com.netflix.spinnaker.q.Queue import com.netflix.spinnaker.spek.and import com.netflix.spinnaker.time.fixedClock -import com.nhaarman.mockito_kotlin.any -import com.nhaarman.mockito_kotlin.anyOrNull -import com.nhaarman.mockito_kotlin.atLeastOnce -import com.nhaarman.mockito_kotlin.argumentCaptor -import com.nhaarman.mockito_kotlin.check -import com.nhaarman.mockito_kotlin.doReturn -import com.nhaarman.mockito_kotlin.doThrow -import com.nhaarman.mockito_kotlin.isA -import com.nhaarman.mockito_kotlin.mock -import com.nhaarman.mockito_kotlin.never -import com.nhaarman.mockito_kotlin.reset -import com.nhaarman.mockito_kotlin.times -import com.nhaarman.mockito_kotlin.spy -import com.nhaarman.mockito_kotlin.verify -import com.nhaarman.mockito_kotlin.verifyNoMoreInteractions -import com.nhaarman.mockito_kotlin.verifyZeroInteractions -import com.nhaarman.mockito_kotlin.whenever -import java.time.Duration +import com.nhaarman.mockito_kotlin.* import org.assertj.core.api.Assertions.assertThat -import org.jetbrains.spek.api.dsl.context -import org.jetbrains.spek.api.dsl.describe -import org.jetbrains.spek.api.dsl.given -import org.jetbrains.spek.api.dsl.it -import org.jetbrains.spek.api.dsl.on +import org.jetbrains.spek.api.dsl.* import org.jetbrains.spek.api.lifecycle.CachingMode.GROUP import org.jetbrains.spek.subject.SubjectSpek import org.springframework.context.ApplicationEventPublisher +import java.time.Duration object StartStageHandlerTest : SubjectSpek({ @@ -473,7 +429,7 @@ object StartStageHandlerTest : SubjectSpek({ } it("does not publish an event") { - verifyZeroInteractions(publisher) + verifyNoMoreInteractions(publisher) } it("re-queues the message with a delay") { @@ -517,7 +473,7 @@ object StartStageHandlerTest : SubjectSpek({ } it("publishes no events") { - verifyZeroInteractions(publisher) + verifyNoMoreInteractions(publisher) } it("completes the execution") { @@ -541,11 +497,11 @@ object StartStageHandlerTest : SubjectSpek({ } it("does not queue any messages") { - verifyZeroInteractions(queue) + verifyNoMoreInteractions(queue) } it("does not publish any events") { - verifyZeroInteractions(publisher) + verifyNoMoreInteractions(publisher) } } } @@ -631,7 +587,7 @@ object StartStageHandlerTest : SubjectSpek({ } } } - + and("parallel stages") { val pipeline = pipeline { application = "foo" diff --git a/orca-queue/src/test/kotlin/com/netflix/spinnaker/orca/q/handler/StartWaitingExecutionsHandlerTest.kt b/orca-queue/src/test/kotlin/com/netflix/spinnaker/orca/q/handler/StartWaitingExecutionsHandlerTest.kt index 0711024bf6..f49161044b 100644 --- a/orca-queue/src/test/kotlin/com/netflix/spinnaker/orca/q/handler/StartWaitingExecutionsHandlerTest.kt +++ b/orca-queue/src/test/kotlin/com/netflix/spinnaker/orca/q/handler/StartWaitingExecutionsHandlerTest.kt @@ -24,28 +24,16 @@ import com.netflix.spinnaker.orca.q.StartWaitingExecutions import com.netflix.spinnaker.orca.q.pending.PendingExecutionService import com.netflix.spinnaker.q.Message import com.netflix.spinnaker.q.Queue -import com.nhaarman.mockito_kotlin.argumentCaptor -import com.nhaarman.mockito_kotlin.doReturn -import com.nhaarman.mockito_kotlin.eq -import com.nhaarman.mockito_kotlin.isA -import com.nhaarman.mockito_kotlin.mock -import com.nhaarman.mockito_kotlin.never -import com.nhaarman.mockito_kotlin.reset -import com.nhaarman.mockito_kotlin.times -import com.nhaarman.mockito_kotlin.verify -import com.nhaarman.mockito_kotlin.verifyNoMoreInteractions -import com.nhaarman.mockito_kotlin.verifyZeroInteractions -import com.nhaarman.mockito_kotlin.whenever -import java.time.Instant.now -import java.util.Random -import java.util.UUID -import kotlin.math.absoluteValue +import com.nhaarman.mockito_kotlin.* import org.jetbrains.spek.api.dsl.describe import org.jetbrains.spek.api.dsl.given import org.jetbrains.spek.api.dsl.it import org.jetbrains.spek.api.dsl.on import org.jetbrains.spek.api.lifecycle.CachingMode.GROUP import org.jetbrains.spek.subject.SubjectSpek +import java.time.Instant.now +import java.util.* +import kotlin.math.absoluteValue object StartWaitingExecutionsHandlerTest : SubjectSpek({ @@ -76,7 +64,7 @@ object StartWaitingExecutionsHandlerTest : SubjectSpek