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

refactor(core/test): fix cardinality issue by replacing Stub to Mock during upgrade to groovy 3.x #4544

Merged
merged 2 commits into from
Sep 27, 2023

Conversation

j-sandy
Copy link
Contributor

@j-sandy j-sandy commented Sep 27, 2023

While upgrading groovy 3.0.10 and spockframework 2.0-groovy-3.0, encountered the following errors in groovy test orca-core module:

Stub 'executionRepository' matches the following required interaction:

0 * _   (0 invocations)

Remove the cardinality (e.g. '1 *'), or turn the stub into a mock.

org.spockframework.runtime.InvalidSpecException: Stub 'executionRepository' matches the following required interaction:

0 * _   (0 invocations)

Remove the cardinality (e.g. '1 *'), or turn the stub into a mock.

	at app//org.spockframework.mock.constraint.TargetConstraint.setInteraction(TargetConstraint.java:57)
	at app//org.spockframework.mock.runtime.MockInteraction.<init>(MockInteraction.java:53)
	at app//org.spockframework.mock.runtime.InteractionBuilder.build(InteractionBuilder.java:187)
	at com.netflix.spinnaker.orca.pipeline.util.ArtifactUtilsSpec.$spock_initializeFields_closure2(ArtifactUtilsSpec.groovy:49)
	at app//groovy.lang.Closure.call(Closure.java:412)
	at app//org.spockframework.lang.SpecInternals.createMock(SpecInternals.java:50)
	at app//org.spockframework.lang.SpecInternals.createMockImpl(SpecInternals.java:302)
	at app//org.spockframework.lang.SpecInternals.createMockImpl(SpecInternals.java:292)
	at app//org.spockframework.lang.SpecInternals.StubImpl(SpecInternals.java:137)
	at app//com.netflix.spinnaker.orca.pipeline.util.ArtifactUtilsSpec.$spock_initializeFields(ArtifactUtilsSpec.groovy:45)
ArtifactUtilsSpec > should find artifacts from a specific pipeline FAILED
    org.spockframework.runtime.InvalidSpecException: Stub 'executionRepositoryStub' matches the following required interaction:
    0 * _   (0 invocations)
    Remove the cardinality (e.g. '1 *'), or turn the stub into a mock.
        at app//org.spockframework.mock.constraint.TargetConstraint.setInteraction(TargetConstraint.java:57)
        at app//org.spockframework.mock.runtime.MockInteraction.<init>(MockInteraction.java:53)
        at app//org.spockframework.mock.runtime.InteractionBuilder.build(InteractionBuilder.java:187)
        at com.netflix.spinnaker.orca.pipeline.util.ArtifactUtilsSpec.should find artifacts from a specific pipeline_closure25(ArtifactUtilsSpec.groovy:344)
        at app//groovy.lang.Closure.call(Closure.java:412)
        at app//org.spockframework.lang.SpecInternals.createMock(SpecInternals.java:50)
        at app//org.spockframework.lang.SpecInternals.createMockImpl(SpecInternals.java:302)
        at app//org.spockframework.lang.SpecInternals.createMockImpl(SpecInternals.java:292)
        at app//org.spockframework.lang.SpecInternals.StubImpl(SpecInternals.java:137)
        at com.netflix.spinnaker.orca.pipeline.util.ArtifactUtilsSpec.should find artifacts from a specific pipeline(ArtifactUtilsSpec.groovy:339)
1 test completed, 1 failed
> Task :orca-core:test FAILED
ArtifactUtilsSpec > should find artifacts without a specific stage ref FAILED
    org.spockframework.runtime.InvalidSpecException: Stub 'executionRepositoryStub' matches the following required interaction:
    0 * _   (0 invocations)
    Remove the cardinality (e.g. '1 *'), or turn the stub into a mock.
        at app//org.spockframework.mock.constraint.TargetConstraint.setInteraction(TargetConstraint.java:57)
        at app//org.spockframework.mock.runtime.MockInteraction.<init>(MockInteraction.java:53)
        at app//org.spockframework.mock.runtime.InteractionBuilder.build(InteractionBuilder.java:187)
        at com.netflix.spinnaker.orca.pipeline.util.ArtifactUtilsSpec.should find artifacts without a specific stage ref_closure27(ArtifactUtilsSpec.groovy:382)
        at app//groovy.lang.Closure.call(Closure.java:412)
        at app//org.spockframework.lang.SpecInternals.createMock(SpecInternals.java:50)
        at app//org.spockframework.lang.SpecInternals.createMockImpl(SpecInternals.java:302)
        at app//org.spockframework.lang.SpecInternals.createMockImpl(SpecInternals.java:292)
        at app//org.spockframework.lang.SpecInternals.StubImpl(SpecInternals.java:137)
        at com.netflix.spinnaker.orca.pipeline.util.ArtifactUtilsSpec.should find artifacts without a specific stage ref(ArtifactUtilsSpec.groovy:378)
1 test completed, 1 failed
> Task :orca-core:test FAILED

To fix this issue replaced Stub() with Mock().

…during upgrade to groovy 3.x

While upgrading groovy 3.0.10 and spockframework 2.0-groovy-3.0, encountered the following errors in groovy test orca-core module:

