Skip to content

Test micronaut 2.x #232

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

Merged
merged 1 commit into from
Jan 13, 2021
Merged

Conversation

pavolloffay
Copy link
Member

Resolves #230

All credit goes to @aaron-steinfeld 👍

Signed-off-by: Pavol Loffay p.loffay@gmail.com

Signed-off-by: Pavol Loffay <p.loffay@gmail.com>
@pavolloffay pavolloffay merged commit 71fba10 into hypertrace:main Jan 13, 2021
versionedConfiguration("io.micronaut.test:micronaut-test-junit5:${micronautTestVersion}")
versionedConfiguration("io.micronaut:micronaut-inject-java:${version}")
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this needed? The standard test only uses this as an annotation processor, which means it's not present at runtime for those tests (and thus shouldn't be when switching versions)

Copy link
Member Author

Choose a reason for hiding this comment

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

it seems redundant, removing

shouldRunAfter("test")
}
tasks.check { dependsOn(versionedTest) }
tasks.test { dependsOn(versionedTest) }
Copy link
Contributor

Choose a reason for hiding this comment

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

this contradicts the shouldRunAfter on line 48. It win's because this is a stronger constraint than shouldRunAfter, but in reality, neither should be needed - the two test tasks can run in parallel. What is needed and is missing however, is a dependency declaration for the versionedTest task itself. I suspect it's working right now because the other constraints are causing gradle to order things like compilation first anyway.

Copy link
Contributor

Choose a reason for hiding this comment

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

I take it back on the last part - the declaration of dependencies for versionedTest isn't needed explicitly since using the test sourceset tells gradle that those sources must be compiled first.

Copy link
Member Author

Choose a reason for hiding this comment

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

without this the tests do not run. I am running them as

./gradlew clean :instrumentation:micronaut-1.0:test  --info

Copy link
Contributor

Choose a reason for hiding this comment

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

So that's specifying a specific task to run - the unit test task. If you're trying to run all verification tasks, that's the purpose of check - it's the verification lifecycle task. The consequence of the change isn't huge, as I mentioned above it gets the same tasks run, it just arbitrarily forces the micronaut2 version to run before the basic unit tests, rather than letting gradle optimize their ordering/parallelizing - so up to you if the distinction is worthwhile.

Copy link
Member Author

Choose a reason for hiding this comment

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

It the additional tests are not run either with

./gradlew clean :instrumentation:micronaut-1.0:check  --info

Copy link
Contributor

@aaron-steinfeld aaron-steinfeld Jan 13, 2021

Choose a reason for hiding this comment

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

