-
Notifications
You must be signed in to change notification settings - Fork 43
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
fix(java): rename test to be picked up by native profile #723
Conversation
The Kokoro Native Image job is now passing |
However, the unit tests seem to be failing with the following error:
|
All tests are now passing. |
@@ -0,0 +1 @@ | |||
Args = --enable-url-protocols=https,http |
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.
Does this library use HTTP (not HTTPS) somewhere in users' environment? (What's the error without this argument?)
If the request is only for testing, then this file should be under test.
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.
Looking at the stacktrace, this is coming from com.google.datastore.v1.client.RemoteRpc
:
Caused by: java.lang.IllegalArgumentException: java.net.MalformedURLException: Accessing an URL protocol that was not enabled. The URL protocol https is supported but not enabled by default. It must be enabled by adding the --enable-url-protocols=https option to the native-image command.
com.google.api.client.http.GenericUrl.parseURL(GenericUrl.java:679)
com.google.api.client.http.GenericUrl.<init>(GenericUrl.java:125)
com.google.api.client.http.GenericUrl.<init>(GenericUrl.java:108)
com.google.datastore.v1.client.RemoteRpc.resolveURL(RemoteRpc.java:161)
com.google.datastore.v1.client.RemoteRpc.<init>(RemoteRpc.java:62)
Normally this configuration would come from gax, but this module doesn't import it so we had to add this setting in.
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.
I believe RemoteRpc
constructor takes an HTTP URL. Where is the value defined? (My guess is it's only for tests)
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.
The error is coming from RemoteRpc.resolveURL
but it's used in RemoteRpc#call
which is later referenced in Datastore
. For this reason, I think we would still need it in the main configuration?
@kolea2 This is a followup from our conversation after the Wednesday meeting. |
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.
If the allow HTTP is passed in GAX already, then no need to reject it here.
Thank you all so much! |
🤖 I have created a release *beep* *boop* --- ## [2.5.0](v2.4.0...v2.5.0) (2022-05-23) ### Features * add build scripts for native image testing in Java 17 ([#1440](#1440)) ([#739](#739)) ([252a174](252a174)) * add ReadOption.ReadTime to support timestamp reads. ([#712](#712)) ([06bb08f](06bb08f)) ### Bug Fixes * **java:** rename test to be picked up by native profile ([#723](#723)) ([3a30e75](3a30e75)) ### Documentation * **samples:** remove unused dependency ([#730](#730)) ([5185691](5185691)) ### Dependencies * update dependency com.google.cloud:google-cloud-shared-dependencies to v2.11.0 ([#737](#737)) ([8eb0c5f](8eb0c5f)) * update shared deps to 2.12.0 ([#740](#740)) ([5c3676e](5c3676e)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
A couple of changes to note:
The maven-surefire-plugin defined in datastore-v1-proto-client/pom.xml was overwriting the one defined in the native profile brought in from java-shared-config, therefore, resulting in the following error:
Test configuration file wasn't found. Make sure that test execution wasn't skipped.
. Tested this change locally to verify that integration tests are excluded when unit tests are run. Also, java-shared-config brings in the same config defined in the POM: https://github.com/googleapis/java-shared-config/blob/b5e05c6726c60a7ad7c0d9588b4fab69a0b4e6b7/pom.xml#L87Replaced usages of
@Rule public ExpectedException thrown = ExpectedException.none();
with Truth. (background: go/cloud-java-native-image#truth-vs-hamcrest-use-truth)Renamed test that uses EasyMock
ITDatastoreTest
->DatastoreTest
as mocking is incompatible with native image compilation atm.