Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
C
Coredns
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Railgun
Coredns
Commits
e8b44125
Commit
e8b44125
authored
Oct 08, 2016
by
Miek Gieben
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tests: clean up output
Some document improvements and add a few more tests.
parent
e43384b5
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
53 additions
and
13 deletions
+53
-13
README.md
README.md
+2
-3
middleware/file/nsec3_test.go
middleware/file/nsec3_test.go
+0
-2
middleware/file/reload_test.go
middleware/file/reload_test.go
+3
-0
middleware/file/secondary_test.go
middleware/file/secondary_test.go
+6
-2
middleware/metrics/setup_test.go
middleware/metrics/setup_test.go
+1
-1
middleware/pkg/rcode/rcode_test.go
middleware/pkg/rcode/rcode_test.go
+29
-0
middleware/test/server.go
middleware/test/server.go
+4
-5
test/server.go
test/server.go
+8
-0
No files found.
README.md
View file @
e8b44125
...
...
@@ -143,7 +143,7 @@ Github: <https://github.com/miekg/coredns>
## Systemd Service File
Use this as a systemd service file. It defaults to a coredns with a homedir of /home/coredns
Use this as a systemd service file. It defaults to a coredns with a homedir of /home/coredns
and the binary lives in /opt/bin and the config in
`/etc/coredns/Corefile`
:
~~~
txt
...
...
@@ -154,12 +154,11 @@ After=network.target
[Service]
PermissionsStartOnly=true
PIDFile=/home/coredns/coredns.pid
LimitNOFILE=8192
User=coredns
WorkingDirectory=/home/coredns
ExecStartPre=/sbin/setcap cap_net_bind_service=+ep /opt/bin/coredns
ExecStart=/opt/bin/coredns -
pidfile /home/coredns/coredns.pid -
conf=/etc/coredns/Corefile
ExecStart=/opt/bin/coredns -conf=/etc/coredns/Corefile
ExecReload=/bin/kill -SIGUSR1 $MAINPID
Restart=on-failure
...
...
middleware/file/nsec3_test.go
View file @
e8b44125
...
...
@@ -10,7 +10,6 @@ func TestParseNSEC3PARAM(t *testing.T) {
if
err
==
nil
{
t
.
Fatalf
(
"expected error when reading zone, got nothing"
)
}
t
.
Logf
(
"%v
\n
"
,
err
)
}
func
TestParseNSEC3
(
t
*
testing
.
T
)
{
...
...
@@ -18,7 +17,6 @@ func TestParseNSEC3(t *testing.T) {
if
err
==
nil
{
t
.
Fatalf
(
"expected error when reading zone, got nothing"
)
}
t
.
Logf
(
"%v
\n
"
,
err
)
}
const
nsec3paramTest
=
`miek.nl. 1800 IN SOA linode.atoom.net. miek.miek.nl. 1460175181 14400 3600 604800 14400
...
...
middleware/file/reload_test.go
View file @
e8b44125
...
...
@@ -2,6 +2,7 @@ package file
import
(
"io/ioutil"
"log"
"os"
"testing"
"time"
...
...
@@ -11,6 +12,8 @@ import (
)
func
TestZoneReload
(
t
*
testing
.
T
)
{
log
.
SetOutput
(
ioutil
.
Discard
)
fileName
,
rm
,
err
:=
test
.
TempFile
(
"."
,
reloadZoneTest
)
if
err
!=
nil
{
t
.
Fatalf
(
"failed to create zone: %s"
,
err
)
...
...
middleware/file/secondary_test.go
View file @
e8b44125
...
...
@@ -2,6 +2,8 @@ package file
import
(
"fmt"
"io/ioutil"
"log"
"testing"
"github.com/miekg/coredns/middleware/test"
...
...
@@ -70,11 +72,12 @@ const testZone = "secondary.miek.nl."
func
TestShouldTransfer
(
t
*
testing
.
T
)
{
soa
:=
soa
{
250
}
log
.
SetOutput
(
ioutil
.
Discard
)
dns
.
HandleFunc
(
testZone
,
soa
.
Handler
)
defer
dns
.
HandleRemove
(
testZone
)
s
,
addrstr
,
err
:=
test
.
TCPServer
(
t
,
"127.0.0.1:0"
)
s
,
addrstr
,
err
:=
test
.
TCPServer
(
"127.0.0.1:0"
)
if
err
!=
nil
{
t
.
Fatalf
(
"unable to run test server: %v"
,
err
)
}
...
...
@@ -114,11 +117,12 @@ func TestShouldTransfer(t *testing.T) {
func
TestTransferIn
(
t
*
testing
.
T
)
{
soa
:=
soa
{
250
}
log
.
SetOutput
(
ioutil
.
Discard
)
dns
.
HandleFunc
(
testZone
,
soa
.
Handler
)
defer
dns
.
HandleRemove
(
testZone
)
s
,
addrstr
,
err
:=
test
.
TCPServer
(
t
,
"127.0.0.1:0"
)
s
,
addrstr
,
err
:=
test
.
TCPServer
(
"127.0.0.1:0"
)
if
err
!=
nil
{
t
.
Fatalf
(
"unable to run test server: %v"
,
err
)
}
...
...
middleware/metrics/setup_test.go
View file @
e8b44125
...
...
@@ -6,7 +6,7 @@ import (
"github.com/mholt/caddy"
)
func
TestPrometheus
(
t
*
testing
.
T
)
{
func
TestPrometheus
Parse
(
t
*
testing
.
T
)
{
tests
:=
[]
struct
{
input
string
shouldErr
bool
...
...
middleware/pkg/rcode/rcode_test.go
0 → 100644
View file @
e8b44125
package
rcode
import
(
"testing"
"github.com/miekg/dns"
)
func
TestToString
(
t
*
testing
.
T
)
{
tests
:=
[]
struct
{
in
int
expected
string
}{
{
dns
.
RcodeSuccess
,
"NOERROR"
,
},
{
28
,
"RCODE28"
,
},
}
for
i
,
test
:=
range
tests
{
got
:=
ToString
(
test
.
in
)
if
got
!=
test
.
expected
{
t
.
Errorf
(
"Test %d, expected %s, got %s"
,
i
,
test
.
expected
,
got
)
}
}
}
middleware/test/server.go
View file @
e8b44125
...
...
@@ -3,14 +3,13 @@ package test
import
(
"net"
"sync"
"testing"
"time"
"github.com/miekg/dns"
)
// TCPServer starts a DNS server with a TCP listener on laddr.
func
TCPServer
(
t
*
testing
.
T
,
laddr
string
)
(
*
dns
.
Server
,
string
,
error
)
{
func
TCPServer
(
laddr
string
)
(
*
dns
.
Server
,
string
,
error
)
{
l
,
err
:=
net
.
Listen
(
"tcp"
,
laddr
)
if
err
!=
nil
{
return
nil
,
""
,
err
...
...
@@ -20,7 +19,7 @@ func TCPServer(t *testing.T, laddr string) (*dns.Server, string, error) {
waitLock
:=
sync
.
Mutex
{}
waitLock
.
Lock
()
server
.
NotifyStartedFunc
=
func
()
{
t
.
Logf
(
"started TCP server on %s"
,
l
.
Addr
());
waitLock
.
Unlock
()
}
server
.
NotifyStartedFunc
=
func
()
{
waitLock
.
Unlock
()
}
go
func
()
{
server
.
ActivateAndServe
()
...
...
@@ -32,7 +31,7 @@ func TCPServer(t *testing.T, laddr string) (*dns.Server, string, error) {
}
// UDPServer starts a DNS server with an UDP listener on laddr.
func
UDPServer
(
t
*
testing
.
T
,
laddr
string
)
(
*
dns
.
Server
,
string
,
error
)
{
func
UDPServer
(
laddr
string
)
(
*
dns
.
Server
,
string
,
error
)
{
pc
,
err
:=
net
.
ListenPacket
(
"udp"
,
laddr
)
if
err
!=
nil
{
return
nil
,
""
,
err
...
...
@@ -41,7 +40,7 @@ func UDPServer(t *testing.T, laddr string) (*dns.Server, string, error) {
waitLock
:=
sync
.
Mutex
{}
waitLock
.
Lock
()
server
.
NotifyStartedFunc
=
func
()
{
t
.
Logf
(
"started UDP server on %s"
,
pc
.
LocalAddr
());
waitLock
.
Unlock
()
}
server
.
NotifyStartedFunc
=
func
()
{
waitLock
.
Unlock
()
}
go
func
()
{
server
.
ActivateAndServe
()
...
...
test/server.go
View file @
e8b44125
package
test
import
(
"io/ioutil"
"log"
"github.com/miekg/coredns/core/dnsserver"
// Hook in CoreDNS.
_
"github.com/miekg/coredns/core"
...
...
@@ -10,6 +15,9 @@ import (
// CoreDNSServer returns a CoreDNS test server. It just takes a normal Corefile as input.
func
CoreDNSServer
(
corefile
string
)
(
*
caddy
.
Instance
,
error
)
{
caddy
.
Quiet
=
true
dnsserver
.
Quiet
=
true
log
.
SetOutput
(
ioutil
.
Discard
)
return
caddy
.
Start
(
NewInput
(
corefile
))
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment