Running unit tests from Maven, my code starts DatastoreCloudOnTestHelper. All connections to the Datastore emulator are refused. Stacktrace below.
Notes:
- Everything works OK when running tests from TestNG plugin in Eclipse.
-- Using detailed logs in the Google Cloud code, I learned that the reason is this: In Eclipse, GcloudEmulatorRunner silently fails to start, so that the test-helper falls back to an emulator which it downloads from Google Cloud Storage. This downloaded emulator allow connections. In contrast, when running from Maven, the GcloudEmulatorRunner completes its starts up "successfully," so that GcloudEmulatorRunner is used -- but it refuses connections. Ironically, then, it is the fallback to the less-preferred emulator which allows the tests to proceed in Eclipse.
- On a colleague's machine, even running from Maven, everything works OK.
- Simply running the emulator from the command line (
gcloud beta emulators datastore start ...) allows connections -- everything works OK.
- My gcloud is fully up to date :
gcloud components list, Your current Cloud SDK version is: 164.0.0. The latest available version is: 164.0.0.
- I checked whether the Windows Firewall is blocking this
java.exe -- it is not.
How can I get this to work?
INFO: Initialized Google Cloud Datastore with options gcloud-java/1.2.0:localhost:51321
SEVERE: ``java.net.ConnectException: Connection refused: connect Connection refused: connect
java.net.ConnectException: Connection refused: connect
at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:85)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at sun.net.NetworkClient.doConnect(NetworkClient.java:175)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:432)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:527)
at sun.net.www.http.HttpClient.<init>(HttpClient.java:211)
at sun.net.www.http.HttpClient.New(HttpClient.java:308)
at sun.net.www.http.HttpClient.New(HttpClient.java:326)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:1169)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1105)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:999)
at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:933)
at sun.net.www.protocol.http.HttpURLConnection.getOutputStream0(HttpURLConnection.java:1283)
at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:1258)
at com.google.api.client.http.javanet.NetHttpRequest.execute(NetHttpRequest.java:77)
at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:981)
at com.google.datastore.v1.client.RemoteRpc.call(RemoteRpc.java:87)
at com.google.datastore.v1.client.Datastore.commit(Datastore.java:84)
at com.google.cloud.datastore.spi.v1.HttpDatastoreRpc.commit(HttpDatastoreRpc.java:152)
at com.google.cloud.datastore.DatastoreImpl$5.call(DatastoreImpl.java:418)
at com.google.cloud.datastore.DatastoreImpl$5.call(DatastoreImpl.java:415)
at com.google.api.gax.retrying.DirectRetryingExecutor.submit(DirectRetryingExecutor.java:93)
at com.google.cloud.RetryHelper.runWithRetries(RetryHelper.java:49)
at com.google.cloud.datastore.DatastoreImpl.commit(DatastoreImpl.java:414)
at com.google.cloud.datastore.DatastoreImpl.commitMutation(DatastoreImpl.java:408)
at com.google.cloud.datastore.DatastoreImpl.put(DatastoreImpl.java:368)
at com.google.cloud.datastore.DatastoreHelper.put(DatastoreHelper.java:55)
at com.google.cloud.datastore.DatastoreImpl.put(DatastoreImpl.java:343)
Running unit tests from Maven, my code starts
DatastoreCloudOnTestHelper. All connections to the Datastore emulator are refused. Stacktrace below.Notes:
-- Using detailed logs in the Google Cloud code, I learned that the reason is this: In Eclipse,
GcloudEmulatorRunnersilently fails to start, so that the test-helper falls back to an emulator which it downloads from Google Cloud Storage. This downloaded emulator allow connections. In contrast, when running from Maven, theGcloudEmulatorRunnercompletes its starts up "successfully," so thatGcloudEmulatorRunneris used -- but it refuses connections. Ironically, then, it is the fallback to the less-preferred emulator which allows the tests to proceed in Eclipse.gcloud beta emulators datastore start ...) allows connections -- everything works OK.gcloud components list, Your current Cloud SDK version is: 164.0.0. The latest available version is: 164.0.0.java.exe-- it is not.How can I get this to work?