Skip to content

Commit c349185

Browse files
authored
---
yaml --- r: 5583 b: refs/heads/master c: b6a87b0 h: refs/heads/master i: 5581: aca7796 5579: e61d025 5575: 6b781e8 5567: f088739
1 parent d57cfb2 commit c349185

2 files changed

Lines changed: 22 additions & 38 deletions

File tree

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: a27d8c7ff24c282b2a7bf943dfec039d7ef02f72
2+
refs/heads/master: b6a87b0deb4dd2aaebaf528d9225c1927b5bb475
33
refs/heads/travis: dae77e558b884bc1b165155482d76c8e40b0fca4
44
refs/heads/gh-pages: 049a9668af6afce3b5840dee8be005b0e6b43506
55
refs/tags/0.0.9: 22f1839238f66c39e67ed4dfdcd273b1ae2e8444

trunk/TESTING.md

Lines changed: 21 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -73,46 +73,30 @@ uses the `RemoteComputeHelper` to create an address.
7373

7474
You can test against a temporary local Datastore by following these steps:
7575

76-
1. Start the local Datastore emulator before running your tests using `LocalDatastoreHelper`'s `create` and `start` methods. This will create a temporary folder on your computer and bind a port for communication with the local Datastore. There is an optional argument for `create`: consistency. The consistency setting controls the fraction of Datastore writes that are immediately visible in global queries.
77-
```java
78-
// Use the default consistency setting of 0.9
79-
LocalDatastoreHelper helper = LocalDatastoreHelper.create();
80-
// or explicitly set the consistency
81-
helper = LocalDatastoreHelper.create(0.6);
82-
83-
helper.start(); // Starts the local Datastore emulator in a separate process
84-
```
85-
86-
2. Create and use a `Datastore` object with the options given by the `LocalDatastoreHelper` instance. For example:
87-
```java
88-
Datastore localDatastore = helper.getOptions().getService();
89-
```
90-
91-
3. Run your tests.
92-
93-
4. Stop the local datastore emulator by calling the `stop()` method, like so:
94-
```java
95-
helper.stop();
96-
```
97-
98-
#### On a remote machine
99-
100-
You can test against a remote Datastore emulator as well. To do this, set the `DatastoreOptions` project endpoint to the hostname of the remote machine, like the example below.
101-
102-
```java
103-
DatastoreOptions options = DatastoreOptions.newBuilder()
104-
.setProjectId("my-project-id") // must match project ID specified on remote machine
105-
.setHost("http://<hostname of machine>:<port>")
106-
.setCredentials(NoCredentials.getInstance())
107-
.build();
108-
Datastore localDatastore = options.getService();
109-
```
110-
111-
We recommend that you start the emulator on the remote machine using the [Google Cloud SDK](https://cloud.google.com/sdk/gcloud/reference/beta/emulators/datastore/) from command line, as shown below:
76+
1. [Install Cloud SDK](https://cloud.google.com/sdk/downloads)
11277

78+
2. Start the emulator
79+
```
80+
$ gcloud beta emulators datastore start
11381
```
114-
gcloud beta emulators datastore start --host-port <hostname of machine>:<port>
82+
To determine which host/port the emulator is running on:
83+
```
84+
$ gcloud beta emulators datastore env-init
85+
# Sample output:
86+
# export DATASTORE_EMULATOR_HOST=localhost:8759
87+
```
88+
3. Point your client to the emulator
89+
90+
```java
91+
DatastoreOptions options = DatastoreOptions.newBuilder()
92+
.setProjectId(DatastoreOptions.getDefaultProjectId())
93+
.setHost(System.getenv("DATASTORE_EMULATOR_HOST"))
94+
.setCredentials(NoCredentials.getInstance())
95+
.setRetrySettings(ServiceOptions.getNoRetrySettings())
96+
.build();
97+
Datastore datastore = options.getService();
11598
```
99+
4. Run your tests
116100

117101
### Testing code that uses DNS
118102

0 commit comments

Comments
 (0)