Commit Graph

544 Commits

Author SHA1 Message Date
Miek Gieben
6e3eec1e72 documention: test README snippets (#1043)
If a README has a corefile snippet that is annotated with `corefile`,
this test will parse the instance and checks the snippet is legal.
This means a) we will get better docs b) we know for sure everything
still parses.

The test parses everything in middleware/*/README.md, it does not check
for README presence, just Corefile snippets. The port used is 10053 and
overrides whatever port is set in the docs.

The secondary middleware was used as an example and adds two examples
that should parse.

failures show up as:

~~~
--- FAIL: TestReadme (0.04s)
	readme_test.go:50: Testing ../middleware/secondary/README.md, with 100 byte snippet
	readme_test.go:50: Testing ../middleware/secondary/README.md, with 93 byte snippet
	readme_test.go:53: Failed to start server for input "middleware/secondary: Corefile:3 - Error during parsing: unknown property 'transfeT'":
		. {
		    secondary example.net {
		        transfeT from 10.1.2.1
		        transfer to *
		    }
		}
FAIL
~~~
2017-09-10 19:52:15 +01:00
Miek Gieben
e4170150c7 mw/secondary: more tests in setup_test.go (#1039)
Improve the syntax tests for this middleware.
2017-09-09 11:11:07 +01:00
Thong Huynh
8e5d0a23fa Add EDNS0_SUBNET rewrite (#1022)
* Add EDNS0_SUBNET rewrite

* Fix review comments

* Update comment

* Fix according to review comments

* Add ResponseWriter6 instead of parameterized the existing ResponseWriter
2017-09-08 21:36:09 +01:00
Miek Gieben
bcdc99ab11 mw/etcd: fix 'fallthrough' (#1026)
* mw/etcd: revert 'add fallthrough'

This removes 'fallthrough' for *etcd* which is not needed. This was
added in 00f5c7797 but is totally not needed and creates backwards
incompat behavior even.

Thanks to @johnbelamaric for pointing this out in #925.

* remove here as well

* Revert "remove here as well"

This reverts commit 9d44397827.

* Revert "mw/etcd: revert 'add fallthrough'"

This reverts commit 0cfe3cb1ab.

* mw/{etcd,kubernetes}: use fallthrough correctly

reverts of reverts, will rebase and squash later.
2017-09-07 13:21:37 -04:00
Miek Gieben
594c6d7522 mw/federation: use original qname in all responses (#1033)
Maybe a fix for #1031 ?
2017-09-07 08:47:58 -04:00
Miek Gieben
48806fe8a6 mw/kubernetes: document stubDomain proxy (#1032)
Mention stubdomains in the documentation, give an example  and fix a few
typos.

Fixes #1028
2017-09-07 10:48:26 +01:00
Miek Gieben
9528777fc5 mw/autopath: correct type for type switch (#1029)
* mw/autopath: correct type for type switch

Use pointer to kubernetes as that is what is registered. Fix up
federation which had the same mistake.

* here
2017-09-06 18:28:41 -04:00
Miek Gieben
c514197d6b mw/federation: correct parse (#1027)
Fix parse error and add testcase when a ZONE is specified.

Fixes #1024
2017-09-06 22:25:05 +01:00
Miek Gieben
9452a0a3bc mw/kubernetes: test cleanup (#1020)
Move tests infra to look like all other middleware, and some small
cleanups.
2017-09-02 18:49:50 +02:00
Miek Gieben
9bcddc5c16 mw/proxy: simplify google code (#1019)
* mw/proxy: simplify google code

Minimize bootstrap code a bit, and block on the first resolve of the
google https endpont. Add more logging and include actual error in the
returned errors.

Also re-resolve every 120 seconds, instead of 300 (might eventually make
this an option).

* fix test
2017-09-02 18:43:52 +02:00
Brad Beam
3a96d1ab77 Cleaning up dnssec docs (#1016) 2017-09-02 18:41:52 +02:00
Yong Tang
4b14243e9b Add k8s tags to related tests (#1018)
, so that `make test` will pass by default.

Also fixed several ineffassign and golint issues.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2017-09-01 19:21:05 +02:00
Yong Tang
6493858893 Use context.TODO() in tests for go vet fix (#1017)
See #997 #1000.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2017-09-01 18:45:39 +02:00
Miek Gieben
778fb73177 mw/dnssec: improve docs (#1015)
* mw/dnssec: improve docs

Improve the docs: add example and details the perrils of having multiple
*dnssec* middlewares in one zone.

* better
2017-09-01 15:54:51 +02:00
varyoo
345dee82ed IP endpoint for dnstap (#1002)
* adds the option to log to a remote endpoint

* examples

* tests

* tcp:// or default to unix://

* cosmetic update

* bad naked returns
2017-09-01 14:07:21 +02:00
varyoo
c5efd45720 middleware/proxy: dnstap (#786)
* experimental dnstap support into proxy

* proxy reports dnstap errors

* refactoring

* add a message builder for less dnstap code

* msg lint

* context

* proxy by DNS: dnstap comments

* TapBuilder

* resolves conflict

* dnstap into ServeDNS

* testing

* more tests

* `go lint`

* doc update
2017-09-01 12:41:41 +02:00
Mohammed Naser
8f77566cdd Add test for SRV on root (#1010) 2017-09-01 08:55:09 +02:00
Miek Gieben
a08a4beec4 mw/dnssec: warn when keys don't sign zones (#1011)
fail startup when dnssec middleware has keys configured that can't be
used to sign any of the responses it should sign.

More tests added, including ones that actually trigger setup failures.
2017-09-01 08:52:13 +02:00
Miek Gieben
7b8cf9df90 mw/health: call Shutdown on FinalShutdown (#1003)
Reloading caddy won't kill the health handler. Only on final shutdown
we stop the handler.

Currently when reloading CoreDNS with -SIGUSR1 the health handler stops
answering - there is a test for this but it doesn't capture whole
process reloading, sadly. This PR keeps the handler alive during reloads
and only stops on process shutdown.
2017-08-29 21:23:13 +02:00
Miek Gieben
558f4bea41 mw/health: poll other middleware (#976)
This add the infrastructure to let other middleware report their health
status back to the health middleware. A health.Healther interface is
introduced and a middleware needs to implement that. A middleware
that supports healthchecks is statically configured.

Every second each supported middleware is queried and the global health
state is updated.

Actual tests have been disabled as no other middleware implements this
at the moment.
2017-08-27 13:33:38 -07:00
Miek Gieben
9c56805d38 mw/etcd: use context.TODO() in tests (#1000)
Go vet warning: fix use of context.

Fixes #997

Also make *auto*'s reload test less flaky by retrying
and then giving up.
2017-08-27 07:39:44 +01:00
Miek Gieben
4049ed4f4b mw/kubernetes: add configurable TTL (#995)
* mw/kubernetes: add configurable TTL

Add ttl option to kubernetes. This defaults to 5s but allows
configuration to go up to 3600.

Configure the tests so that a few actually check for the 5s, while the
rest use the TTL of 303 which is ignored by the checking code.

Fixes #935

* fix tests

* and more
2017-08-26 17:32:46 -07:00
Yong Tang
01f6e8cba5 Cleanup in go vet and misspell (#996)
Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2017-08-26 17:32:16 -07:00
varyoo
d5b636bca6 changes in Caddy caused mw/root tests to fail: 4cce8c7b6b (#990) 2017-08-26 16:58:04 +01:00
Miek Gieben
55dafe6f59 core: block CH queries earlier (#973)
block chaos queries, unless the chaos or proxy middleware is loaded. We
respond with REFUSED.

This removes the need for each middleware to do this class != ClassINET
if-then.

Also make config.Registry non-public.
2017-08-25 08:55:53 +01:00
Miek Gieben
e06863d2be mw/kubernetes: split up tests cases (#971)
Split up the handler_test in four files that all tests their specific
bits. Removed the CNAME sort as there was only 1 answer with a CNAME
and that was a single one.

See #942, this fixes (a bit) the tests in middleware.
2017-08-24 19:42:45 +01:00
Thong Huynh
3f05f7e6c0 Add set EDNS0 with variable substitution (#937)
* Add set EDNS0 with variable substitution

* Change variable from $ to {}. Un-export constants

* Update README

* Change getRuleData() to ruleData(); Change to use string match from regexp
2017-08-24 17:34:07 +01:00
Sandeep Rajan
5e9991556e Middleware/Kubernetes: Add RR check to K8s integration tests (#884) 2017-08-24 11:05:16 -04:00
Miek Gieben
9c62ddaa01 Small golint cleanup (#977)
* Small golint cleanup

Mostly docs in autopath.

* duh
2017-08-24 08:56:48 +01:00
Miek Gieben
10b7221067 mw/kubernetes: revert if-else for health (#970)
Do the return early and dedent the rest of the function.
2017-08-23 08:30:19 -07:00
Miek Gieben
4b105c761e Parse fix (#974)
* mw/kubernetes: add apex test

This adds small test case for apex queries: SOA and HINFO.

Fix (obvious) parse bug in parse.go.

* Test Ns request also here
2017-08-23 14:07:10 +01:00
Miek Gieben
61fc672e19 mw/kubernetes: remove kPod and kServices (#969)
Based up on: #939, but redone in a new PR with some cherry-picked
commits:
aacb91ef0b
5dc34247b7

This removes kPod and Kservice and creates []msg.Service from k.findPods
and k.findServices.

Updated few tests which I *think* are correct; they look correct to me.
2017-08-23 07:19:41 +01:00
Miek Gieben
7f5086e97a mw/kubernetes: don't export Pod-mode constants. (#959)
* mw/kubernetes: don't export Pod-mode constants.

* merged
2017-08-22 22:11:48 +01:00
Miek Gieben
12db6618c8 mw/kubernetes: resync to opts (#957)
* mw/kubernetes: resync to opts

Only used to initialize the cache that already has a dnsControlopts, so
remove it from the main kubernetes struct.

* Fix test

* mw/kubernetes: LabelSelector to options as well

Labels select is also only used for init. Don't carry it in the main
kubernetes struct.

* remove this test: can't happen

Caddyfile parser will only call setup when it sees kubernetes.

* erge gone wrong
2017-08-22 21:52:18 +01:00
Miek Gieben
6a4e69eb9f mw/kubernetes: Rewrite parseRequest and Readability improvements (#939)
* mw/kubernetes: rewrite parseRequest

Stop looking at the qtype in parseRequest and make k.Namespace a map.
Fallout from this is that pkg/strings as it is not used anymore. Also
add a few helper functions to make unexposed namespaces easier to see in
the code.

Add wildcard tests to the middleware tests.

* Fix tests

Add a whole bunch of comments to document what we are trying to do.

* This is now answered

* up coverage

* duh

* Update testcase

* Make it nodata
2017-08-22 12:44:42 -07:00
Miek Gieben
60d5e71a1a mw/*: updates docs about upstream (#968)
Upstream allows file structured like /etc/resolv.conf. Update docs.

Fixes #709
2017-08-22 14:56:00 +01:00
Miek Gieben
5604568655 mw/auto: increate setup coverage (#967)
Fixes #965
2017-08-22 14:52:20 +01:00
Miek Gieben
8931ede142 core: hide registerHandler (#964)
* core: hide registerHandler

Remove RegisterHandler and just make it implicit when we look at the
handler compilation step.

* Rename GetHandler to just Handler

Update callers and make auto check Hander in OnStartup.

* Up test coverage in erratic

* up test coverage
2017-08-22 14:21:42 +01:00
Miek Gieben
65009b5578 mw/autopath: a minimal bug section (#961)
Briefly highlight that autopath might return the wrong results to pods
in different namespaces.

Fixes #778
2017-08-21 08:57:54 +01:00
Miek Gieben
fe75e1b6f9 mw/file: add include test (#960)
$INCLUDE was fixed in miekg/dns, create tests in CoreDNS so that we know
we have the latest version.

Fixes #880
2017-08-21 08:20:17 +01:00
Miek Gieben
87eb0d39a4 Move nonwriter to mw/pkg/nonwriter (#948)
Make it its own package as shared between autopath and federation.

Fixes #933
2017-08-19 17:28:42 +01:00
Miek Gieben
02955d7594 Dns.join (#944)
* Add dnsutil.Join

* Create dnsutil.Join

Create Join helper function and move bits in the code over.
2017-08-19 15:22:09 +01:00
Miek Gieben
7c343982a6 backend.Records make it take request.Request (#943)
This is more general and aligns well with the other methods.
Also allows the kubernetes middleware to use it.

Fixes #940
2017-08-19 14:03:03 +01:00
Miek Gieben
627687b11f mw/kubernetes: remove zone from parseRequest (#938)
* mw/kubernetes: remove zone from parseRequest

State has the zone info as well, so don't need to have it in
parseRequest anymore.

* Fix up tests

* improve test coverage
2017-08-19 07:18:35 +01:00
Miek Gieben
f96cf27193 mw/federation: add federation back as separate mw for k8s (#929)
* mw/federaration

This PR add the federation back as a middleware to keep it more
contained from the main kubernetes code.

It also makes parseRequest less import and pushes this functionlity down
in the k.Entries. This minimizes (or tries to) the importance for the
qtype in the query. In the end the qtype checking should only happen
in ServeDNS - but for k8s this might proof difficult.

Numerous other cleanup in code and kubernetes tests.

* up test coverage
2017-08-18 14:45:20 +01:00
Miek Gieben
cc4e4a0626 mw/autopath: integration test with erratic (#930)
Add integration test with erratic. For this erratic now also returns an
autopath searchpath. This tests the whole chain; i.e registring a
searchfunction and calling that from autopath.

This tests does a autopathing domain and a non-autopathing one.
2017-08-18 12:57:23 +01:00
Miek Gieben
5a1875120c mw/kubernetes: add reverse test case (#932)
Add a non-arpa testcase to the reverse test.
2017-08-17 18:42:14 +01:00
Miek Gieben
7f46df6d27 tests: add SortAndCheck helper (#926)
There was quite some code duplication in a lot of tests to check if
an answer was considered Ok. Created a test.SortAndCheck helper function
that takes care of this.
2017-08-16 15:30:58 +01:00
John Belamaric
65b56248f0 Remove use of hostnames in upstreams (#927)
Only IP:Port or file name is allowed.
2017-08-16 10:00:32 -04:00
Miek Gieben
06644c2855 mw/kubernetes: add reverse_test.go (#922)
This PR adds a reverse tests that copies some of it from the main
integration test. This aids in local testing because you don't need
a full k8s setup running.

It does the most minimal testing, a successful return and a nodata
response that includes the SOA for in-addr.arpa.
2017-08-16 07:33:35 +01:00