aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorGravatar Chris O'Haver <cohaver@infoblox.com> 2017-02-02 16:51:42 -0500
committerGravatar John Belamaric <jbelamaric@infoblox.com> 2017-02-02 16:51:42 -0500
commit77f957d443f9c287abc1f315cebc0c725e9e4ba0 (patch)
treede37e9b305019bc47e66ee81e2aac90b05f0f1de /test
parent8beb1b2166102368ba5f19c7cf60850c555b915a (diff)
downloadcoredns-77f957d443f9c287abc1f315cebc0c725e9e4ba0.tar.gz
coredns-77f957d443f9c287abc1f315cebc0c725e9e4ba0.tar.zst
coredns-77f957d443f9c287abc1f315cebc0c725e9e4ba0.zip
k8s middleware add tests and docs update (#501)
* add cidrs opt * remove state data from middleware object * update k8s docs * Add integration tests * add unit tests for cidr and pods config * more README fixes, separate dev notes * adjust section headers * fix typo
Diffstat (limited to 'test')
-rw-r--r--test/kubernetes_test.go86
1 files changed, 85 insertions, 1 deletions
diff --git a/test/kubernetes_test.go b/test/kubernetes_test.go
index 9e6be8d28..530051f0a 100644
--- a/test/kubernetes_test.go
+++ b/test/kubernetes_test.go
@@ -255,6 +255,66 @@ var dnsTestCasesPodsVerified = []test.Case{
},
}
+var dnsTestCasesCidrReverseZone = []test.Case{
+ {
+ Qname: "123.0.0.10.in-addr.arpa.", Qtype: dns.TypePTR,
+ Rcode: dns.RcodeSuccess,
+ Answer: []dns.RR{},
+ },
+ {
+ Qname: "100.0.0.10.in-addr.arpa.", Qtype: dns.TypePTR,
+ Rcode: dns.RcodeSuccess,
+ Answer: []dns.RR{
+ test.PTR("100.0.0.10.in-addr.arpa. 303 IN PTR svc-1-a.test-1.svc.cluster.local."),
+ },
+ },
+ {
+ Qname: "110.0.0.10.in-addr.arpa.", Qtype: dns.TypePTR,
+ Rcode: dns.RcodeSuccess,
+ Answer: []dns.RR{
+ test.PTR("115.0.0.10.in-addr.arpa. 303 IN PTR svc-1-b.test-1.svc.cluster.local."),
+ },
+ },
+ {
+ Qname: "115.0.0.10.in-addr.arpa.", Qtype: dns.TypePTR,
+ Rcode: dns.RcodeSuccess,
+ Answer: []dns.RR{
+ test.PTR("115.0.0.10.in-addr.arpa. 303 IN PTR svc-c.test-1.svc.cluster.local."),
+ },
+ },
+}
+
+var dnsTestCasesPartialCidrReverseZone = []test.Case{
+ {
+ // In exposed range, record not present = OK + No data
+ Qname: "99.0.0.10.in-addr.arpa.", Qtype: dns.TypePTR,
+ Rcode: dns.RcodeSuccess,
+ Answer: []dns.RR{},
+ },
+ {
+ // In exposed range, record present = OK + Data
+ Qname: "100.0.0.10.in-addr.arpa.", Qtype: dns.TypePTR,
+ Rcode: dns.RcodeSuccess,
+ Answer: []dns.RR{
+ test.PTR("100.0.0.10.in-addr.arpa. 303 IN PTR svc-1-a.test-1.svc.cluster.local."),
+ },
+ },
+ {
+ // In exposed range, record present = OK + Data
+ Qname: "110.0.0.10.in-addr.arpa.", Qtype: dns.TypePTR,
+ Rcode: dns.RcodeSuccess,
+ Answer: []dns.RR{
+ test.PTR("115.0.0.10.in-addr.arpa. 303 IN PTR svc-1-b.test-1.svc.cluster.local."),
+ },
+ },
+ {
+ // Out of exposed range, record present = pass to next middleware (not existing in test) = FAIL
+ Qname: "115.0.0.10.in-addr.arpa.", Qtype: dns.TypePTR,
+ Rcode: dns.RcodeServerFailure,
+ Answer: []dns.RR{},
+ },
+}
+
func createTestServer(t *testing.T, corefile string) (*caddy.Instance, string) {
server, err := CoreDNSServer(corefile)
if err != nil {
@@ -275,7 +335,7 @@ func doIntegrationTests(t *testing.T, corefile string, testCases []test.Case) {
// Work-around for timing condition that results in no-data being returned in
// test environment.
- time.Sleep(5 * time.Second)
+ time.Sleep(1 * time.Second)
for _, tc := range testCases {
@@ -340,3 +400,27 @@ func TestKubernetesIntegrationPodsVerified(t *testing.T) {
`
doIntegrationTests(t, corefile, dnsTestCasesPodsVerified)
}
+
+func TestKubernetesIntegrationCidrReverseZone(t *testing.T) {
+ corefile :=
+ `.:0 {
+ kubernetes cluster.local {
+ endpoint http://localhost:8080
+ namespaces test-1
+ cidrs 10.0.0.0/24
+ }
+`
+ doIntegrationTests(t, corefile, dnsTestCasesCidrReverseZone)
+}
+
+func TestKubernetesIntegrationPartialCidrReverseZone(t *testing.T) {
+ corefile :=
+ `.:0 {
+ kubernetes cluster.local {
+ endpoint http://localhost:8080
+ namespaces test-1
+ cidrs 10.0.0.96/28 10.0.0.120/32
+ }
+`
+ doIntegrationTests(t, corefile, dnsTestCasesPartialCidrReverseZone)
+}