From 88aecea4cec6d40eaed895723fa39cbfc3e63815 Mon Sep 17 00:00:00 2001 From: Martin Derka Date: Thu, 14 Apr 2016 14:18:50 -0700 Subject: [PATCH 1/4] Added DNS to testing documentation. --- TESTING.md | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/TESTING.md b/TESTING.md index aecd6140b79f..3c4bb967f2eb 100644 --- a/TESTING.md +++ b/TESTING.md @@ -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 : ``` +### Testing code that uses DNS + +#### On your machine + +You can test against a temporary 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 delay of `delay` milliseconds. + +2. In your program, create and use a DNS service object whose host is set to `localhost` at the appropriate port. 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: From e9f264a4570aac9bc75fff91403a0c0bbd7549eb Mon Sep 17 00:00:00 2001 From: Martin Derka Date: Thu, 14 Apr 2016 15:20:31 -0700 Subject: [PATCH 2/4] Rephrased the text. --- TESTING.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/TESTING.md b/TESTING.md index 3c4bb967f2eb..05b694368a5b 100644 --- a/TESTING.md +++ b/TESTING.md @@ -58,7 +58,7 @@ gcloud beta emulators datastore start --host-port : #### On your machine -You can test against a temporary local DNS by following these steps: +You can test against a 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: @@ -72,7 +72,7 @@ You can test against a temporary local DNS by following these steps: The `delay` parameter determines if change requests should be processed synchronously (value `0`) or in a separate thread with a delay of `delay` milliseconds. -2. In your program, create and use a DNS service object whose host is set to `localhost` at the appropriate port. For example: +2. In your program, create and use a DNS service object by using the `options()` of `LocalDnsHelper`. For example: ```java Dns dns = LocalDnsHelper.options().service(); @@ -118,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 a 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: From ca2e9278aee240ce2f101b56a891a0bc41d01ec7 Mon Sep 17 00:00:00 2001 From: Martin Derka Date: Thu, 14 Apr 2016 16:30:11 -0700 Subject: [PATCH 3/4] Reworded text. --- TESTING.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/TESTING.md b/TESTING.md index 05b694368a5b..883718621a8e 100644 --- a/TESTING.md +++ b/TESTING.md @@ -58,7 +58,7 @@ gcloud beta emulators datastore start --host-port : #### On your machine -You can test against a in-memory local DNS by following these steps: +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: @@ -70,9 +70,9 @@ You can test against a in-memory local DNS by following these steps: 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 delay of `delay` milliseconds. + (value `0`) or in a separate thread with a minimum of delay of `delay` milliseconds. -2. In your program, create and use a DNS service object by using the `options()` of `LocalDnsHelper`. For example: +2. In your program, create the DNS service by using helper's `options()` method. For example: ```java Dns dns = LocalDnsHelper.options().service(); @@ -118,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 in-memory 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: From 6fe3b43e835710c6f07db75d9a2b6348ea641ab6 Mon Sep 17 00:00:00 2001 From: Martin Derka Date: Thu, 14 Apr 2016 16:33:07 -0700 Subject: [PATCH 4/4] Missing article. --- TESTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TESTING.md b/TESTING.md index 883718621a8e..7ae34db4c4f1 100644 --- a/TESTING.md +++ b/TESTING.md @@ -72,7 +72,7 @@ You can test against an in-memory local DNS by following these steps: 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 helper's `options()` method. For example: +2. In your program, create the DNS service by using the helper's `options()` method. For example: ```java Dns dns = LocalDnsHelper.options().service();