Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added DNS helper to testing documentation. #926

Merged
merged 4 commits into from
Apr 14, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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