-
Notifications
You must be signed in to change notification settings - Fork 291
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
Update Groovy and Spock versions #4840
Update Groovy and Spock versions #4840
Conversation
d1a62af
to
41c8c78
Compare
5bd62a8
to
e95d721
Compare
dd-trace-core/src/test/groovy/datadog/trace/common/writer/DDAgentApiTest.groovy
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work 👏
I wonder if it will be an issue for the junit-4
and junit-5
instrumentation to not properly test the minimal version supported. I will try to get some feedback on it.
In the meantime, I left you some comments.
dd-java-agent/agent-iast/src/test/groovy/com/datadog/iast/sink/PathTraversalModuleTest.groovy
Outdated
Show resolved
Hide resolved
@@ -1,5 +1,5 @@ | |||
final class CachedData { | |||
static groovyVer = "2.5.21" | |||
static groovyVer = "3.0.10" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not using groovy 4?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One of the reasons for doing this change was to be able to use gradleTestKit()
, and the one that comes with our Gradle version uses Groovy 3.0.10.
If I update it to Groovy 4 I am afraid the issue will be the same as before, only this time Spock's Groovy will be newer than the test kit's one, not older.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I tried to bump Groovy version to version 4 but I had to leave it to 3 for Gradle plugins for example.
Is there any specific module(s) that would requires version 3 for your tests or will it impact the whole project?
I wonder if it could be doable (and recommended) to update to 4 while leaving some module to 3 (like we did for JUnit4/5).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will be just one module that does Gradle instrumentation. Technically it would be possible, of course, to have that specific module use Groovy 3, but it would complicate things too much in my opinion (as that module depends on a couple of common testing modules which themselves depend on Groovy).
Perhaps it would be simpler to migrate to Groovy 4 together with Gradle wrapper update, to avoid the need to have multiple versions.
@@ -10,9 +10,8 @@ final class CachedData { | |||
okhttp_legacy : "[3.0,3.12.12]", // 3.12.x is last version to support Java7) | |||
okio : "1.16.0", | |||
|
|||
spock : "1.3-groovy-$spockGroovyVer", | |||
spock : "2.1-groovy-$spockGroovyVer", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same question here: why not using latest Spock version 2.3
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Initial intention was to do the minimal upgrade required to use Groovy 3. I will try the newest version to see if it doesn't require further changes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For some strange reason, upgrading Groovy from 3.0.10
to 3.0.11
breaks tests in :dd-java-agent:instrumentation:netty-4.1:test
module.
This blocks upgrading Spock.
I assume it's some transitive dependency change in Groovy that is to blame (my prime suspect is asm, which has been bumped from 9.2
to 9.3
), but I wasn't able to prove it.
I cannot dedicate much more time to this change at the moment, so my suggestion would be staying on Groovy 3.0.10
/ Spock 2.1
combination for now, and then possibly upgrading them later as a separate change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally, I wouldn't mind upgrading Groovy and Spock in separate PR, since these will probably require many more fixes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. About my above comment, this question (global groovy 4 with some groovy 3 modules) can be investigate later in another PR in you have other priorities right now.
Yeah, I am not too happy about this, but there isn't an alternative that I can think of. |
…Unit 5 assertions
… in projects that utilize SpockRunner for instrumentation tests
…mentation classpath of some instrumentation modules, as they were incompatible with the versions used by Spock
…d to verify mock interactions, and Spock 2.x is strict about this
…h newer Spock version
We could start thinking of moving away from |
…r to use JUnitPlatform
f8b19af
to
f20c2e3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM for debugger
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job!
Seems all good. Can you squash the commits when merging? 🙏 |
What Does This Do
Updates Groovy version (2.5 -> 3.0) and Spock version (1.3 -> 2.1).
Migrates all tests that used to run on JUnit 4 to JUnit 5.
Motivation
Our current version of Spock is 1.3.
It only support Groovy 2.x, which has some drawbacks:
gradleTestKit()
cannot be used due to dependency conflictsAdditional Notes
SpockRunner
that we use to run instrumentation tests cannot be properly ported to JUnit 5, since the framework does not provide the hooks / extension points that can be used to shadow the tested class (see Introduce extension API for providing a custom ClassLoader (e.g. for Powermock)).In order to mitigate this,
SpockRunner
was changed to extendJUnitPlatform
, which is a JUnit 4 runner that allows executing JUnit 5 tests in a JUnit 4 environment (i.e. running them as JUnit 4 tests).So even though Spock 2 tests run on top of JUnit 5, we execute them in "compatibility mode" so that
SpockRunner
could shadow the test class (see SputnikRunner removed for more details).