testutil

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 15, 2023 License: Apache-2.0 Imports: 11 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var LeakOptions = []goleak.Option{
	goleak.IgnoreTopFunction("github.com/syndtr/goleveldb/leveldb.(*DB).mpoolDrain"),
	goleak.IgnoreTopFunction("google.golang.org/grpc.(*ccBalancerWrapper).watcher"),
	goleak.IgnoreTopFunction("google.golang.org/grpc.(*addrConn).resetTransport"),
	goleak.IgnoreTopFunction("go.etcd.io/etcd/pkg/logutil.(*MergeLogger).outputLoop"),
	goleak.IgnoreTopFunction("sync.runtime_notifyListWait"),

	goleak.IgnoreTopFunction("internal/poll.runtime_pollWait"),
	goleak.IgnoreTopFunction("net/http.(*persistConn).writeLoop"),

	goleak.IgnoreTopFunction("gopkg.in/natefinch/lumberjack%2ev2.(*Logger).millRun"),
}

LeakOptions is used to filter the goroutines.

Functions

func CheckGetJSON

func CheckGetJSON(client *http.Client, url string, data []byte, checkOpts ...func([]byte, int)) error

CheckGetJSON is used to do get request and do check options

func CheckPatchJSON

func CheckPatchJSON(client *http.Client, url string, data []byte, checkOpts ...func([]byte, int)) error

CheckPatchJSON is used to do patch request and do check options

func CheckPostJSON

func CheckPostJSON(client *http.Client, url string, data []byte, checkOpts ...func([]byte, int)) error

CheckPostJSON is used to do post request and do check options

func CleanServer

func CleanServer(dataDir string)

CleanServer is used to clean data directory.

func Eventually

func Eventually(re *require.Assertions, condition func() bool, opts ...WaitOption)

Eventually asserts that given condition will be met in a period of time.

func ExtractJSON

func ExtractJSON(re *require.Assertions, data interface{}) func([]byte, int)

ExtractJSON is used to check whether given data can be extracted successfully

func MustNewGrpcClient

func MustNewGrpcClient(re *require.Assertions, addr string) pdpb.PDClient

MustNewGrpcClient must create a new PD grpc client.

func NewRequestHeader

func NewRequestHeader(clusterID uint64) *pdpb.RequestHeader

NewRequestHeader creates a new request header.

func ReadGetJSON

func ReadGetJSON(re *require.Assertions, client *http.Client, url string, data interface{}) error

ReadGetJSON is used to do get request and check whether given data can be extracted successfully

func ReadGetJSONWithBody

func ReadGetJSONWithBody(re *require.Assertions, client *http.Client, url string, input []byte, data interface{}) error

ReadGetJSONWithBody is used to do get request with input and check whether given data can be extracted successfully

func Status

func Status(re *require.Assertions, code int) func([]byte, int)

Status is used to check whether http response code is equal given code

func StatusNotOK

func StatusNotOK(re *require.Assertions) func([]byte, int)

StatusNotOK is used to check whether http response code is not equal http.StatusOK

func StatusOK

func StatusOK(re *require.Assertions) func([]byte, int)

StatusOK is used to check whether http response code is equal http.StatusOK

func StringContain

func StringContain(re *require.Assertions, sub string) func([]byte, int)

StringContain is used to check whether response context contains given string

func StringEqual

func StringEqual(re *require.Assertions, str string) func([]byte, int)

StringEqual is used to check whether response context equal given string

Types

type CleanupFunc

type CleanupFunc func()

CleanupFunc closes test pd server(s) and deletes any files left behind.

type WaitOp

type WaitOp struct {
	// contains filtered or unexported fields
}

WaitOp represents available options when execute Eventually.

type WaitOption

type WaitOption func(op *WaitOp)

WaitOption configures WaitOp.

func WithTickInterval

func WithTickInterval(tickInterval time.Duration) WaitOption

WithTickInterval specify the tick interval to check the condition.

func WithWaitFor

func WithWaitFor(waitFor time.Duration) WaitOption

WithWaitFor specify the max wait duration.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL