Skip to content

Commit 8f1f6ba

Browse files
mderkaaozarov
authored andcommitted
---
yaml --- r: 7205 b: refs/heads/tswast-patch-1 c: 527c656 h: refs/heads/master i: 7203: 89cfe46
1 parent f09013d commit 8f1f6ba

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
@@ -57,5 +57,5 @@ refs/tags/v0.18.0: 9d193c4c4b9d1c6f21515dd8e50836b9194ec9bb
5757
refs/tags/v0.19.0: e67b56e4d8dad5f9a7b38c9b2107c23c828f2ed5
5858
refs/tags/v0.20.0: 839f7fb7156535146aa1cb2c5aadd8d375d854e8
5959
refs/tags/v0.20.1: 370471f437f1f4f68a11e068df5cd6bf39edb1fa
60-
refs/heads/tswast-patch-1: 7d7b799c4ab14b6c0fd90520bc1060533607a1fe
60+
refs/heads/tswast-patch-1: 527c656bcb783a8d05dbfbd4f36d743dc8e7cc14
6161
refs/heads/pubsub-streaming-pull: 19262b752ee874eb2ca3b950eb2aef44d5a5267b

branches/tswast-patch-1/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)