Skip to content

Commit 5b5d511

Browse files
mderkaaozarov
authored andcommitted
---
yaml --- r: 3897 b: refs/heads/pubsub-alpha c: 527c656 h: refs/heads/master i: 3895: 3b249cb
1 parent fc1f7ec commit 5b5d511

2 files changed

Lines changed: 36 additions & 2 deletions

File tree

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 36a62ef856d199f8efd09501b5ba65c422c01f23
33
refs/heads/travis: e21ee7b88a5edc3f3d8c71f90c3fc32abf7e8dd6
44
refs/heads/gh-pages: 7406918e071dd2c5677a638ae2a06e7592b6542c
5-
refs/heads/pubsub-alpha: 7d7b799c4ab14b6c0fd90520bc1060533607a1fe
5+
refs/heads/pubsub-alpha: 527c656bcb783a8d05dbfbd4f36d743dc8e7cc14
66
refs/heads/update-datastore: 47aae517c2cb33f1dccd909adaced73ec9d0f4df
77
refs/tags/0.0.9: 22f1839238f66c39e67ed4dfdcd273b1ae2e8444
88
refs/tags/v0.0.10: 207ebd2a3472fddee69fe1298eb90429e3306efd

branches/pubsub-alpha/TESTING.md

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,40 @@ We recommend that you start the emulator on the remote machine using the [Google
5454
gcloud beta emulators datastore start --host-port <hostname of machine>:<port>
5555
```
5656

57+
### Testing code that uses DNS
58+
59+
#### On your machine
60+
61+
You can test against an in-memory local DNS by following these steps:
62+
63+
1. Before running your testing code, start the DNS emulator `LocalDnsHelper`. This can be done as follows:
64+
65+
```java
66+
long delay = 0;
67+
LocalDnsHelper helper = LocalDnsHelper.create(delay);
68+
helper.start();
69+
```
70+
71+
This will spawn a server thread that listens to `localhost` at an ephemeral port for DNS requests.
72+
The `delay` parameter determines if change requests should be processed synchronously
73+
(value `0`) or in a separate thread with a minimum of delay of `delay` milliseconds.
74+
75+
2. In your program, create the DNS service by using the helper's `options()` method. For example:
76+
77+
```java
78+
Dns dns = LocalDnsHelper.options().service();
79+
```
80+
81+
3. Run your tests.
82+
83+
4. Stop the DNS emulator.
84+
85+
```java
86+
helper.stop();
87+
```
88+
89+
This method will block until the server thread has been terminated.
90+
5791
### Testing code that uses Storage
5892

5993
Currently, there isn't an emulator for Google Cloud Storage, so an alternative is to create a test project. `RemoteStorageHelper` contains convenience methods to make setting up and cleaning up the test project easier. To use this class, follow the steps below:
@@ -84,7 +118,7 @@ Here is an example that clears the bucket created in Step 3 with a timeout of 5
84118

85119
#### On your machine
86120

87-
You can test against a temporary local Resource Manager by following these steps:
121+
You can test against an in-memory local Resource Manager by following these steps:
88122

89123
1. Before running your testing code, start the Resource Manager emulator `LocalResourceManagerHelper`. This can be done as follows:
90124

0 commit comments

Comments
 (0)