-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Description
Module
None
Problem
I am developing a spring-cloud-function (spring boot) based aws lambda app which is compiled with Graal image and shall be tested as native compiled application as well using maven plugin.
https://graalvm.github.io/native-build-tools/latest/maven-plugin.html
While running native testing the below issue appears which i assume is based on missing reachability information for testcontainers in graalvm reachability metadata repository https://github.com/oracle/graalvm-reachability-metadata/tree/master/metadata/org.testcontainers/testcontainers
org.testcontainers.dockerclient.RootlessDockerClientProviderStrategy$LibC. -> libjnidispatch.so
[2/7] Performing analysis... [**********] (189.4s @ 4.34GB)
15,363 (89.01%) of 17,260 classes reachable
25,425 (65.46%) of 38,839 fields reachable
69,945 (57.00%) of 122,717 methods reachable
493 classes, 153 fields, and 2,506 methods registered for reflection
65 classes, 68 fields, and 56 methods registered for JNI access
4 native libraries: dl, pthread, rt, z
8:47:22.229 [main] DEBUG org.testcontainers.dockerclient.DockerClientProviderStrategy - UnixSocketClientProviderStrategy: failed with exception RuntimeException (org.testcontainers.shaded.com.fasterxml.jackson.databind.JsonMappingException: Can not construct instance of com.github.dockerjava.api.model.Info
: no suitable constructor found, can not deserialize from Object value (missing default constructor or creator, or perhaps need to add/enable type information?)
at [Source: N/A; line: -1, column: -1]). Root cause JsonMappingException (Can not construct instance of com.github.dockerjava.api.model.Info: no suitable constructor found, can not deserialize from Object value (missing default constructor or creator, or perhaps need to add/enable type information?)
at [Source: N/A; line: -1, column: -1])
08:47:22.229 [main] DEBUG org.testcontainers.dockerclient.RootlessDockerClientProviderStrategy - $XDG_RUNTIME_DIR is not set.
08:47:22.229 [main] DEBUG org.testcontainers.dockerclient.RootlessDockerClientProviderStrategy - '/root/.docker/run/docker.sock' does not exist.
Failures (1):
JUnit Jupiter:GetSessionsTest
ClassSource [className = 'demo.cloudfunctiondynamodblambda.GetSessionsTest', filePosition = null]
=> java.lang.UnsatisfiedLinkError: Native library (com/sun/jna/linux-x86-64/libjnidispatch.so) not found in resource path ()
com.sun.jna.Native.loadNativeDispatchLibraryFromClasspath(Native.java:1033)
com.sun.jna.Native.loadNativeDispatchLibrary(Native.java:989)
com.sun.jna.Native.<clinit>(Native.java:195)
org.testcontainers.dockerclient.RootlessDockerClientProviderStrategy$LibC.<clinit>(RootlessDockerClientProviderStrategy.java:96)
org.testcontainers.dockerclient.RootlessDockerClientProviderStrategy.lambda$null$0(RootlessDockerClientProviderStrategy.java:37)
[...]
Suppressed: java.lang.NoClassDefFoundError: Could not initialize class org.testcontainers.dockerclient.RootlessDockerClientProviderStrategy$LibC
org.testcontainers.dockerclient.RootlessDockerClientProviderStrategy.lambda$null$0(RootlessDockerClientProviderStrategy.java:37)
[ 0 tests started ]
[ 0 tests aborted ]
[ 0 tests successful ]
[ 0 tests failed ]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 09:52 min
[INFO] Finished at: 2022-12-07T08:47:22+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.graalvm.buildtools:native-maven-plugin:0.9.19:test (test-native) on project cloud-function-dynamodb-lambda: Execution of /git/serverless/spring-native-aws-demo/cloud-function-dynamodb-lambda/target/native-tests --xml-output-dir /git/serverless/spring-native-aws-demo/cloud-
function-dynamodb-lambda/target/native-test-reports -Djunit.platform.listeners.uid.tracking.output.dir=/git/serverless/spring-native-aws-demo/cloud-function-dynamodb-lambda/target/test-ids returned non-zero result -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
Solution
Create tests to cover the graal native image based compilation and testing to detect issues and regression test for supporting thee spring boot way of native testing
Add necesarry [
2/7] Performing analysis... [**********] (189.4s @ 4.34GB)
15,363 (89.01%) of 17,260 classes reachable
25,425 (65.46%) of 38,839 fields reachable
69,945 (57.00%) of 122,717 methods reachable
493 classes, 153 fields, and 2,506 methods registered for reflection
65 classes, 68 fields, and 56 methods registered for JNI access
4 native libraries: dl, pthread, rt, z
Benefit
Graal won't go away ;) Testing features platform specific is necessary to allow discover platform specific tests
Alternatives
Would you like to help contributing this feature?
yes. Added possible fix as below fork, but trying to test that now.