Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OP-22192 Fixed 100+ test cases during upgrade of orca from 1.30.1 to … #46

Merged
merged 1 commit into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion orca-api-tck/orca-api-tck.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we pick v4.0.0 from kork.
if not, any specific reason to use 4.0.2 ?

Copy link
Collaborator Author

@sanopsmx sanopsmx Jun 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aman-agrawal @j-sandy No specific reason to use 4.0.2. We can use 4.0.0 also.

i had to force this dependency , otherwise this dependency version is set to 2.0.3 and the test case fails.

force = true
}

testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine")
}
Expand Down
6 changes: 4 additions & 2 deletions orca-clouddriver/orca-clouddriver.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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") {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we pick v1.13.4 from kork.
if not, any specific reason to use 1.13.7 ?

Copy link
Collaborator Author

@sanopsmx sanopsmx Jun 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aman-agrawal @j-sandy No specific reason to use 1.13.7. We can use 1.13.4 also.

i had to force this dependency , otherwise this dependency version is set to 1.10.5 and the test case fails.

force true
}
testImplementation("ru.lanwen.wiremock:wiremock-junit5:1.3.1")

testCompileOnly("org.projectlombok:lombok")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks simpler & easy to read, why replacing it with your custom logic ?

Copy link
Collaborator Author

@sanopsmx sanopsmx Jun 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aman-agrawal @j-sandy Good question. OSS groovy version : 3.0.17..Our version : 4.0.13
Comparator logic changed significantly. if you can observe when we upgraded , one of our developers commented out the code. Fortunately no bug raised..... 😄

After the upgrade we have to write our own comparator logic. Hence the logic was added. This test case checks this logic. you should try out this.

}*/
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(
Expand All @@ -135,4 +133,36 @@ class SourceResolver {
}
}

static class InstanceCount implements Comparator<ServerGroup> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how we hav verified that this sorting logic is working fine ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aman-agrawal @j-sandy Good question. OSS groovy version : 3.0.17..Our version : 4.0.13
Comparator logic changed significantly. if you can observe when we upgraded , one of our developers commented out the code. Fortunately no bug raised..... 😄

After the upgrade we have to write our own comparator logic. Hence the logic was added. This test case checks this logic. you should try out this.

@Override
int compare(ServerGroup o1, ServerGroup o2) {
def size1 = o1.instances?.size() ?: 0
def size2 = o2.instances?.size() ?: 0
size1 <=> size2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we ensure o1 and o2 are checked for null values, like : o1?.instances?.size() ?: 0
Applicable elsewhere.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aman-agrawal @j-sandy Not needed. Code written in accordance to previous versions. Also, i guess, server groups are checked for null before.

}
}

static class CreatedTime implements Comparator<ServerGroup> {
@Override
int compare(ServerGroup o1, ServerGroup o2) {
def createdTime1 = o1.createdTime ?: 0
def createdTime2 = o2.createdTime ?: 0
createdTime2 <=> createdTime1
}
}

static class CompositeComparator implements Comparator<ServerGroup> {
private final List<Comparator<ServerGroup>> comparators

CompositeComparator(List<Comparator<ServerGroup>> comparators) {
this.comparators = comparators
}

@Override
int compare(ServerGroup o1, ServerGroup o2) {
comparators.findResult { it.compare(o1, o2) ?: null } ?: 0
}
}
}


Original file line number Diff line number Diff line change
Expand Up @@ -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!")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious : what is JarDiffsTask class doing & why this code change ?

Copy link
Collaborator Author

@sanopsmx sanopsmx Jun 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aman-agrawal @j-sandy It is not able to find the log method when running the closure methods. We are getting this exception.
When added the classname to the log object,all the test cases are passing.

