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

Migrate to spock 2 #4458

Merged
merged 5 commits into from
Oct 22, 2021
Merged

Migrate to spock 2 #4458

merged 5 commits into from
Oct 22, 2021

Conversation

laurit
Copy link
Contributor

@laurit laurit commented Oct 21, 2021

Resolves #4271

"io.netty:netty:3.10.6.Final",
"org.assertj:assertj-core:3.21.0",
"org.awaitility:awaitility:4.1.0",
"org.checkerframework:checker-qual:3.14.0",
"org.codehaus.groovy:groovy-all:${groovyVersion}",
"org.objenesis:objenesis:3.2",
"org.spockframework:spock-core:1.3-groovy-2.5",
"org.spockframework:spock-core:2.0-groovy-2.5",
"org.spockframework:spock-junit4:2.0-groovy-2.5",
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you know what we need this for? Ideally it runs with jupiter now without needing any junit4 stuff (I noticed we removed some junit4 annotations)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is needed for junit @Rule which is used in a couple of tests that mutate environment variables and in jaxrs+dropwizard tests. I initially got rid of these rules by extracting code from rule classes, but reverted that when I found this compatibility module.

* SPDX-License-Identifier: Apache-2.0
*/

import static org.assertj.core.api.Assertions.assertThat;
Copy link
Contributor

Choose a reason for hiding this comment

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

Quite a bit of groovy -> Java - I'll take what I can get :-)

@@ -44,7 +42,6 @@ trait HttpServerTestTrait<SERVER> implements RetryOnAddressAlreadyInUseTrait {
static int port
static URI address

@BeforeClass
Copy link
Contributor

Choose a reason for hiding this comment

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

Would jupiter's BeforeAll / AfterAll have worked?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As far as I understand spock 2 doesn't extend junit 5, it more like replaces it while using the same platform that junit 5 is built on, so none of the junit 5 annotations work.

@@ -81,7 +81,7 @@ abstract class AbstractGrpcStreamingTest extends InstrumentationSpecification {
GreeterGrpc.GreeterStub client = GreeterGrpc.newStub(channel).withWaitForReady()

when:
def observer = client.conversation(new StreamObserver<Helloworld.Response>() {
def observer2 = client.conversation(new StreamObserver<Helloworld.Response>() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

test failed to compile claiming that there already is a variable named observer in current scope

@@ -230,11 +230,11 @@ class LettuceAsyncClientTest extends AgentInstrumentationSpecification {
String successStr = "KEY MISSING"
BiFunction<String, Throwable, String> firstStage = new BiFunction<String, Throwable, String>() {
@Override
String apply(String res, Throwable throwable) {
String apply(String res, Throwable error) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

spock 2 has a bug that makes it fail when local variable is named throwable

@@ -495,15 +495,19 @@ class JdbcInstrumentationTest extends AgentInstrumentationSpecification {
connection = driver.connect(jdbcUrl, null)
}

def (Statement statement, ResultSet rs) = runWithSpan("parent") {
// TODO: def (Statement statement, ResultSet rs) fails to compile, switch back when this is fixed in spock
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe this bug only manifests when test has a cleanup block

Copy link
Member

Choose a reason for hiding this comment

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

🤯

@@ -495,15 +495,19 @@ class JdbcInstrumentationTest extends AgentInstrumentationSpecification {
connection = driver.connect(jdbcUrl, null)
}

def (Statement statement, ResultSet rs) = runWithSpan("parent") {
// TODO: def (Statement statement, ResultSet rs) fails to compile, switch back when this is fixed in spock
Copy link
Member

Choose a reason for hiding this comment

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

🤯

smoke-tests/images/servlet/build.gradle Outdated Show resolved Hide resolved
@@ -24,7 +24,11 @@ class SnsCamelTest extends AgentInstrumentationSpecification {
String queueName = "snsCamelTest"
def camelApp = new CamelSpringApp(awsConnector, SnsConfig, ImmutableMap.of("topicName", topicName, "queueName", queueName))

def (queueUrl, topicArn) = setupTestInfrastructure(queueName, topicName)
// TODO: def (queueUrl, topicArn) fails to compile, switch back when this is fixed in spock
Copy link
Contributor

Choose a reason for hiding this comment

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

It is already fixed, just not released yet: spockframework/spock#1333

Probably makes sense to link that PR/issue here.

Copy link
Member

@trask trask left a comment

Choose a reason for hiding this comment

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

👍

@trask
Copy link
Member

trask commented Oct 21, 2021

@laurit looks like i caused merge conflicts, i'll resolve and push

@trask trask merged commit 9b8ab5e into open-telemetry:main Oct 22, 2021
RashmiRam pushed a commit to RashmiRam/opentelemetry-auto-instr-java that referenced this pull request May 23, 2022
* Migrate to spock 2

* Fix smoke test suites

* address review comments

* review comment

Co-authored-by: Trask Stalnaker <[email protected]>
@laurit laurit deleted the spock2 branch July 6, 2023 17:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Migrate away from Sputnik
5 participants