google-cloud-java icon indicating copy to clipboard operation
google-cloud-java copied to clipboard

Support standard env vars for emulator testing

Open shinfan opened this issue 10 years ago • 2 comments

https://github.com/GoogleCloudPlatform/gcloud-python/blob/master/gcloud/environment_vars.py

shinfan avatar May 09 '16 17:05 shinfan

What's the workaround for this until the env variable is supported?

kir-titievsky avatar Oct 14 '16 18:10 kir-titievsky

Hi @kir-titievsky, we offer helper classes that allow you to start/stop/reset an emulator from your tests. For example the following code starts and uses the local datastore emulator:

// Use the default consistency setting of 0.9
LocalDatastoreHelper helper = LocalDatastoreHelper.create();
// or explicitly set the consistency
helper = LocalDatastoreHelper.create(0.6);

// Start the local Datastore emulator in a separate process
helper.start();

// Create and use a Datastore object with the options given by the LocalDatastoreHelper instance. 
Datastore localDatastore = helper.options().service();

// Stop the emulator
helper.stop();

You can find more details in our TESTING readme. Does this help?

mziccard avatar Oct 14 '16 18:10 mziccard