Fix mixed indentation within tests (#3855)
Signed-off-by: Ambrose Chua <ambrose@chua.family>
This commit is contained in:
parent
74eabe90e0
commit
ed1f42cf56
31 changed files with 284 additions and 305 deletions
|
@ -22,8 +22,7 @@ func TestAuto(t *testing.T) {
|
||||||
directory ` + tmpdir + ` db\.(.*) {1}
|
directory ` + tmpdir + ` db\.(.*) {1}
|
||||||
reload 1s
|
reload 1s
|
||||||
}
|
}
|
||||||
}
|
}`
|
||||||
`
|
|
||||||
|
|
||||||
i, udp, _, err := CoreDNSServerAndPorts(corefile)
|
i, udp, _, err := CoreDNSServerAndPorts(corefile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -82,8 +81,7 @@ func TestAutoNonExistentZone(t *testing.T) {
|
||||||
reload 1s
|
reload 1s
|
||||||
}
|
}
|
||||||
errors stdout
|
errors stdout
|
||||||
}
|
}`
|
||||||
`
|
|
||||||
|
|
||||||
i, err := CoreDNSServer(corefile)
|
i, err := CoreDNSServer(corefile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -121,8 +119,7 @@ func TestAutoAXFR(t *testing.T) {
|
||||||
reload 1s
|
reload 1s
|
||||||
transfer to *
|
transfer to *
|
||||||
}
|
}
|
||||||
}
|
}`
|
||||||
`
|
|
||||||
|
|
||||||
i, err := CoreDNSServer(corefile)
|
i, err := CoreDNSServer(corefile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -161,8 +158,8 @@ func TestAutoAXFR(t *testing.T) {
|
||||||
|
|
||||||
const zoneContent = `; testzone
|
const zoneContent = `; testzone
|
||||||
@ IN SOA sns.dns.icann.org. noc.dns.icann.org. 2016082534 7200 3600 1209600 3600
|
@ IN SOA sns.dns.icann.org. noc.dns.icann.org. 2016082534 7200 3600 1209600 3600
|
||||||
NS a.iana-servers.net.
|
IN NS a.iana-servers.net.
|
||||||
NS b.iana-servers.net.
|
IN NS b.iana-servers.net.
|
||||||
|
|
||||||
www IN A 127.0.0.1
|
www IN A 127.0.0.1
|
||||||
`
|
`
|
||||||
|
|
|
@ -18,8 +18,8 @@ func TestLookupCache(t *testing.T) {
|
||||||
|
|
||||||
corefile := `example.org:0 {
|
corefile := `example.org:0 {
|
||||||
file ` + name + `
|
file ` + name + `
|
||||||
}
|
}`
|
||||||
`
|
|
||||||
i, udp, _, err := CoreDNSServerAndPorts(corefile)
|
i, udp, _, err := CoreDNSServerAndPorts(corefile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Could not get CoreDNS serving instance: %s", err)
|
t.Fatalf("Could not get CoreDNS serving instance: %s", err)
|
||||||
|
@ -30,8 +30,8 @@ func TestLookupCache(t *testing.T) {
|
||||||
corefile = `example.org:0 {
|
corefile = `example.org:0 {
|
||||||
forward . ` + udp + `
|
forward . ` + udp + `
|
||||||
cache 10
|
cache 10
|
||||||
}
|
}`
|
||||||
`
|
|
||||||
i, udp, _, err = CoreDNSServerAndPorts(corefile)
|
i, udp, _, err = CoreDNSServerAndPorts(corefile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Could not get CoreDNS serving instance: %s", err)
|
t.Fatalf("Could not get CoreDNS serving instance: %s", err)
|
||||||
|
|
|
@ -13,8 +13,7 @@ import (
|
||||||
func TestChaos(t *testing.T) {
|
func TestChaos(t *testing.T) {
|
||||||
corefile := `.:0 {
|
corefile := `.:0 {
|
||||||
chaos
|
chaos
|
||||||
}
|
}`
|
||||||
`
|
|
||||||
|
|
||||||
i, udp, _, err := CoreDNSServerAndPorts(corefile)
|
i, udp, _, err := CoreDNSServerAndPorts(corefile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -36,8 +36,7 @@ func TestLookupDS(t *testing.T) {
|
||||||
|
|
||||||
corefile := `miek.nl:0 {
|
corefile := `miek.nl:0 {
|
||||||
file ` + name + `
|
file ` + name + `
|
||||||
}
|
}`
|
||||||
`
|
|
||||||
|
|
||||||
i, udp, _, err := CoreDNSServerAndPorts(corefile)
|
i, udp, _, err := CoreDNSServerAndPorts(corefile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -9,8 +9,7 @@ import (
|
||||||
func TestEDNS0(t *testing.T) {
|
func TestEDNS0(t *testing.T) {
|
||||||
corefile := `.:0 {
|
corefile := `.:0 {
|
||||||
whoami
|
whoami
|
||||||
}
|
}`
|
||||||
`
|
|
||||||
|
|
||||||
i, udp, _, err := CoreDNSServerAndPorts(corefile)
|
i, udp, _, err := CoreDNSServerAndPorts(corefile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -31,8 +31,8 @@ google.com. IN A 172.217.25.110
|
||||||
|
|
||||||
corefile := `.:0 {
|
corefile := `.:0 {
|
||||||
file ` + path + `
|
file ` + path + `
|
||||||
}
|
}`
|
||||||
`
|
|
||||||
i, udp, _, err := CoreDNSServerAndPorts(corefile)
|
i, udp, _, err := CoreDNSServerAndPorts(corefile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Could not get proxy target CoreDNS serving instance: %s", err)
|
t.Fatalf("Could not get proxy target CoreDNS serving instance: %s", err)
|
||||||
|
@ -49,8 +49,8 @@ func TestLookupAutoPathErratic(t *testing.T) {
|
||||||
autopath @erratic
|
autopath @erratic
|
||||||
forward . ` + proxyPath + `
|
forward . ` + proxyPath + `
|
||||||
debug
|
debug
|
||||||
}
|
}`
|
||||||
`
|
|
||||||
i, udp, _, err := CoreDNSServerAndPorts(corefile)
|
i, udp, _, err := CoreDNSServerAndPorts(corefile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Could not get CoreDNS serving instance: %s", err)
|
t.Fatalf("Could not get CoreDNS serving instance: %s", err)
|
||||||
|
@ -94,8 +94,8 @@ func TestAutoPathErraticNotLoaded(t *testing.T) {
|
||||||
autopath @erratic
|
autopath @erratic
|
||||||
forward . ` + proxyPath + `
|
forward . ` + proxyPath + `
|
||||||
debug
|
debug
|
||||||
}
|
}`
|
||||||
`
|
|
||||||
i, err := CoreDNSServer(corefile)
|
i, err := CoreDNSServer(corefile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Could not get CoreDNS serving instance: %s", err)
|
t.Fatalf("Could not get CoreDNS serving instance: %s", err)
|
||||||
|
|
|
@ -19,7 +19,7 @@ func TestEtcdCache(t *testing.T) {
|
||||||
path /skydns
|
path /skydns
|
||||||
}
|
}
|
||||||
cache skydns.test
|
cache skydns.test
|
||||||
}`
|
}`
|
||||||
|
|
||||||
ex, udp, _, err := CoreDNSServerAndPorts(corefile)
|
ex, udp, _, err := CoreDNSServerAndPorts(corefile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -14,7 +14,7 @@ func TestEtcdCredentials(t *testing.T) {
|
||||||
etcd skydns.test {
|
etcd skydns.test {
|
||||||
path /skydns
|
path /skydns
|
||||||
}
|
}
|
||||||
}`
|
}`
|
||||||
|
|
||||||
ex, _, _, err := CoreDNSServerAndPorts(corefile)
|
ex, _, _, err := CoreDNSServerAndPorts(corefile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -49,7 +49,7 @@ func TestEtcdStubAndProxyLookup(t *testing.T) {
|
||||||
fallthrough
|
fallthrough
|
||||||
}
|
}
|
||||||
forward . 8.8.8.8:53
|
forward . 8.8.8.8:53
|
||||||
}`
|
}`
|
||||||
|
|
||||||
ex, udp, _, err := CoreDNSServerAndPorts(corefile)
|
ex, udp, _, err := CoreDNSServerAndPorts(corefile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -20,8 +20,8 @@ func TestZoneExternalCNAMELookupWithoutProxy(t *testing.T) {
|
||||||
// Corefile with for example without proxy section.
|
// Corefile with for example without proxy section.
|
||||||
corefile := `example.org:0 {
|
corefile := `example.org:0 {
|
||||||
file ` + name + `
|
file ` + name + `
|
||||||
}
|
}`
|
||||||
`
|
|
||||||
i, udp, _, err := CoreDNSServerAndPorts(corefile)
|
i, udp, _, err := CoreDNSServerAndPorts(corefile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Could not get CoreDNS serving instance: %s", err)
|
t.Fatalf("Could not get CoreDNS serving instance: %s", err)
|
||||||
|
@ -55,8 +55,8 @@ func TestZoneExternalCNAMELookupWithProxy(t *testing.T) {
|
||||||
upstream
|
upstream
|
||||||
}
|
}
|
||||||
forward . 8.8.8.8 8.8.4.4
|
forward . 8.8.8.8 8.8.4.4
|
||||||
}
|
}`
|
||||||
`
|
|
||||||
i, udp, _, err := CoreDNSServerAndPorts(corefile)
|
i, udp, _, err := CoreDNSServerAndPorts(corefile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Could not get CoreDNS serving instance: %s", err)
|
t.Fatalf("Could not get CoreDNS serving instance: %s", err)
|
||||||
|
|
|
@ -18,16 +18,16 @@ func TestZoneReload(t *testing.T) {
|
||||||
defer rm()
|
defer rm()
|
||||||
|
|
||||||
// Corefile with two stanzas
|
// Corefile with two stanzas
|
||||||
corefile := `example.org:0 {
|
corefile := `
|
||||||
|
example.org:0 {
|
||||||
file ` + name + ` {
|
file ` + name + ` {
|
||||||
reload 1s
|
reload 1s
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
example.net:0 {
|
||||||
example.net:0 {
|
|
||||||
file ` + name + `
|
file ` + name + `
|
||||||
}
|
}`
|
||||||
`
|
|
||||||
i, udp, _, err := CoreDNSServerAndPorts(corefile)
|
i, udp, _, err := CoreDNSServerAndPorts(corefile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Could not get CoreDNS serving instance: %s", err)
|
t.Fatalf("Could not get CoreDNS serving instance: %s", err)
|
||||||
|
|
|
@ -18,7 +18,7 @@ func TestZoneEDNS0Lookup(t *testing.T) {
|
||||||
3600 ; retry (1 hour)
|
3600 ; retry (1 hour)
|
||||||
1209600 ; expire (2 weeks)
|
1209600 ; expire (2 weeks)
|
||||||
3600 ; minimum (1 hour)
|
3600 ; minimum (1 hour)
|
||||||
)
|
)
|
||||||
|
|
||||||
3600 IN NS a.iana-servers.net.
|
3600 IN NS a.iana-servers.net.
|
||||||
3600 IN NS b.iana-servers.net.
|
3600 IN NS b.iana-servers.net.
|
||||||
|
@ -34,8 +34,8 @@ www IN AAAA ::1
|
||||||
// Corefile with for example without proxy section.
|
// Corefile with for example without proxy section.
|
||||||
corefile := `example.org:0 {
|
corefile := `example.org:0 {
|
||||||
file ` + name + `
|
file ` + name + `
|
||||||
}
|
}`
|
||||||
`
|
|
||||||
i, udp, _, err := CoreDNSServerAndPorts(corefile)
|
i, udp, _, err := CoreDNSServerAndPorts(corefile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Could not get CoreDNS serving instance: %s", err)
|
t.Fatalf("Could not get CoreDNS serving instance: %s", err)
|
||||||
|
@ -78,8 +78,8 @@ www IN AAAA ::1
|
||||||
// Corefile with for example without proxy section.
|
// Corefile with for example without proxy section.
|
||||||
corefile := `example.org:0 {
|
corefile := `example.org:0 {
|
||||||
file ` + name + `
|
file ` + name + `
|
||||||
}
|
}`
|
||||||
`
|
|
||||||
i, udp, _, err := CoreDNSServerAndPorts(corefile)
|
i, udp, _, err := CoreDNSServerAndPorts(corefile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Could not get CoreDNS serving instance: %s", err)
|
t.Fatalf("Could not get CoreDNS serving instance: %s", err)
|
||||||
|
|
|
@ -20,8 +20,8 @@ func TestZoneSRVAdditional(t *testing.T) {
|
||||||
// Corefile with for example without proxy section.
|
// Corefile with for example without proxy section.
|
||||||
corefile := `example.org:0 {
|
corefile := `example.org:0 {
|
||||||
file ` + name + `
|
file ` + name + `
|
||||||
}
|
}`
|
||||||
`
|
|
||||||
i, udp, _, err := CoreDNSServerAndPorts(corefile)
|
i, udp, _, err := CoreDNSServerAndPorts(corefile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Could not get CoreDNS serving instance: %s", err)
|
t.Fatalf("Could not get CoreDNS serving instance: %s", err)
|
||||||
|
|
|
@ -16,7 +16,7 @@ func TestFileUpstream(t *testing.T) {
|
||||||
3600 ; retry (1 hour)
|
3600 ; retry (1 hour)
|
||||||
1209600 ; expire (2 weeks)
|
1209600 ; expire (2 weeks)
|
||||||
3600 ; minimum (1 hour)
|
3600 ; minimum (1 hour)
|
||||||
)
|
)
|
||||||
|
|
||||||
3600 IN NS a.iana-servers.net.
|
3600 IN NS a.iana-servers.net.
|
||||||
3600 IN NS b.iana-servers.net.
|
3600 IN NS b.iana-servers.net.
|
||||||
|
@ -36,8 +36,8 @@ www 3600 IN CNAME www.example.net.
|
||||||
10.0.0.1 www.example.net.
|
10.0.0.1 www.example.net.
|
||||||
fallthrough
|
fallthrough
|
||||||
}
|
}
|
||||||
}
|
}`
|
||||||
`
|
|
||||||
i, udp, _, err := CoreDNSServerAndPorts(corefile)
|
i, udp, _, err := CoreDNSServerAndPorts(corefile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Could not get CoreDNS serving instance: %s", err)
|
t.Fatalf("Could not get CoreDNS serving instance: %s", err)
|
||||||
|
@ -94,8 +94,8 @@ www 3600 IN A 127.0.0.53
|
||||||
file ` + name2 + ` foo.example.org {
|
file ` + name2 + ` foo.example.org {
|
||||||
upstream
|
upstream
|
||||||
}
|
}
|
||||||
}
|
}`
|
||||||
`
|
|
||||||
i, udp, _, err := CoreDNSServerAndPorts(corefile)
|
i, udp, _, err := CoreDNSServerAndPorts(corefile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Could not get CoreDNS serving instance: %s", err)
|
t.Fatalf("Could not get CoreDNS serving instance: %s", err)
|
||||||
|
|
|
@ -32,8 +32,8 @@ func TestLargeAXFR(t *testing.T) {
|
||||||
file ` + name + ` {
|
file ` + name + ` {
|
||||||
transfer to *
|
transfer to *
|
||||||
}
|
}
|
||||||
}
|
}`
|
||||||
`
|
|
||||||
// Start server, and send an AXFR query to the TCP port. We set the deadline to prevent the test from hanging.
|
// Start server, and send an AXFR query to the TCP port. We set the deadline to prevent the test from hanging.
|
||||||
i, _, tcp, err := CoreDNSServerAndPorts(corefile)
|
i, _, tcp, err := CoreDNSServerAndPorts(corefile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -14,8 +14,8 @@ import (
|
||||||
func TestGrpc(t *testing.T) {
|
func TestGrpc(t *testing.T) {
|
||||||
corefile := `grpc://.:0 {
|
corefile := `grpc://.:0 {
|
||||||
whoami
|
whoami
|
||||||
}
|
}`
|
||||||
`
|
|
||||||
g, _, tcp, err := CoreDNSServerAndPorts(corefile)
|
g, _, tcp, err := CoreDNSServerAndPorts(corefile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Could not get CoreDNS serving instance: %s", err)
|
t.Fatalf("Could not get CoreDNS serving instance: %s", err)
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package test
|
package test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
@ -18,16 +17,16 @@ import (
|
||||||
|
|
||||||
// Start test server that has metrics enabled. Then tear it down again.
|
// Start test server that has metrics enabled. Then tear it down again.
|
||||||
func TestMetricsServer(t *testing.T) {
|
func TestMetricsServer(t *testing.T) {
|
||||||
corefile := `example.org:0 {
|
corefile := `
|
||||||
|
example.org:0 {
|
||||||
chaos CoreDNS-001 miek@miek.nl
|
chaos CoreDNS-001 miek@miek.nl
|
||||||
prometheus localhost:0
|
prometheus localhost:0
|
||||||
}
|
}
|
||||||
|
example.com:0 {
|
||||||
example.com:0 {
|
|
||||||
forward . 8.8.4.4:53
|
forward . 8.8.4.4:53
|
||||||
prometheus localhost:0
|
prometheus localhost:0
|
||||||
}
|
}`
|
||||||
`
|
|
||||||
srv, err := CoreDNSServer(corefile)
|
srv, err := CoreDNSServer(corefile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Could not get CoreDNS serving instance: %s", err)
|
t.Fatalf("Could not get CoreDNS serving instance: %s", err)
|
||||||
|
@ -37,12 +36,11 @@ example.com:0 {
|
||||||
|
|
||||||
func TestMetricsRefused(t *testing.T) {
|
func TestMetricsRefused(t *testing.T) {
|
||||||
metricName := "coredns_dns_responses_total"
|
metricName := "coredns_dns_responses_total"
|
||||||
|
|
||||||
corefile := `example.org:0 {
|
corefile := `example.org:0 {
|
||||||
forward . 8.8.8.8:53
|
forward . 8.8.8.8:53
|
||||||
prometheus localhost:0
|
prometheus localhost:0
|
||||||
}
|
}`
|
||||||
`
|
|
||||||
srv, udp, _, err := CoreDNSServerAndPorts(corefile)
|
srv, udp, _, err := CoreDNSServerAndPorts(corefile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Could not get CoreDNS serving instance: %s", err)
|
t.Fatalf("Could not get CoreDNS serving instance: %s", err)
|
||||||
|
@ -82,8 +80,7 @@ func TestMetricsAuto(t *testing.T) {
|
||||||
reload 1s
|
reload 1s
|
||||||
}
|
}
|
||||||
prometheus localhost:0
|
prometheus localhost:0
|
||||||
}
|
}`
|
||||||
`
|
|
||||||
|
|
||||||
i, err := CoreDNSServer(corefile)
|
i, err := CoreDNSServer(corefile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -140,22 +137,20 @@ func TestMetricsAuto(t *testing.T) {
|
||||||
func TestMetricsSeveralBlocs(t *testing.T) {
|
func TestMetricsSeveralBlocs(t *testing.T) {
|
||||||
cacheSizeMetricName := "coredns_cache_entries"
|
cacheSizeMetricName := "coredns_cache_entries"
|
||||||
addrMetrics := "localhost:9155"
|
addrMetrics := "localhost:9155"
|
||||||
|
corefile := `
|
||||||
corefile := fmt.Sprintf(`
|
example.org:0 {
|
||||||
example.org:0 {
|
prometheus ` + addrMetrics + `
|
||||||
prometheus %s
|
|
||||||
forward . 8.8.8.8:53 {
|
forward . 8.8.8.8:53 {
|
||||||
force_tcp
|
force_tcp
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
google.com:0 {
|
google.com:0 {
|
||||||
prometheus %s
|
prometheus ` + addrMetrics + `
|
||||||
forward . 8.8.8.8:53 {
|
forward . 8.8.8.8:53 {
|
||||||
force_tcp
|
force_tcp
|
||||||
}
|
}
|
||||||
cache
|
cache
|
||||||
}
|
}`
|
||||||
`, addrMetrics, addrMetrics)
|
|
||||||
|
|
||||||
i, udp, _, err := CoreDNSServerAndPorts(corefile)
|
i, udp, _, err := CoreDNSServerAndPorts(corefile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -190,16 +185,16 @@ google.com:0 {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestMetricsPluginEnabled(t *testing.T) {
|
func TestMetricsPluginEnabled(t *testing.T) {
|
||||||
corefile := `example.org:0 {
|
corefile := `
|
||||||
|
example.org:0 {
|
||||||
chaos CoreDNS-001 miek@miek.nl
|
chaos CoreDNS-001 miek@miek.nl
|
||||||
prometheus localhost:0
|
prometheus localhost:0
|
||||||
}
|
}
|
||||||
|
example.com:0 {
|
||||||
example.com:0 {
|
|
||||||
forward . 8.8.4.4:53
|
forward . 8.8.4.4:53
|
||||||
prometheus localhost:0
|
prometheus localhost:0
|
||||||
}
|
}`
|
||||||
`
|
|
||||||
srv, err := CoreDNSServer(corefile)
|
srv, err := CoreDNSServer(corefile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Could not get CoreDNS serving instance: %s", err)
|
t.Fatalf("Could not get CoreDNS serving instance: %s", err)
|
||||||
|
@ -230,14 +225,14 @@ func TestMetricsAvailable(t *testing.T) {
|
||||||
procCache := "coredns_cache_entries"
|
procCache := "coredns_cache_entries"
|
||||||
procCacheMiss := "coredns_cache_misses_total"
|
procCacheMiss := "coredns_cache_misses_total"
|
||||||
procForward := "coredns_dns_request_duration_seconds"
|
procForward := "coredns_dns_request_duration_seconds"
|
||||||
corefileWithMetrics := `
|
corefileWithMetrics := `.:0 {
|
||||||
.:0 {
|
|
||||||
prometheus localhost:0
|
prometheus localhost:0
|
||||||
cache
|
cache
|
||||||
forward . 8.8.8.8 {
|
forward . 8.8.8.8 {
|
||||||
force_tcp
|
force_tcp
|
||||||
}
|
}
|
||||||
}`
|
}`
|
||||||
|
|
||||||
inst, _, tcp, err := CoreDNSServerAndPorts(corefileWithMetrics)
|
inst, _, tcp, err := CoreDNSServerAndPorts(corefileWithMetrics)
|
||||||
defer inst.Stop()
|
defer inst.Stop()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -27,8 +27,8 @@ func TestLookupBalanceRewriteCacheDnssec(t *testing.T) {
|
||||||
key file ` + base + `
|
key file ` + base + `
|
||||||
}
|
}
|
||||||
loadbalance
|
loadbalance
|
||||||
}
|
}`
|
||||||
`
|
|
||||||
ex, udp, _, err := CoreDNSServerAndPorts(corefile)
|
ex, udp, _, err := CoreDNSServerAndPorts(corefile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Could not get CoreDNS serving instance: %s", err)
|
t.Fatalf("Could not get CoreDNS serving instance: %s", err)
|
||||||
|
|
|
@ -15,8 +15,7 @@ func TestProxyThreeWay(t *testing.T) {
|
||||||
erratic {
|
erratic {
|
||||||
drop 2
|
drop 2
|
||||||
}
|
}
|
||||||
}
|
}`
|
||||||
`
|
|
||||||
|
|
||||||
up1, err := CoreDNSServer(corefileUp1)
|
up1, err := CoreDNSServer(corefileUp1)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -26,8 +25,7 @@ func TestProxyThreeWay(t *testing.T) {
|
||||||
|
|
||||||
corefileUp2 := `example.org:0 {
|
corefileUp2 := `example.org:0 {
|
||||||
whoami
|
whoami
|
||||||
}
|
}`
|
||||||
`
|
|
||||||
|
|
||||||
up2, err := CoreDNSServer(corefileUp2)
|
up2, err := CoreDNSServer(corefileUp2)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -18,8 +18,7 @@ func TestLookupProxy(t *testing.T) {
|
||||||
|
|
||||||
corefile := `example.org:0 {
|
corefile := `example.org:0 {
|
||||||
file ` + name + `
|
file ` + name + `
|
||||||
}
|
}`
|
||||||
`
|
|
||||||
|
|
||||||
i, udp, _, err := CoreDNSServerAndPorts(corefile)
|
i, udp, _, err := CoreDNSServerAndPorts(corefile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -55,8 +54,7 @@ func BenchmarkProxyLookup(b *testing.B) {
|
||||||
|
|
||||||
corefile := `example.org:0 {
|
corefile := `example.org:0 {
|
||||||
file ` + name + `
|
file ` + name + `
|
||||||
}
|
}`
|
||||||
`
|
|
||||||
|
|
||||||
i, err := CoreDNSServer(corefile)
|
i, err := CoreDNSServer(corefile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -15,8 +15,8 @@ import (
|
||||||
func TestReload(t *testing.T) {
|
func TestReload(t *testing.T) {
|
||||||
corefile := `.:0 {
|
corefile := `.:0 {
|
||||||
whoami
|
whoami
|
||||||
}
|
}`
|
||||||
`
|
|
||||||
coreInput := NewInput(corefile)
|
coreInput := NewInput(corefile)
|
||||||
|
|
||||||
c, err := CoreDNSServer(corefile)
|
c, err := CoreDNSServer(corefile)
|
||||||
|
@ -60,11 +60,11 @@ func send(t *testing.T, server string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestReloadHealth(t *testing.T) {
|
func TestReloadHealth(t *testing.T) {
|
||||||
corefile := `
|
corefile := `.:0 {
|
||||||
.:0 {
|
|
||||||
health 127.0.0.1:52182
|
health 127.0.0.1:52182
|
||||||
whoami
|
whoami
|
||||||
}`
|
}`
|
||||||
|
|
||||||
c, err := CoreDNSServer(corefile)
|
c, err := CoreDNSServer(corefile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if strings.Contains(err.Error(), inUse) {
|
if strings.Contains(err.Error(), inUse) {
|
||||||
|
@ -81,12 +81,12 @@ func TestReloadHealth(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestReloadMetricsHealth(t *testing.T) {
|
func TestReloadMetricsHealth(t *testing.T) {
|
||||||
corefile := `
|
corefile := `.:0 {
|
||||||
.:0 {
|
|
||||||
prometheus 127.0.0.1:53183
|
prometheus 127.0.0.1:53183
|
||||||
health 127.0.0.1:53184
|
health 127.0.0.1:53184
|
||||||
whoami
|
whoami
|
||||||
}`
|
}`
|
||||||
|
|
||||||
c, err := CoreDNSServer(corefile)
|
c, err := CoreDNSServer(corefile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if strings.Contains(err.Error(), inUse) {
|
if strings.Contains(err.Error(), inUse) {
|
||||||
|
@ -154,15 +154,14 @@ func TestReloadSeveralTimeMetrics(t *testing.T) {
|
||||||
// that is not used in another test
|
// that is not used in another test
|
||||||
promAddress := "127.0.0.1:53185"
|
promAddress := "127.0.0.1:53185"
|
||||||
proc := "coredns_build_info"
|
proc := "coredns_build_info"
|
||||||
corefileWithMetrics := `
|
corefileWithMetrics := `.:0 {
|
||||||
.:0 {
|
|
||||||
prometheus ` + promAddress + `
|
prometheus ` + promAddress + `
|
||||||
whoami
|
whoami
|
||||||
}`
|
}`
|
||||||
corefileWithoutMetrics := `
|
corefileWithoutMetrics := `.:0 {
|
||||||
.:0 {
|
|
||||||
whoami
|
whoami
|
||||||
}`
|
}`
|
||||||
|
|
||||||
if err := collectMetricsInfo(promAddress, proc); err == nil {
|
if err := collectMetricsInfo(promAddress, proc); err == nil {
|
||||||
t.Errorf("Prometheus is listening before the test started")
|
t.Errorf("Prometheus is listening before the test started")
|
||||||
}
|
}
|
||||||
|
@ -211,14 +210,14 @@ func TestMetricsAvailableAfterReload(t *testing.T) {
|
||||||
procMetric := "coredns_build_info"
|
procMetric := "coredns_build_info"
|
||||||
procCache := "coredns_cache_entries"
|
procCache := "coredns_cache_entries"
|
||||||
procForward := "coredns_dns_request_duration_seconds"
|
procForward := "coredns_dns_request_duration_seconds"
|
||||||
corefileWithMetrics := `
|
corefileWithMetrics := `.:0 {
|
||||||
.:0 {
|
|
||||||
prometheus ` + promAddress + `
|
prometheus ` + promAddress + `
|
||||||
cache
|
cache
|
||||||
forward . 8.8.8.8 {
|
forward . 8.8.8.8 {
|
||||||
force_tcp
|
force_tcp
|
||||||
}
|
}
|
||||||
}`
|
}`
|
||||||
|
|
||||||
inst, _, tcp, err := CoreDNSServerAndPorts(corefileWithMetrics)
|
inst, _, tcp, err := CoreDNSServerAndPorts(corefileWithMetrics)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if strings.Contains(err.Error(), inUse) {
|
if strings.Contains(err.Error(), inUse) {
|
||||||
|
@ -265,16 +264,14 @@ func TestMetricsAvailableAfterReloadAndFailedReload(t *testing.T) {
|
||||||
procMetric := "coredns_build_info"
|
procMetric := "coredns_build_info"
|
||||||
procCache := "coredns_cache_entries"
|
procCache := "coredns_cache_entries"
|
||||||
procForward := "coredns_dns_request_duration_seconds"
|
procForward := "coredns_dns_request_duration_seconds"
|
||||||
corefileWithMetrics := `
|
corefileWithMetrics := `.:0 {
|
||||||
.:0 {
|
|
||||||
prometheus ` + promAddress + `
|
prometheus ` + promAddress + `
|
||||||
cache
|
cache
|
||||||
forward . 8.8.8.8 {
|
forward . 8.8.8.8 {
|
||||||
force_tcp
|
force_tcp
|
||||||
}
|
}
|
||||||
}`
|
}`
|
||||||
invalidCorefileWithMetrics := `
|
invalidCorefileWithMetrics := `.:0 {
|
||||||
.:0 {
|
|
||||||
prometheus ` + promAddress + `
|
prometheus ` + promAddress + `
|
||||||
cache
|
cache
|
||||||
forward . 8.8.8.8 {
|
forward . 8.8.8.8 {
|
||||||
|
@ -282,6 +279,7 @@ func TestMetricsAvailableAfterReloadAndFailedReload(t *testing.T) {
|
||||||
}
|
}
|
||||||
invalid
|
invalid
|
||||||
}`
|
}`
|
||||||
|
|
||||||
inst, _, tcp, err := CoreDNSServerAndPorts(corefileWithMetrics)
|
inst, _, tcp, err := CoreDNSServerAndPorts(corefileWithMetrics)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if strings.Contains(err.Error(), inUse) {
|
if strings.Contains(err.Error(), inUse) {
|
||||||
|
|
|
@ -15,7 +15,7 @@ func TestRewrite(t *testing.T) {
|
||||||
erratic . {
|
erratic . {
|
||||||
drop 0
|
drop 0
|
||||||
}
|
}
|
||||||
}`
|
}`
|
||||||
|
|
||||||
i, udp, _, err := CoreDNSServerAndPorts(corefile)
|
i, udp, _, err := CoreDNSServerAndPorts(corefile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -15,8 +15,7 @@ func TestEmptySecondaryZone(t *testing.T) {
|
||||||
secondary {
|
secondary {
|
||||||
transfer from 127.0.0.1:1717
|
transfer from 127.0.0.1:1717
|
||||||
}
|
}
|
||||||
}
|
}`
|
||||||
`
|
|
||||||
|
|
||||||
i, udp, _, err := CoreDNSServerAndPorts(corefile)
|
i, udp, _, err := CoreDNSServerAndPorts(corefile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -46,8 +45,7 @@ func TestSecondaryZoneTransfer(t *testing.T) {
|
||||||
file ` + name + ` {
|
file ` + name + ` {
|
||||||
transfer to *
|
transfer to *
|
||||||
}
|
}
|
||||||
}
|
}`
|
||||||
`
|
|
||||||
|
|
||||||
i, _, tcp, err := CoreDNSServerAndPorts(corefile)
|
i, _, tcp, err := CoreDNSServerAndPorts(corefile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -59,8 +57,8 @@ func TestSecondaryZoneTransfer(t *testing.T) {
|
||||||
secondary {
|
secondary {
|
||||||
transfer from ` + tcp + `
|
transfer from ` + tcp + `
|
||||||
}
|
}
|
||||||
}
|
}`
|
||||||
`
|
|
||||||
i1, udp, _, err := CoreDNSServerAndPorts(corefile)
|
i1, udp, _, err := CoreDNSServerAndPorts(corefile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Could not get CoreDNS serving instance: %s", err)
|
t.Fatalf("Could not get CoreDNS serving instance: %s", err)
|
||||||
|
@ -96,8 +94,7 @@ func TestIxfrResponse(t *testing.T) {
|
||||||
file ` + name + ` {
|
file ` + name + ` {
|
||||||
transfer to *
|
transfer to *
|
||||||
}
|
}
|
||||||
}
|
}`
|
||||||
`
|
|
||||||
|
|
||||||
i, udp, _, err := CoreDNSServerAndPorts(corefile)
|
i, udp, _, err := CoreDNSServerAndPorts(corefile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -11,8 +11,8 @@ func TestClasslessReverse(t *testing.T) {
|
||||||
// 25 -> so anything above 1.127 won't be answered, below is OK.
|
// 25 -> so anything above 1.127 won't be answered, below is OK.
|
||||||
corefile := `192.168.1.0/25:0 {
|
corefile := `192.168.1.0/25:0 {
|
||||||
whoami
|
whoami
|
||||||
}
|
}`
|
||||||
`
|
|
||||||
s, udp, _, err := CoreDNSServerAndPorts(corefile)
|
s, udp, _, err := CoreDNSServerAndPorts(corefile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Could not get CoreDNS serving instance: %s", err)
|
t.Fatalf("Could not get CoreDNS serving instance: %s", err)
|
||||||
|
@ -51,8 +51,8 @@ func TestClasslessReverse(t *testing.T) {
|
||||||
func TestReverse(t *testing.T) {
|
func TestReverse(t *testing.T) {
|
||||||
corefile := `192.168.1.0/24:0 {
|
corefile := `192.168.1.0/24:0 {
|
||||||
whoami
|
whoami
|
||||||
}
|
}`
|
||||||
`
|
|
||||||
s, udp, _, err := CoreDNSServerAndPorts(corefile)
|
s, udp, _, err := CoreDNSServerAndPorts(corefile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Could not get CoreDNS serving instance: %s", err)
|
t.Fatalf("Could not get CoreDNS serving instance: %s", err)
|
||||||
|
@ -97,8 +97,8 @@ func TestReverse(t *testing.T) {
|
||||||
func TestReverseInAddr(t *testing.T) {
|
func TestReverseInAddr(t *testing.T) {
|
||||||
corefile := `1.168.192.in-addr.arpa:0 {
|
corefile := `1.168.192.in-addr.arpa:0 {
|
||||||
whoami
|
whoami
|
||||||
}
|
}`
|
||||||
`
|
|
||||||
s, udp, _, err := CoreDNSServerAndPorts(corefile)
|
s, udp, _, err := CoreDNSServerAndPorts(corefile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Could not get CoreDNS serving instance: %s", err)
|
t.Fatalf("Could not get CoreDNS serving instance: %s", err)
|
||||||
|
|
|
@ -11,8 +11,8 @@ func TestProxyToChaosServer(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
corefile := `.:0 {
|
corefile := `.:0 {
|
||||||
chaos CoreDNS-001 miek@miek.nl
|
chaos CoreDNS-001 miek@miek.nl
|
||||||
}
|
}`
|
||||||
`
|
|
||||||
chaos, udpChaos, _, err := CoreDNSServerAndPorts(corefile)
|
chaos, udpChaos, _, err := CoreDNSServerAndPorts(corefile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Could not get CoreDNS serving instance: %s", err)
|
t.Fatalf("Could not get CoreDNS serving instance: %s", err)
|
||||||
|
@ -22,8 +22,8 @@ func TestProxyToChaosServer(t *testing.T) {
|
||||||
|
|
||||||
corefileProxy := `.:0 {
|
corefileProxy := `.:0 {
|
||||||
forward . ` + udpChaos + `
|
forward . ` + udpChaos + `
|
||||||
}
|
}`
|
||||||
`
|
|
||||||
proxy, udp, _, err := CoreDNSServerAndPorts(corefileProxy)
|
proxy, udp, _, err := CoreDNSServerAndPorts(corefileProxy)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Could not get CoreDNS serving instance")
|
t.Fatalf("Could not get CoreDNS serving instance")
|
||||||
|
|
|
@ -20,8 +20,8 @@ func TestTemplateUpstream(t *testing.T) {
|
||||||
match ".*"
|
match ".*"
|
||||||
answer "target.example.net. 60 IN A 1.2.3.4"
|
answer "target.example.net. 60 IN A 1.2.3.4"
|
||||||
}
|
}
|
||||||
}
|
}`
|
||||||
`
|
|
||||||
i, udp, _, err := CoreDNSServerAndPorts(corefile)
|
i, udp, _, err := CoreDNSServerAndPorts(corefile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Could not get CoreDNS serving instance: %s", err)
|
t.Fatalf("Could not get CoreDNS serving instance: %s", err)
|
||||||
|
|
|
@ -18,8 +18,7 @@ func TestLookupWildcard(t *testing.T) {
|
||||||
|
|
||||||
corefile := `example.org:0 {
|
corefile := `example.org:0 {
|
||||||
file ` + name + `
|
file ` + name + `
|
||||||
}
|
}`
|
||||||
`
|
|
||||||
|
|
||||||
i, udp, _, err := CoreDNSServerAndPorts(corefile)
|
i, udp, _, err := CoreDNSServerAndPorts(corefile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Add table
Reference in a new issue