Agreed, but a little debugging shows that Google Client Library is trying to connect to the actual cloud endpoint of the project: supplying the credentials through `gcloud auth application-default login` or `gcloud iam service-accounts keys create` results in the test code connecting to the production datastore…
According to
https://cloud.google.com/docs/authentication/production#finding_credentials_automatically, if no credentials are provided the hosting environment should automatically provide connection hints for the local resources: I’d expect Java 8 Local Development Server to automatically connect Google Client Library to the local Datastore Emulator, replicating the application behaviour when deployed in cloud, but that’s apparently not the case.
I’m currently working around the issue by testing locally using both the Local Development Server and the standalone Datastore Emulator as:
gcloud beta emulators datastore start \
—project=project-id \
--host-port=localhost:8081 \
--data-dir=target/war
DATASTORE_EMULATOR_HOST=localhost:8081 java_dev_appserver.sh \
--port=8080 \
target/war
However, the process is quite cumbersome and difficult to automate: what I’m looking for is a way to automatically connect Google Client Library to the Datastore Emulator managed by the Java 8 Local Development Server when launching the app with something like
https://github.com/GoogleCloudPlatform/app-maven-plugin, e.g. `mvn appengine:run`.
-----------------------------------------------------------------------------------------------------------------------------------------
alessandro bollini ph.d. - tech lead -
linkedin.com/in/alessandrobollini