-
Notifications
You must be signed in to change notification settings - Fork 135
Closed
Labels
🚨This issue needs some love.This issue needs some love.api: spannerIssues related to the googleapis/java-spanner API.Issues related to the googleapis/java-spanner API.triage meI really want to be triaged.I really want to be triaged.
Description
Currently some integrations tests that are run with the native profile are resulting in the following errors:
JUnit Vintage:ITSessionPoolIntegrationTest
ClassSource [className = 'com.google.cloud.spanner.ITSessionPoolIntegrationTest', filePosition = null]
=> java.lang.NullPointerException: Property spanner.testenv.config.class needs to be set
com.google.cloud.spanner.IntegrationTestEnv.initializeConfig(IntegrationTestEnv.java:68)
com.google.cloud.spanner.IntegrationTestEnv.before(IntegrationTestEnv.java:77)
org.junit.rules.ExternalResource$1.evaluate(ExternalResource.java:50)
org.junit.rules.RunRules.evaluate(RunRules.java:20)
org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
org.junit.runners.ParentRunner.run(ParentRunner.java:413)
org.junit.runner.JUnitCore.run(JUnitCore.java:137)
org.junit.runner.JUnitCore.run(JUnitCore.java:115)
org.junit.vintage.engine.execution.RunnerExecutor.execute(RunnerExecutor.java:42)
org.junit.vintage.engine.VintageTestEngine.executeAllChildren(VintageTestEngine.java:80)
[...]
JUnit Vintage:ITInstanceAdminTest
ClassSource [className = 'com.google.cloud.spanner.it.ITInstanceAdminTest', filePosition = null]
=> java.lang.NullPointerException: Property spanner.testenv.config.class needs to be set
com.google.cloud.spanner.IntegrationTestEnv.initializeConfig(IntegrationTestEnv.java:68)
com.google.cloud.spanner.IntegrationTestEnv.before(IntegrationTestEnv.java:77)
org.junit.rules.ExternalResource$1.evaluate(ExternalResource.java:50)
org.junit.rules.RunRules.evaluate(RunRules.java:20)
org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
org.junit.runners.ParentRunner.run(ParentRunner.java:413)
org.junit.runner.JUnitCore.run(JUnitCore.java:137)
org.junit.runner.JUnitCore.run(JUnitCore.java:115)
org.junit.vintage.engine.execution.RunnerExecutor.execute(RunnerExecutor.java:42)
org.junit.vintage.engine.VintageTestEngine.executeAllChildren(VintageTestEngine.java:80)
[...]
This means that system properties are not accessible to the tests after native image compilation. According to the official documentation, System properties are only available at build-time (when the native image builder is building the image) and not at run-time and can't be determined from the maven-surefire/maven-failsafe plugin. This requires us to do a couple of things:
- Pass the System Property in question directly to the
native-imagecommand using-Dspanner.testenv.config.class=. - Store the system property's value as the static variable.
- Initialize the class that is referencing the System Property at build-time. (fix(java): initialize spanner test environment class at build-time and add reflection configurations java-core#734)
Additionally, we also need to specify the system properties to the maven surefire plugin because the native profile uses this plugin to run tests before building the native image.
Metadata
Metadata
Assignees
Labels
🚨This issue needs some love.This issue needs some love.api: spannerIssues related to the googleapis/java-spanner API.Issues related to the googleapis/java-spanner API.triage meI really want to be triaged.I really want to be triaged.