does that include the switch suggested above (tasks.check { dependsOn(versionedTest) })? I see it running when I run my local copy I used to suggest the changes (grep'd output below)

./gradlew clean :instrumentation:micronaut-1.0:check  --info | grep 2.2.3                                                                                         

Tasks to be executed: [task ':clean', task ':filter-api:clean', task ':filter-custom-opa:clean', task ':instrumentation:clean', task ':javaagent:clean', task ':javaagent-bootstrap:clean', task ':javaagent-core:clean', task ':javaagent-tooling:clean', task ':otel-extensions:clean', task ':smoke-tests:clean', task ':testing-bootstrap:clean', task ':testing-common:clean', task ':instrumentation:apache-httpasyncclient-4.1:clean', task ':instrumentation:apache-httpclient-4.0:clean', task ':instrumentation:grpc-1.5:clean', task ':instrumentation:java-streams:clean', task ':instrumentation:jaxrs-client-2.0:clean', task ':instrumentation:micronaut-1.0:clean', task ':instrumentation:netty:clean', task ':instrumentation:okhttp:clean', task ':instrumentation:servlet:clean', task ':instrumentation:spark-2.3:clean', task ':instrumentation:spring:clean', task ':instrumentation:vertx-web-3.0:clean', task ':instrumentation:netty:netty-4.0:clean', task ':instrumentation:netty:netty-4.1:clean', task ':instrumentation:okhttp:okhttp-3.0:clean', task ':instrumentation:servlet:servlet-2.3:clean', task ':instrumentation:servlet:servlet-3.0:clean', task ':instrumentation:servlet:servlet-3.1:clean', task ':instrumentation:servlet:servlet-common:clean', task ':instrumentation:spring:spring-webflux-5.0:clean', task ':spotlessInternalRegisterDependencies', task ':instrumentation:micronaut-1.0:spotlessJava', task ':instrumentation:micronaut-1.0:spotlessJavaCheck', task ':instrumentation:micronaut-1.0:spotlessKotlin', task ':instrumentation:micronaut-1.0:spotlessKotlinCheck', task ':instrumentation:micronaut-1.0:spotlessMisc', task ':instrumentation:micronaut-1.0:spotlessMiscCheck', task ':instrumentation:micronaut-1.0:spotlessScala', task ':instrumentation:micronaut-1.0:spotlessScalaCheck', task ':instrumentation:micronaut-1.0:spotlessCheck', task ':javaagent-core:extractIncludeProto', task ':javaagent-core:extractProto', task ':javaagent-core:generateProto', task ':javaagent-core:compileJava', task ':filter-api:compileJava', task ':filter-api:processResources', task ':filter-api:classes', task ':filter-api:jar', task ':javaagent-core:processResources', task ':javaagent-core:classes', task ':javaagent-core:jar', task ':testing-common:compileJava', task ':testing-common:processResources', task ':testing-common:classes', task ':testing-common:jar', task ':instrumentation:netty:netty-4.1:compileJava', task ':instrumentation:netty:netty-4.1:processResources', task ':instrumentation:netty:netty-4.1:byteBuddyjava', task ':instrumentation:netty:netty-4.1:byteBuddy', task ':instrumentation:netty:netty-4.1:classes', task ':instrumentation:netty:netty-4.1:jar', task ':instrumentation:micronaut-1.0:compileJava', task ':instrumentation:micronaut-1.0:processResources', task ':instrumentation:micronaut-1.0:classes', task ':instrumentation:micronaut-1.0:compileTestJava', task ':instrumentation:micronaut-1.0:processTestResources', task ':instrumentation:micronaut-1.0:testClasses', task ':instrumentation:micronaut-1.0:test', task ':instrumentation:micronaut-1.0:test_2.2.3', task ':instrumentation:micronaut-1.0:check']
:instrumentation:micronaut-1.0:test_2.2.3 (Thread[Execution worker for ':',5,main]) started.
> Task :instrumentation:micronaut-1.0:test_2.2.3 FROM-CACHE
Build cache key for task ':instrumentation:micronaut-1.0:test_2.2.3' is ffad4aba7c3744e5af595a8df6b0397f
Task ':instrumentation:micronaut-1.0:test_2.2.3' is not up-to-date because:
  Output property 'binaryResultsDirectory' file /Users/asteinfeld/dev/javaagent/instrumentation/micronaut-1.0/build/test-results/test_2.2.3/binary has been removed.
  Output property 'binaryResultsDirectory' file /Users/asteinfeld/dev/javaagent/instrumentation/micronaut-1.0/build/test-results/test_2.2.3/binary/output.bin has been removed.
  Output property 'binaryResultsDirectory' file /Users/asteinfeld/dev/javaagent/instrumentation/micronaut-1.0/build/test-results/test_2.2.3/binary/output.bin.idx has been removed.
Loaded cache entry for task ':instrumentation:micronaut-1.0:test_2.2.3' with cache key ffad4aba7c3744e5af595a8df6b0397f
:instrumentation:micronaut-1.0:test_2.2.3 (Thread[Execution worker for ':',5,main]) completed. Took 0.063 secs.

Copy link
Member Author

Choose a reason for hiding this comment

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

changing to check

 tasks.check { dependsOn(versionedTest) }

now it runs as part of the check task, not sure what the benefit is though.

Copy link
Contributor

Choose a reason for hiding this comment

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

described above - it's minimal, but it removes one more constraint on the task graph to allow better optimization of the task execution.

Copy link
Member Author

Choose a reason for hiding this comment

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

got it thanks

for (version in listOf(micronautVersion, micronaut2Version)) {
val micronaut2Version = "2.2.3"

for (version in listOf(micronaut2Version)) {
val versionedConfiguration = configurations.create("test_${version}") {
extendsFrom(configurations.testRuntimeClasspath.get())
}
dependencies {
versionedConfiguration(project(":instrumentation:netty:netty-4.1"))
Copy link
Contributor

Choose a reason for hiding this comment

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

These aren't present in the testImplementation either - I'd expect the dependencies called out here to match those, except with different versions (and the added junit ones which are added externally from your root file for testImplementation and aren't visible in this file)

Copy link
Member Author

Choose a reason for hiding this comment

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

not needed removing

Copy link
Contributor

@aaron-steinfeld aaron-steinfeld left a comment

Choose a reason for hiding this comment

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

Suggested changes:

diff --git a/instrumentation/micronaut-1.0/build.gradle.kts b/instrumentation/micronaut-1.0/build.gradle.kts
index a24fba1..229cb49 100644
--- a/instrumentation/micronaut-1.0/build.gradle.kts
+++ b/instrumentation/micronaut-1.0/build.gradle.kts
@@ -24,14 +24,11 @@ val micronaut2Version = "2.2.3"
 
 for (version in listOf(micronaut2Version)) {
     val versionedConfiguration = configurations.create("test_${version}") {
-        extendsFrom(configurations.testRuntimeClasspath.get())
+        extendsFrom(configurations.runtimeClasspath.get())
     }
     dependencies {
-        versionedConfiguration(project(":instrumentation:netty:netty-4.1"))
-        versionedConfiguration("io.opentelemetry.javaagent.instrumentation:opentelemetry-javaagent-netty-4.1:${versions["opentelemetry_java_agent"]}")
         versionedConfiguration(project(":testing-common"))
         versionedConfiguration("io.micronaut.test:micronaut-test-junit5:${micronautTestVersion}")
-        versionedConfiguration("io.micronaut:micronaut-inject-java:${version}")
         versionedConfiguration("io.micronaut:micronaut-http-server-netty:${version}")
         versionedConfiguration("io.micronaut:micronaut-http-client:${version}")
         versionedConfiguration("io.micronaut:micronaut-runtime:${version}")
@@ -45,7 +42,6 @@ for (version in listOf(micronaut2Version)) {
         testClassesDirs = testOuput.classesDirs
         classpath = versionedConfiguration + testOuput
         useJUnitPlatform()
-        shouldRunAfter("test")
     }
-    tasks.test { dependsOn(versionedTest) }
+    tasks.check { dependsOn(versionedTest) }
 }

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.

Run micronaut tests against multiple versions
2 participants