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

Run JUnit tests with GraalVM #6296

Closed
swankjesse opened this issue Oct 2, 2020 · 8 comments
Closed

Run JUnit tests with GraalVM #6296

swankjesse opened this issue Oct 2, 2020 · 8 comments
Labels
enhancement Feature not a bug

Comments

@swankjesse
Copy link
Collaborator

It's quite possible there's gaps on OkHttp when executed on GraalVM.

We should do the Gradle work to run our test suite on it. It appears possible, though awkward.
spring-attic/spring-native#22

Spring uses JUnit 5 in the above example. If doing our tests on GraalVM requires upgrading to JUnit 5, we should probably do that too.

@swankjesse swankjesse added the enhancement Feature not a bug label Oct 2, 2020
@yschimke
Copy link
Collaborator

yschimke commented Oct 2, 2020

Check if that's interesting to use GraalVM capability to create shared libraries

Interesting...

@yschimke
Copy link
Collaborator

yschimke commented Oct 2, 2020

Wow

Test run finished after 966 ms
[       101 containers found      ]
[         2 containers skipped    ]
[        99 containers started    ]
[         1 containers aborted    ]
[        98 containers successful ]
[         0 containers failed     ]
[      1096 tests found           ]
[        68 tests skipped         ]
[      1025 tests started         ]
[         0 tests aborted         ]
[      1025 tests successful      ]
[         0 tests failed          ]

swankjesse pushed a commit that referenced this issue Oct 9, 2020
I want to confirm all of OkHttp works with Graalvm, and I'm hoping
to demonstrate that by getting the entire test suite running inside
Graalvm.

#6296
swankjesse added a commit that referenced this issue Oct 10, 2020
I want to confirm all of OkHttp works with Graalvm, and I'm hoping
to demonstrate that by getting the entire test suite running inside
Graalvm.

#6296
@yschimke
Copy link
Collaborator

Do you want any help with any aspect of this? exploring best ways to setup reflection with junit? adding support in PlatformRule to use NativeImageDetector.inNativeImage()? fixing tests?

I'll assume no, but happy to chip in when and if you think I can help.

@swankjesse
Copy link
Collaborator Author

Yeah I'd love help.

In hacking on this yesterday I learned just how annoying it is to pull one module’s tests into another module's dependencies. My conclusion was to make this into a task we can use from any module, and not a separate module. Which led to this PR:
palantir/gradle-graal#393

The next natural step I see while waiting on the above is to temporarily manually move a few tests into native-image-tests/src/main/java to execute 'em in Graal. Presumably there's gonna be challenges there! Getting CallTest passing will be a nice milestone.

@yschimke
Copy link
Collaborator

@swankjesse +1 - graal itself doesn't add additional modules, just a target for running nativeImage. Is that an option here?

nativeImage -> jar
as
graalTest -> test?

@swankjesse
Copy link
Collaborator Author

Yep!

@yschimke
Copy link
Collaborator

POC graal test with okhttp and mockwebserver with only Junit5

yschimke#5

$  ./native-image-tests/build/graal/ConsoleLauncher --select-class okhttp3.CallKotlinTest

Thanks for using JUnit! Support its development at https://junit.org/sponsoring

╷
└─ JUnit Jupiter ✔
   └─ CallKotlinTest ✔
      ├─ legalToExecuteTwiceCloning() ✔
      └─ testMockWebserverRequest() ✔

Test run finished after 168 ms
[         2 containers found      ]
[         0 containers skipped    ]
[         2 containers started    ]
[         0 containers aborted    ]
[         2 containers successful ]
[         0 containers failed     ]
[         2 tests found           ]
[         0 tests skipped         ]
[         2 tests started         ]
[         0 tests aborted         ]
[         2 tests successful      ]
[         0 tests failed          ]

@yschimke
Copy link
Collaborator

Closing this out, I think remaining work is really a migrate all tests to junit5 task.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Feature not a bug
Projects
None yet
Development

No branches or pull requests

2 participants