aboutsummaryrefslogtreecommitdiff
path: root/test/server_test.go
diff options
context:
space:
mode:
authorGravatar Chris O'Haver <cohaver@infoblox.com> 2021-07-09 11:12:06 -0400
committerGravatar GitHub <noreply@github.com> 2021-07-09 17:12:06 +0200
commitbdaa2a55271f88e2bf94ee146e90562f8aa57b34 (patch)
tree8f5762b28b9faa96fda1b0e7f414fecf50a23c00 /test/server_test.go
parent2a61309cad794848e247e2d3de7369b96e12efd1 (diff)
downloadcoredns-bdaa2a55271f88e2bf94ee146e90562f8aa57b34.tar.gz
coredns-bdaa2a55271f88e2bf94ee146e90562f8aa57b34.tar.zst
coredns-bdaa2a55271f88e2bf94ee146e90562f8aa57b34.zip
Share plugins among zones in the same server block (#4593)
* share plugins among zones in the same server block Signed-off-by: Chris O'Haver <cohaver@infoblox.com> * update caddy dep Signed-off-by: Chris O'Haver <cohaver@infoblox.com> * simp code Signed-off-by: Chris O'Haver <cohaver@infoblox.com> * copy ListenHosts and Debug from first config Signed-off-by: Chris O'Haver <cohaver@infoblox.com> * copy tls configs from first config Signed-off-by: Chris O'Haver <cohaver@infoblox.com> * add test to validate debug setting is replicated to all configs in block Signed-off-by: Chris O'Haver <cohaver@infoblox.com> * stop server Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
Diffstat (limited to 'test/server_test.go')
-rw-r--r--test/server_test.go31
1 files changed, 31 insertions, 0 deletions
diff --git a/test/server_test.go b/test/server_test.go
index c58915ee7..54e44722d 100644
--- a/test/server_test.go
+++ b/test/server_test.go
@@ -1,7 +1,11 @@
package test
import (
+ "reflect"
"testing"
+ "unsafe"
+
+ "github.com/coredns/coredns/core/dnsserver"
"github.com/miekg/dns"
)
@@ -107,3 +111,30 @@ func TestReverseExpansion(t *testing.T) {
t.Errorf("Expected 0 RRs in additional section, got %d", len(r.Extra))
}
}
+
+func TestMultiZoneBlockConfigs(t *testing.T) {
+ corefile := `.:40000 .:40001 .:40002 {
+ debug
+ }`
+
+ server, err := CoreDNSServer(corefile)
+ defer server.Stop()
+
+ if err != nil {
+ t.Fatalf("Could not get CoreDNS serving instance: %s", err)
+ }
+
+ // unsafe reflection to read unexported fields "context" and "configs" within context
+ ctxVal := reflect.ValueOf(server).Elem().FieldByName("context")
+ ctxVal2 := reflect.NewAt(ctxVal.Type(), unsafe.Pointer(ctxVal.UnsafeAddr())).Elem()
+ configs := reflect.ValueOf(ctxVal2.Interface()).Elem().FieldByName("configs")
+ configs2 := reflect.NewAt(configs.Type(), unsafe.Pointer(configs.UnsafeAddr())).Elem()
+
+ for i := 0; i < 3; i++ {
+ v := configs2.Index(i)
+ config := v.Interface().(*dnsserver.Config)
+ if !config.Debug {
+ t.Fatalf("Debug was not set for %s://%s:%s", config.Transport, config.Zone, config.Port)
+ }
+ }
+}