Skip to content

Commit

Permalink
Added DNS helper to testing documentation. (#926)
Browse files Browse the repository at this point in the history
Added DNS to testing documentation.
  • Loading branch information
mderka authored and aozarov committed Apr 14, 2016
1 parent 7d7b799 commit 527c656
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion TESTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,40 @@ We recommend that you start the emulator on the remote machine using the [Google
gcloud beta emulators datastore start --host-port <hostname of machine>:<port>
```

### Testing code that uses DNS

#### On your machine

You can test against an in-memory local DNS by following these steps:

1. Before running your testing code, start the DNS emulator `LocalDnsHelper`. This can be done as follows:

```java
long delay = 0;
LocalDnsHelper helper = LocalDnsHelper.create(delay);
helper.start();
```

This will spawn a server thread that listens to `localhost` at an ephemeral port for DNS requests.
The `delay` parameter determines if change requests should be processed synchronously
(value `0`) or in a separate thread with a minimum of delay of `delay` milliseconds.

2. In your program, create the DNS service by using the helper's `options()` method. For example:
```java
Dns dns = LocalDnsHelper.options().service();
```
3. Run your tests.
4. Stop the DNS emulator.
```java
helper.stop();
```
This method will block until the server thread has been terminated.
### Testing code that uses Storage
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:
Expand Down Expand Up @@ -84,7 +118,7 @@ Here is an example that clears the bucket created in Step 3 with a timeout of 5
#### On your machine
You can test against a temporary local Resource Manager by following these steps:
You can test against an in-memory local Resource Manager by following these steps:
1. Before running your testing code, start the Resource Manager emulator `LocalResourceManagerHelper`. This can be done as follows:
Expand Down

0 comments on commit 527c656

Please sign in to comment.