cockroach: Index | Files

package pgtest

import ""


Package Files

datadriven.go pgtest.go

func RunTest Uses

func RunTest(t *testing.T, path, addr, user string)

RunTest executes PGTest commands, connecting to the database specified by addr and user. Supported commands:

"send": Sends messages to a server. Takes a newline-delimited list of pgproto3.FrontendMessage types. Can fill in values by adding a space then a JSON object. No output.

"until": Receives all messages from a server until messages of the given types have been seen. Converts them to JSON one per line as output. Takes a newline-delimited list of pgproto3.BackendMessage types. An ignore option can be used to specify types to ignore. ErrorResponse messages are immediately returned as errors unless they are the expected type, in which case they will marshal to an empty ErrorResponse message since our error detail specifics differ from Postgres.

"receive": Like "until", but only output matching messages instead of all messages.

If the argument crdb_only is given and the server is non-crdb (e.g. posrgres), then the exchange is skipped. With noncrdb_only, the inverse happens.

func WalkWithNewServer Uses

func WalkWithNewServer(
    t *testing.T, path string, newServer func() (addr, user string, cleanup func()),

WalkWithNewServer walks path for datadriven files and calls RunTest on them, but creates a new server for each test file.

func WalkWithRunningServer Uses

func WalkWithRunningServer(t *testing.T, path, addr, user string)

WalkWithRunningServer walks path for datadriven files and calls RunTest on them. It is used when an existing server is desired for each test.

type PGTest Uses

type PGTest struct {
    // contains filtered or unexported fields

PGTest can be used to send and receive arbitrary pgwire messages on Postgres-compatible servers.

func NewPGTest Uses

func NewPGTest(ctx context.Context, addr, user string) (*PGTest, error)

NewPGTest connects to a Postgres server at addr with username user.

func (*PGTest) Close Uses

func (p *PGTest) Close() error

Close sends a Terminate message and closes the connection.

func (*PGTest) Receive Uses

func (p *PGTest) Receive(
    keepErrMsg bool, typs ...pgproto3.BackendMessage,
) ([]pgproto3.BackendMessage, error)

Receive reads messages until messages of the given types have been found in the specified order (with any number of messages in between). It returns matched messages.

func (*PGTest) Send Uses

func (p *PGTest) Send(msg pgproto3.FrontendMessage) error

Send sends msg to the serrver.

func (*PGTest) Until Uses

func (p *PGTest) Until(
    keepErrMsg bool, typs ...pgproto3.BackendMessage,
) ([]pgproto3.BackendMessage, error)

Until is like Receive except all messages are returned instead of only matched messages.

Package pgtest imports 11 packages (graph). Updated 2020-08-13. Refresh now. Tools for package owners.