JarDiffsTaskSpec > getJarList single server FAILED
groovy.lang.MissingMethodException: No signature of method: com.netflix.spinnaker.orca.kato.tasks.JarDiffsTask.getLog() is applicable for argument types: () values: []
Possible solutions: getAt(java.lang.String), getClass(), notify(), $getLookup(), every(), grep()
at com.netflix.spinnaker.orca.kato.tasks.JarDiffsTask.getJarList_closure2(JarDiffsTask.groovy:145)
at app//com.netflix.spinnaker.orca.kato.tasks.JarDiffsTask.getJarList(JarDiffsTask.groovy:138)
at app//org.spockframework.mock.runtime.ByteBuddyMethodInvoker.respond(ByteBuddyMethodInvoker.java:20)
at app//org.spockframework.mock.runtime.MockInvocation.callRealMethod(MockInvocation.java:61)
at app//org.spockframework.mock.CallRealMethodResponse.respond(CallRealMethodResponse.java:30)
at app//org.spockframework.mock.runtime.MockController.handle(MockController.java:52)
at app//org.spockframework.mock.runtime.JavaMockInterceptor.intercept(JavaMockInterceptor.java:84)
at app//org.spockframework.mock.runtime.ByteBuddyInterceptorAdapter.interceptNonAbstract(ByteBuddyInterceptorAdapter.java:35)
at com.netflix.spinnaker.orca.kato.tasks.JarDiffsTaskSpec.getJarList single server(JarDiffsTaskSpec.groovy:87)

JarDiffsTaskSpec > getJarList first server fails, second succeeds FAILED
groovy.lang.MissingMethodException: No signature of method: com.netflix.spinnaker.orca.kato.tasks.JarDiffsTask.getLog() is applicable for argument types: () values: []
Possible solutions: getAt(java.lang.String), getClass(), notify(), $getLookup(), every(), grep()
at com.netflix.spinnaker.orca.kato.tasks.JarDiffsTask.getJarList_closure2(JarDiffsTask.groovy:145)
at app//com.netflix.spinnaker.orca.kato.tasks.JarDiffsTask.getJarList(JarDiffsTask.groovy:138)
at app//org.spockframework.mock.runtime.ByteBuddyMethodInvoker.respond(ByteBuddyMethodInvoker.java:20)
at app//org.spockframework.mock.runtime.MockInvocation.callRealMethod(MockInvocation.java:61)
at app//org.spockframework.mock.CallRealMethodResponse.respond(CallRealMethodResponse.java:30)
at app//org.spockframework.mock.runtime.MockController.handle(MockController.java:52)
at app//org.spockframework.mock.runtime.JavaMockInterceptor.intercept(JavaMockInterceptor.java:84)
at app//org.spockframework.mock.runtime.ByteBuddyInterceptorAdapter.interceptNonAbstract(ByteBuddyInterceptorAdapter.java:35)
at com.netflix.spinnaker.orca.kato.tasks.JarDiffsTaskSpec.getJarList first server fails, second succeeds(JarDiffsTaskSpec.groovy:109)

JarDiffsTaskSpec > getJarList will short circuit after 5 attempts FAILED
groovy.lang.MissingMethodException: No signature of method: com.netflix.spinnaker.orca.kato.tasks.JarDiffsTask.getLog() is applicable for argument types: () values: []
Possible solutions: getAt(java.lang.String), getClass(), notify(), $getLookup(), every(), grep()
at com.netflix.spinnaker.orca.kato.tasks.JarDiffsTask.getJarList_closure2(JarDiffsTask.groovy:145)
at app//com.netflix.spinnaker.orca.kato.tasks.JarDiffsTask.getJarList(JarDiffsTask.groovy:138)
at app//org.spockframework.mock.runtime.ByteBuddyMethodInvoker.respond(ByteBuddyMethodInvoker.java:20)
at app//org.spockframework.mock.runtime.MockInvocation.callRealMethod(MockInvocation.java:61)
at app//org.spockframework.mock.CallRealMethodResponse.respond(CallRealMethodResponse.java:30)
at app//org.spockframework.mock.runtime.MockController.handle(MockController.java:52)
at app//org.spockframework.mock.runtime.JavaMockInterceptor.intercept(JavaMockInterceptor.java:84)
at app//org.spockframework.mock.runtime.ByteBuddyInterceptorAdapter.interceptNonAbstract(ByteBuddyInterceptorAdapter.java:35)
at com.netflix.spinnaker.orca.kato.tasks.JarDiffsTaskSpec.getJarList will short circuit after 5 attempts(JarDiffsTaskSpec.groovy:126)

