From f9be836e315766021e37ed6bfec5985ef3fef52c Mon Sep 17 00:00:00 2001 From: Jeffrey Cafferata Date: Sat, 28 Jan 2023 17:07:32 +0100 Subject: [PATCH] DOCS: Split out debugging / integration Tests (#2007) --- documentation/SUMMARY.md | 2 ++ documentation/debugging-with-dlv.md | 15 ++++++++ .../integration-tests.md | 36 +++++++++---------- 3 files changed, 33 insertions(+), 20 deletions(-) create mode 100644 documentation/debugging-with-dlv.md rename integrationTest/readme.md => documentation/integration-tests.md (75%) diff --git a/documentation/SUMMARY.md b/documentation/SUMMARY.md index 0eb5202b4..9d149cd97 100644 --- a/documentation/SUMMARY.md +++ b/documentation/SUMMARY.md @@ -152,6 +152,8 @@ * [Creating new DNS Resource Types (rtypes)](adding-new-rtypes.md) * [TXT record testing](testing-txt-records.md) * [Unit Testing DNS Data](unittests.md) +* [Integration Tests](integration-tests.md) +* [Debugging with dlv](debugging-with-dlv.md) * [DNSControl is an opinionated system](opinions.md) ## Release diff --git a/documentation/debugging-with-dlv.md b/documentation/debugging-with-dlv.md new file mode 100644 index 000000000..35d87e1cd --- /dev/null +++ b/documentation/debugging-with-dlv.md @@ -0,0 +1,15 @@ +## Debugger + +Test a particular function: + +```shell +dlv test github.com/StackExchange/dnscontrol/v3/pkg/diff2 -- -test.run Test_analyzeByRecordSet + ^^^^^^^^^ + Assumes you are in the pkg/diff2 directory. +``` + +Debug the integration tests: + +```shell +dlv test github.com/StackExchange/dnscontrol/v3/integrationTest -- -test.v -test.run ^TestDNSProviders -verbose -provider NAMEDOTCOM -start 1 -end 1 -diff2 +``` diff --git a/integrationTest/readme.md b/documentation/integration-tests.md similarity index 75% rename from integrationTest/readme.md rename to documentation/integration-tests.md index 490462740..dd068edaa 100644 --- a/integrationTest/readme.md +++ b/documentation/integration-tests.md @@ -17,42 +17,38 @@ For each step, it will run the config once and expect changes. It will run it ag Example: -```bash +```shell egrep ROUTE53 providers.json +``` + +```text "KeyId": "$ROUTE53_KEY_ID", "SecretKey": "$ROUTE53_KEY", "domain": "$ROUTE53_DOMAIN" +``` + +```shell export ROUTE53_KEY_ID="redacted" export ROUTE53_KEY="also redacted" export ROUTE53_DOMAIN="testdomain.tld" +``` + +```shell go test -v -verbose -provider ROUTE53 ``` -WARNING: The records in the test domain will be deleted. Only use +{% hint style="warning" %} +**WARNING**: The records in the test domain will be deleted. Only use a domain that is not used in production. Some providers have a way to run tests on domains that aren't registered (often a test environment or a side-effect of the company not being a registrar). In other cases we use a domain we squat on, or we register a domain called `dnscontrol-$provider.com` just for testing. +{% endhint %} -ProTip: If you run these tests frequently (and we hope you do), you +{% hint style="info" %} +**ProTip**: If you run these tests frequently (and we hope you do), you should create a script that you can `source` to set these variables. Be careful not to check this script into Git since it contains credentials. - -## Debugger - -Test a particular function: - -``` -dlv test github.com/StackExchange/dnscontrol/v3/pkg/diff2 -- -test.run Test_analyzeByRecordSet - ^^^^^^^^^ - Assumes you are in the pkg/diff2 directory. -``` - -Debug the integration tests: - - -``` -dlv test github.com/StackExchange/dnscontrol/v3/integrationTest -- -test.v -test.run ^TestDNSProviders -verbose -provider NAMEDOTCOM -start 1 -end 1 -diff2 -``` +{% endhint %}