Ejemplo n.º 1
0
// Server returns a test server and the tcp and udp listeners addresses.
func Server(t *testing.T, corefile string) (*server.Server, string, string, error) {
	srv, err := core.TestServer(t, corefile)
	if err != nil {
		return nil, "", "", err
	}
	go srv.ListenAndServe()

	time.Sleep(1 * time.Second) // yeah... I regret nothing
	tcp, udp := srv.LocalAddr()
	return srv, tcp.String(), udp.String(), nil
}
Ejemplo n.º 2
0
// Bind to low port should fail.
func TestFailStartServer(t *testing.T) {
	corefile := `.:53 {
	chaos CoreDNS-001 [email protected]
}
`
	srv, _ := core.TestServer(t, corefile)
	err := srv.ListenAndServe()
	if err == nil {
		srv.Stop()
		t.Fatalf("Low port startup should fail")
	}
}