JarDiffsTaskSpec > getJarList stops when finds a jar list FAILED
groovy.lang.MissingMethodException: No signature of method: com.netflix.spinnaker.orca.kato.tasks.JarDiffsTask.getLog() is applicable for argument types: () values: []
Possible solutions: getAt(java.lang.String), getClass(), notify(), $getLookup(), every(), grep()
at com.netflix.spinnaker.orca.kato.tasks.JarDiffsTask.getJarList_closure2(JarDiffsTask.groovy:145)
at app//com.netflix.spinnaker.orca.kato.tasks.JarDiffsTask.getJarList(JarDiffsTask.groovy:138)
at app//org.spockframework.mock.runtime.ByteBuddyMethodInvoker.respond(ByteBuddyMethodInvoker.java:20)
at app//org.spockframework.mock.runtime.MockInvocation.callRealMethod(MockInvocation.java:61)
at app//org.spockframework.mock.CallRealMethodResponse.respond(CallRealMethodResponse.java:30)
at app//org.spockframework.mock.runtime.MockController.handle(MockController.java:52)
at app//org.spockframework.mock.runtime.JavaMockInterceptor.intercept(JavaMockInterceptor.java:84)
at app//org.spockframework.mock.runtime.ByteBuddyInterceptorAdapter.interceptNonAbstract(ByteBuddyInterceptorAdapter.java:35)
at com.netflix.spinnaker.orca.kato.tasks.JarDiffsTaskSpec.getJarList stops when finds a jar list(JarDiffsTaskSpec.groovy:144)

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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can u pls explain this change.
why we are making this ?

Copy link
Collaborator Author

@sanopsmx sanopsmx Jun 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aman-agrawal @j-sandy Good question. OSS groovy version : 3.0.17..Our version : 4.0.13
intersect method functionality changed. We can create a sample project and analyse for yourselves.

if (stage.context.termination.order == 'given') {
terminationInstancePool = terminationInstancePool.sort { stage.context.termination.instances.indexOf(it) }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we are replacing it.file & it.file.text with inputStream, why ?
can you pls explain this change.

Copy link
Collaborator Author

@sanopsmx sanopsmx Jun 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aman-agrawal @j-sandy Good question. snakeyaml version : 1.27..Our version : 2.0
load method functionality changed. We can create a sample project and analyse for yourselves.

}
}

Expand Down
4 changes: 3 additions & 1 deletion orca-plugins-test/orca-plugins-test.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ apply from: "$rootDir/gradle/kotlin.gradle"

dependencies {
implementation(project(":orca-api"))

api("com.ninja-squad:springmockk:4.0.2") {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we pick v4.0.0 from kork ?
if not, any specific reason for this version ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aman-agrawal @j-sandy No specific reason to use 4.0.2. We can use 4.0.0 also.

i had to force this dependency , otherwise this dependency version is set to 2.0.3 and the test case fails.

Task :orca-plugins-test:test

OrcaPluginsTest > minutests() > an orca integration test environment and an orca plugin > an integration test environment and relevant plugins > com.netflix.spinnaker.orca.plugins.test.OrcaPluginsTest.minutests()[1][1][1] FAILED
java.lang.NoClassDefFoundError: org/springframework/beans/factory/config/InstantiationAwareBeanPostProcessorAdapter
at java.base/java.lang.ClassLoader.defineClass1(Native Method)
at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1017)
at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150)
at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:862)
at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:760)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:681)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:639)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:525)
at com.ninjasquad.springmockk.MockkContextCustomizer.customizeContext(MockkContextCustomizer.kt:21)
at org.springframework.boot.test.context.SpringBootContextLoader$ContextCustomizerAdapter.initialize(SpringBootContextLoader.java:435)
at org.springframework.boot.SpringApplication.applyInitializers(SpringApplication.java:605)
at org.springframework.boot.SpringApplication.prepareContext(SpringApplication.java:385)
at org.springframework.boot.SpringApplication.run(SpringAppli

force = true
}
testImplementation(project(":orca-web"))
testImplementation(project(":orca-queue"))
testImplementation(project(":orca-clouddriver"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -166,6 +168,7 @@ class SqlTestConfig {
@ExtendWith(SpringExtension::class)
@SpringBootTest(
classes = [
MissingBeanConfiguration::class,
SqlTestConfig::class,
SqlProperties::class,
TestConfig::class,
Expand All @@ -189,3 +192,16 @@ class SqlTestConfig {
]
)
class SqlQueueIntegrationTest : QueueIntegrationTest()

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious : why we have done this change ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aman-agrawal @j-sandy ..Because of the kotlin upgrade, the test container does not get started. reason being missing beans(artifactUtils, dependsOnExecutionTask)...and we have to provide just at the start of the test case.

Hence, the change

@Configuration
internal class MissingBeanConfiguration {
@Bean
fun artifactUtils(): ArtifactUtils {
return ArtifactUtils(null,null,null)
}

@Bean
fun dependsOnExecutionTask(): DependsOnExecutionTask {
return DependsOnExecutionTask(null)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -88,8 +81,8 @@ object AbortStageHandlerTest : SubjectSpek<AbortStageHandler>({
}

it("does nothing at all") {
verifyZeroInteractions(queue)
verifyZeroInteractions(publisher)
verifyNoMoreInteractions(queue)
Copy link
Collaborator

@aman-agrawal aman-agrawal Jun 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we replace verifyZeroInteractions by verifyNoMoreInteractions?
Applicable elsewhere.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aman-agrawal Already replaced in this file. Did not understand ur comment.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why we replaced verifyZeroInteractions by verifyNoMoreInteractions ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now the question is pertinent enough.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VerifyZeroInteractions was deprecated and verifyNoMoreInteractions has the same behaviour.

mockito/mockito-kotlin#383

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can u pls verify, It is verifyNoInteractions or verifyNoMoreInteractions ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aman-agrawal @j-sandy

This is where i respectfully differ. You should do your homework....I am explaining it for now...next time cannot expect the same from me....Both are same. Little lazy with my writing skills... 🤣

Now what do you think? Should i be using verifyNoMoreInteractions or verifyNoInteractions?

image

image

verifyNoMoreInteractions(publisher)
verify(repository, never()).storeStage(any())
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -97,7 +89,7 @@ object CancelExecutionHandlerTest : SubjectSpek<CancelExecutionHandler>({
}

it("does not send any further messages") {
verifyZeroInteractions(queue)
verifyNoMoreInteractions(queue)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.*
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pls import specific classes. Applicable elsewhere.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah will do it.

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
Expand All @@ -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
Expand Down Expand Up @@ -131,7 +121,7 @@ object CancelStageHandlerTest : SubjectSpek<CancelStageHandler>({
}

it("should not push any messages to the queue") {
verifyZeroInteractions(queue)
verifyNoMoreInteractions(queue)
}
}
}
Expand Down Expand Up @@ -160,7 +150,7 @@ object CancelStageHandlerTest : SubjectSpek<CancelStageHandler>({
}

it("should not push any messages to the queue") {
verifyZeroInteractions(queue)
verifyNoMoreInteractions(queue)
}
}
}
Expand Down
Loading
Loading