```
Stub 'executionRepository' matches the following required interaction:

0 * _   (0 invocations)

Remove the cardinality (e.g. '1 *'), or turn the stub into a mock.

org.spockframework.runtime.InvalidSpecException: Stub 'executionRepository' matches the following required interaction:

0 * _   (0 invocations)

Remove the cardinality (e.g. '1 *'), or turn the stub into a mock.

	at app//org.spockframework.mock.constraint.TargetConstraint.setInteraction(TargetConstraint.java:57)
	at app//org.spockframework.mock.runtime.MockInteraction.<init>(MockInteraction.java:53)
	at app//org.spockframework.mock.runtime.InteractionBuilder.build(InteractionBuilder.java:187)
	at com.netflix.spinnaker.orca.pipeline.util.ArtifactUtilsSpec.$spock_initializeFields_closure2(ArtifactUtilsSpec.groovy:49)
	at app//groovy.lang.Closure.call(Closure.java:412)
	at app//org.spockframework.lang.SpecInternals.createMock(SpecInternals.java:50)
	at app//org.spockframework.lang.SpecInternals.createMockImpl(SpecInternals.java:302)
	at app//org.spockframework.lang.SpecInternals.createMockImpl(SpecInternals.java:292)
	at app//org.spockframework.lang.SpecInternals.StubImpl(SpecInternals.java:137)
	at app//com.netflix.spinnaker.orca.pipeline.util.ArtifactUtilsSpec.$spock_initializeFields(ArtifactUtilsSpec.groovy:45)
```

```
ArtifactUtilsSpec > should find artifacts from a specific pipeline FAILED
    org.spockframework.runtime.InvalidSpecException: Stub 'executionRepositoryStub' matches the following required interaction:
    0 * _   (0 invocations)
    Remove the cardinality (e.g. '1 *'), or turn the stub into a mock.
        at app//org.spockframework.mock.constraint.TargetConstraint.setInteraction(TargetConstraint.java:57)
        at app//org.spockframework.mock.runtime.MockInteraction.<init>(MockInteraction.java:53)
        at app//org.spockframework.mock.runtime.InteractionBuilder.build(InteractionBuilder.java:187)
        at com.netflix.spinnaker.orca.pipeline.util.ArtifactUtilsSpec.should find artifacts from a specific pipeline_closure25(ArtifactUtilsSpec.groovy:344)
        at app//groovy.lang.Closure.call(Closure.java:412)
        at app//org.spockframework.lang.SpecInternals.createMock(SpecInternals.java:50)
        at app//org.spockframework.lang.SpecInternals.createMockImpl(SpecInternals.java:302)
        at app//org.spockframework.lang.SpecInternals.createMockImpl(SpecInternals.java:292)
        at app//org.spockframework.lang.SpecInternals.StubImpl(SpecInternals.java:137)
        at com.netflix.spinnaker.orca.pipeline.util.ArtifactUtilsSpec.should find artifacts from a specific pipeline(ArtifactUtilsSpec.groovy:339)
1 test completed, 1 failed
> Task :orca-core:test FAILED
```

```
ArtifactUtilsSpec > should find artifacts without a specific stage ref FAILED
    org.spockframework.runtime.InvalidSpecException: Stub 'executionRepositoryStub' matches the following required interaction:
    0 * _   (0 invocations)
    Remove the cardinality (e.g. '1 *'), or turn the stub into a mock.
        at app//org.spockframework.mock.constraint.TargetConstraint.setInteraction(TargetConstraint.java:57)
        at app//org.spockframework.mock.runtime.MockInteraction.<init>(MockInteraction.java:53)
        at app//org.spockframework.mock.runtime.InteractionBuilder.build(InteractionBuilder.java:187)
        at com.netflix.spinnaker.orca.pipeline.util.ArtifactUtilsSpec.should find artifacts without a specific stage ref_closure27(ArtifactUtilsSpec.groovy:382)
        at app//groovy.lang.Closure.call(Closure.java:412)
        at app//org.spockframework.lang.SpecInternals.createMock(SpecInternals.java:50)
        at app//org.spockframework.lang.SpecInternals.createMockImpl(SpecInternals.java:302)
        at app//org.spockframework.lang.SpecInternals.createMockImpl(SpecInternals.java:292)
        at app//org.spockframework.lang.SpecInternals.StubImpl(SpecInternals.java:137)
        at com.netflix.spinnaker.orca.pipeline.util.ArtifactUtilsSpec.should find artifacts without a specific stage ref(ArtifactUtilsSpec.groovy:378)
1 test completed, 1 failed
> Task :orca-core:test FAILED
```
To fix this issue replaced Stub() with Mock().
@dbyron-sf dbyron-sf added the ready to merge Approved and ready for merge label Sep 27, 2023
@mergify mergify bot added the auto merged Merged automatically by a bot label Sep 27, 2023
@mergify mergify bot merged commit b34be07 into spinnaker:master Sep 27, 2023
4 checks passed
@j-sandy j-sandy deleted the core-test-refactor branch September 27, 2023 13:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto merged Merged automatically by a bot ready to merge Approved and ready for merge target-release/1.33
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants