Skip to content

Commit 8c13a1f

Browse files
mderkaaozarov
authored andcommitted
---
yaml --- r: 4299 b: refs/heads/gcs-nio c: 527c656 h: refs/heads/master i: 4297: 9c0ca89 4295: 8eaccce
1 parent 74f1e32 commit 8c13a1f

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
@@ -11,7 +11,7 @@ refs/tags/v0.0.12: 2fd8066e891fb3dfea69b65f6bf6461db79342b9
1111
refs/heads/compute-alpha: 969cba2627f1d53d352cc4a5ffe0879dacf65e6c
1212
refs/heads/dns-alpha: 2f90e7e338349287ace33375896907af0f032ca1
1313
refs/heads/dns-alpha-batch: 17442b07867021b85d0452f5f3eda29a3413288f
14-
refs/heads/gcs-nio: 7d7b799c4ab14b6c0fd90520bc1060533607a1fe
14+
refs/heads/gcs-nio: 527c656bcb783a8d05dbfbd4f36d743dc8e7cc14
1515
refs/heads/logging-alpha: db5312bffa7fccac194f6a7feb8cc3066de16aff
1616
refs/tags/v0.1.0: a615317f7424ed58621b1f65d5c4d8cbbe8a6ed8
1717
refs/tags/v0.1.1: 7a7f6985fe465e9dd6a075af55493f42b4933be0

branches/gcs-nio/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)