diff options
author | 2017-08-24 11:05:16 -0400 | |
---|---|---|
committer | 2017-08-24 11:05:16 -0400 | |
commit | 5e9991556e9edb403a12a83372aba46ace42b869 (patch) | |
tree | 08c85910e2a5af3c9cda5d29dd20a7f8d9bf2cb4 /middleware | |
parent | f901b0cefa1475c83e6b6dc859ef35675feb41e1 (diff) | |
download | coredns-5e9991556e9edb403a12a83372aba46ace42b869.tar.gz coredns-5e9991556e9edb403a12a83372aba46ace42b869.tar.zst coredns-5e9991556e9edb403a12a83372aba46ace42b869.zip |
Middleware/Kubernetes: Add RR check to K8s integration tests (#884)
Diffstat (limited to 'middleware')
-rw-r--r-- | middleware/kubernetes/handler_test.go | 15 | ||||
-rw-r--r-- | middleware/test/helpers.go | 19 |
2 files changed, 20 insertions, 14 deletions
diff --git a/middleware/kubernetes/handler_test.go b/middleware/kubernetes/handler_test.go index 292ffdf3a..d5345215d 100644 --- a/middleware/kubernetes/handler_test.go +++ b/middleware/kubernetes/handler_test.go @@ -235,19 +235,8 @@ func runServeDNSTests(ctx context.Context, t *testing.T, dnsTestCases map[string } // Before sorting, make sure that CNAMES do not appear after their target records - for i, c := range resp.Answer { - if c.Header().Rrtype != dns.TypeCNAME { - continue - } - for _, a := range resp.Answer[:i] { - if a.Header().Name != c.(*dns.CNAME).Target { - continue - } - t.Errorf("%v: CNAME found after target record\n", testname) - t.Logf("%v Received:\n %v\n", testname, resp) - - } - } + test.CNAMEOrder(t, resp) + test.SortAndCheck(t, resp, tc) } } diff --git a/middleware/test/helpers.go b/middleware/test/helpers.go index 2074f46c2..35316dd38 100644 --- a/middleware/test/helpers.go +++ b/middleware/test/helpers.go @@ -13,7 +13,7 @@ type sect int const ( // Answer is the answer section in an Msg. Answer sect = iota - // Ns is the authrotitative section in an Msg. + // Ns is the authoritative section in an Msg. Ns // Extra is the additional section in an Msg. Extra @@ -264,6 +264,23 @@ func Section(t *testing.T, tc Case, sec sect, rr []dns.RR) bool { return true } +// CNAMEOrder makes sure that CNAMES do not appear after their target records +func CNAMEOrder(t *testing.T, res *dns.Msg) { + for i, c := range res.Answer { + if c.Header().Rrtype != dns.TypeCNAME { + continue + } + for _, a := range res.Answer[:i] { + if a.Header().Name != c.(*dns.CNAME).Target { + continue + } + t.Errorf("CNAME found after target record\n") + t.Logf("%v\n", res) + + } + } +} + // SortAndCheck sorts resp and the checks the header and three sections against the testcase in tc. func SortAndCheck(t *testing.T, resp *dns.Msg, tc Case) { sort.Sort(RRSet(resp.Answer)) |