Documentation ¶
Overview ¶
Package testutil is testing helpers for the Landns.
Index ¶
- Constants
- func FindEmptyPort() int
- func StartServer(ctx context.Context, t SimpleTB, debugMode bool) (client.Client, *net.UDPAddr)
- type DNSServer
- type DummyResolver
- type DummyResponseWriter
- type DummyTB
- func (t *DummyTB) AssertErrors(tb SimpleTB, expect ...string)
- func (t *DummyTB) AssertFatals(tb SimpleTB, expect ...string)
- func (t *DummyTB) Errorf(format string, data ...interface{})
- func (t *DummyTB) Failed() bool
- func (t *DummyTB) Fatalf(format string, data ...interface{})
- func (t *DummyTB) Helper()
- type EmptyResponseWriter
- type HTTPResponse
- type HTTPServer
- type Metrics
- type MetricsEntry
- type MetricsLabels
- type MetricsServer
- type SimpleTB
Constants ¶
const ( // PortMin is minimum port number for FindEmptyPort. PortMin = 49152 // PortMax is maximum port number for FindEmptyPort. PortMax = 65535 )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DNSServer ¶
DNSServer is tester for DNS blackbox test.
func StartDNSServer ¶
StartDNSServer is make dns.Server and start it.
type DummyResolver ¶
DummyResolver is stub of landns.Resolver.
func (DummyResolver) RecursionAvailable ¶
func (dr DummyResolver) RecursionAvailable() bool
RecursionAvailable is returns value of DummyResolver.Recursion.
func (DummyResolver) Resolve ¶
func (dr DummyResolver) Resolve(w landns.ResponseWriter, r landns.Request) error
Resolve is returns error if DummyResolver.Error is true, otherwise nothing to do.
type DummyResponseWriter ¶
type DummyResponseWriter struct { Records []landns.Record Authoritative bool }
DummyResponseWriter is array stub of landns.ResponseWriter.
func NewDummyResponseWriter ¶
func NewDummyResponseWriter() *DummyResponseWriter
NewDummyResponseWriter is constructor of DummyResponseWriter.
func (*DummyResponseWriter) Add ¶
func (rw *DummyResponseWriter) Add(r landns.Record) error
Add is adding record into DummyResponseWriter.Records.
func (*DummyResponseWriter) IsAuthoritative ¶
func (rw *DummyResponseWriter) IsAuthoritative() bool
IsAuthoritative is returns value of DummyResponseWriter.Authoritative.
func (*DummyResponseWriter) SetNoAuthoritative ¶
func (rw *DummyResponseWriter) SetNoAuthoritative()
SetNoAuthoritative is set value to DummyResponseWriter.Authoritative.
type DummyTB ¶
DummyTB is the tester for assert functions.
func (*DummyTB) AssertErrors ¶
AssertErrors is test error logs.
func (*DummyTB) AssertFatals ¶
AssertFatals is test fatal logs.
type EmptyResponseWriter ¶
type EmptyResponseWriter struct{}
EmptyResponseWriter is empty stub of landns.ResponseWriter.
func (EmptyResponseWriter) Add ¶
func (rw EmptyResponseWriter) Add(r landns.Record) error
Add is nothing to do.
func (EmptyResponseWriter) IsAuthoritative ¶
func (rw EmptyResponseWriter) IsAuthoritative() bool
IsAuthoritative is always returns true.
func (EmptyResponseWriter) SetNoAuthoritative ¶
func (rw EmptyResponseWriter) SetNoAuthoritative()
SetNoAuthoritative is nothing to do.
type HTTPResponse ¶
HTTPResponse is response type from HTTPServer.
type HTTPServer ¶
HTTPServer is tester for HTTP blackbox test.
func StartHTTPServer ¶
StartHTTPServer is make http.Server and start it.
func (HTTPServer) Do ¶
func (h HTTPServer) Do(t SimpleTB, method, path, body string) (r HTTPResponse)
Do is do HTTP request to server.
type Metrics ¶
type Metrics []MetricsEntry
Metrics is response data from MetricsServer.
func ParseMetrics ¶
ParseMetrics is parser for Metrics.
type MetricsEntry ¶
type MetricsEntry struct { Name string Labels MetricsLabels Value float64 }
MetricsEntry is one entry of Metrics.
type MetricsLabels ¶
MetricsLabels is labels for MetricsEntry.
func ParseMetricsLabels ¶
func ParseMetricsLabels(str string) MetricsLabels
ParseMetricsLabels is parser to MetricsLabels.
func (MetricsLabels) String ¶
func (l MetricsLabels) String() string
String is human readable string getter.
type MetricsServer ¶
type MetricsServer struct { Metrics *landns.Metrics HTTPServer HTTPServer }
MetricsServer is tester for Metrics blackbox test.
func StartMetricsServer ¶
func StartMetricsServer(ctx context.Context, t SimpleTB, namespace string) MetricsServer
StartMetricsServer is make metrics server and start it.
func (MetricsServer) Get ¶
func (s MetricsServer) Get(t SimpleTB) Metrics
Get is get Metrics from MetricsServer.