Documentation ¶
Index ¶
- Variables
- func DebugSchema() map[string]Table
- func DebugVars() map[string]any
- func FetchInt(vars map[string]any, tags string) int
- func FetchJSON(urlPath string) map[string]any
- func FetchURL(urlPath string) string
- func FetchVal(vars map[string]any, tags string) any
- func IsPresent(vars map[string]any, tags string) bool
- func PostJSON(urlPath string, values map[string]string) map[string]any
- func QueryStats() map[string]QueryStat
- func RowsToStrings(qr *sqltypes.Result) [][]string
- func StartCustomServer(ctx context.Context, connParams, connAppDebugParams mysql.ConnParams, ...) error
- func StartServer(ctx context.Context, connParams, connAppDebugParams mysql.ConnParams, ...) error
- func StopServer()
- func StreamTerminate(connID int64) error
- type Event
- type EventCatcher
- type LiveQuery
- type MultiCase
- type QueryClient
- func (client *QueryClient) Begin(clientFoundRows bool) error
- func (client *QueryClient) BeginExecute(query string, bindvars map[string]*querypb.BindVariable, preQueries []string) (*sqltypes.Result, error)
- func (client *QueryClient) Commit() error
- func (client *QueryClient) CommitPrepared(dtid string) error
- func (client *QueryClient) ConcludeTransaction(dtid string) error
- func (client *QueryClient) CreateTransaction(dtid string, participants []*querypb.Target) error
- func (client *QueryClient) Execute(query string, bindvars map[string]*querypb.BindVariable) (*sqltypes.Result, error)
- func (client *QueryClient) ExecuteWithOptions(query string, bindvars map[string]*querypb.BindVariable, ...) (*sqltypes.Result, error)
- func (client *QueryClient) GetSchema(tableType querypb.SchemaTableType, tableNames ...string) (map[string]string, error)
- func (client *QueryClient) MessageAck(name string, ids []string) (int64, error)
- func (client *QueryClient) MessageStream(name string, callback func(*sqltypes.Result) error) (err error)
- func (client *QueryClient) Prepare(dtid string) error
- func (client *QueryClient) ReadTransaction(dtid string) (*querypb.TransactionMetadata, error)
- func (client *QueryClient) Release() error
- func (client *QueryClient) ReserveBeginExecute(query string, preQueries []string, postBeginQueries []string, ...) (*sqltypes.Result, error)
- func (client *QueryClient) ReserveBeginStreamExecute(query string, preQueries []string, postBeginQueries []string, ...) (*sqltypes.Result, error)
- func (client *QueryClient) ReserveExecute(query string, preQueries []string, bindvars map[string]*querypb.BindVariable) (*sqltypes.Result, error)
- func (client *QueryClient) ReserveStreamExecute(query string, preQueries []string, bindvars map[string]*querypb.BindVariable) (*sqltypes.Result, error)
- func (client *QueryClient) ReservedID() int64
- func (client *QueryClient) Rollback() error
- func (client *QueryClient) RollbackPrepared(dtid string, originalID int64) error
- func (client *QueryClient) SetReservedID(id int64)
- func (client *QueryClient) SetRollback(dtid string, transactionID int64) error
- func (client *QueryClient) SetServingType(tabletType topodatapb.TabletType) error
- func (client *QueryClient) SetTransactionID(id int64)
- func (client *QueryClient) StartCommit(dtid string) error
- func (client *QueryClient) Stream(query string, bindvars map[string]*querypb.BindVariable, ...) error
- func (client *QueryClient) StreamBeginExecuteWithOptions(query string, preQueries []string, bindvars map[string]*querypb.BindVariable, ...) (*sqltypes.Result, error)
- func (client *QueryClient) StreamExecute(query string, bindvars map[string]*querypb.BindVariable) (*sqltypes.Result, error)
- func (client *QueryClient) StreamExecuteWithOptions(query string, bindvars map[string]*querypb.BindVariable, ...) (*sqltypes.Result, error)
- func (client *QueryClient) StreamHealth(sendFunc func(*querypb.StreamHealthResponse) error) error
- func (client *QueryClient) StreamHealthWithContext(ctx context.Context, sendFunc func(*querypb.StreamHealthResponse) error) error
- func (client *QueryClient) TransactionID() int64
- func (client *QueryClient) UpdateContext(ctx context.Context)
- type QueryStat
- type Table
- type TableColumn
- type TestCase
- type TestQuery
- type Testable
Constants ¶
This section is empty.
Variables ¶
var ( // Target is the target info for the server. Target *querypb.Target // Server is the TabletServer for the framework. Server *tabletserver.TabletServer // ServerAddress is the http URL for the server. ServerAddress string // ResolveChan is the channel that sends dtids that are to be resolved. ResolveChan = make(chan string, 1) // TopoServer is the topology for the server TopoServer *topo.Server )
Functions ¶
func DebugSchema ¶
DebugSchema parses /debug/schema and returns a map of the tables keyed by the table name.
func DebugVars ¶
DebugVars parses /debug/vars and returns a map. The function returns an empty map on error.
func FetchInt ¶
FetchInt fetches the specified slash-separated tag and returns the value as an int. It returns 0 on error, or if not found.
func FetchJSON ¶
FetchJSON fetches JSON content from the specified URL path and returns it as a map. The function returns an empty map on error.
func FetchURL ¶
FetchURL fetches the content from the specified URL path and returns it as a string. The function returns an empty string on error.
func FetchVal ¶
FetchVal fetches the specified slash-separated tag and returns the value as an interface. It returns nil on error, or if not found.
func IsPresent ¶ added in v0.14.0
IsPresent returns whether the specified slash-separated tag is present in the vars provided
func PostJSON ¶ added in v0.9.0
PostJSON performs a post and fetches JSON content from the specified URL path and returns it as a map. The function returns an empty map on error.
func QueryStats ¶
QueryStats parses /debug/query_stats and returns a map of the query stats keyed by the query.
func RowsToStrings ¶
RowsToStrings converts qr.Rows to [][]string.
func StartCustomServer ¶ added in v0.8.0
func StartCustomServer(ctx context.Context, connParams, connAppDebugParams mysql.ConnParams, dbName string, cfg *tabletenv.TabletConfig) error
StartCustomServer starts the server and initializes all the global variables. This function should only be called once at the beginning of the test.
func StartServer ¶
func StartServer(ctx context.Context, connParams, connAppDebugParams mysql.ConnParams, dbName string) error
StartServer starts the server and initializes all the global variables. This function should only be called once at the beginning of the test.
func StreamTerminate ¶
StreamTerminate terminates the specified streaming query.
Types ¶
type EventCatcher ¶ added in v0.17.0
type EventCatcher[T Event] struct { // contains filtered or unexported fields }
func NewEventCatcher ¶ added in v0.17.0
func NewEventCatcher[T Event](logger *streamlog.StreamLogger[T]) *EventCatcher[T]
func NewQueryCatcher ¶
func NewQueryCatcher() *EventCatcher[*tabletenv.LogStats]
func (*EventCatcher[T]) Close ¶ added in v0.17.0
func (catcher *EventCatcher[T]) Close()
Close closes the EventCatcher.
func (*EventCatcher[T]) Next ¶ added in v0.17.0
func (catcher *EventCatcher[T]) Next() (T, error)
type LiveQuery ¶ added in v0.9.0
type LiveQuery struct { Type string Query string ContextHTML string Start time.Time Duration int64 ConnID int64 State string ShowTerminateLink bool }
LiveQuery contains the streaming query info.
func LiveQueryz ¶ added in v0.9.0
func LiveQueryz() []LiveQuery
OLAPQueryz returns the contents of /livequeryz?format=json. as a []LiveQuery. The function returns an empty list on error.
type MultiCase ¶
MultiCase groups a number of test cases under a name. A MultiCase is also Testable. So, it can be recursive.
func (*MultiCase) Benchmark ¶ added in v0.10.0
func (mc *MultiCase) Benchmark(client *QueryClient) error
Benchmark executes the test cases in MultiCase and discards the results without validating them.
type QueryClient ¶
type QueryClient struct {
// contains filtered or unexported fields
}
QueryClient provides a convenient wrapper for TabletServer's query service. It's not thread safe, but you can create multiple clients that point to the same server.
func NewClientWithContext ¶
func NewClientWithContext(ctx context.Context) *QueryClient
NewClientWithContext creates a new client for Server with the provided context.
func NewClientWithServer ¶ added in v0.19.0
func NewClientWithServer(server *tabletserver.TabletServer) *QueryClient
NewClientWithServer creates a new client for a given server.
func NewClientWithTabletType ¶
func NewClientWithTabletType(tabletType topodatapb.TabletType) *QueryClient
NewClientWithTabletType creates a new client for Server with the provided tablet type.
func (*QueryClient) Begin ¶
func (client *QueryClient) Begin(clientFoundRows bool) error
Begin begins a transaction.
func (*QueryClient) BeginExecute ¶
func (client *QueryClient) BeginExecute(query string, bindvars map[string]*querypb.BindVariable, preQueries []string) (*sqltypes.Result, error)
BeginExecute performs a BeginExecute.
func (*QueryClient) Commit ¶
func (client *QueryClient) Commit() error
Commit commits the current transaction.
func (*QueryClient) CommitPrepared ¶
func (client *QueryClient) CommitPrepared(dtid string) error
CommitPrepared commits a prepared transaction.
func (*QueryClient) ConcludeTransaction ¶
func (client *QueryClient) ConcludeTransaction(dtid string) error
ConcludeTransaction issues a ConcludeTransaction to TabletServer.
func (*QueryClient) CreateTransaction ¶
func (client *QueryClient) CreateTransaction(dtid string, participants []*querypb.Target) error
CreateTransaction issues a CreateTransaction to TabletServer.
func (*QueryClient) Execute ¶
func (client *QueryClient) Execute(query string, bindvars map[string]*querypb.BindVariable) (*sqltypes.Result, error)
Execute executes a query.
func (*QueryClient) ExecuteWithOptions ¶
func (client *QueryClient) ExecuteWithOptions(query string, bindvars map[string]*querypb.BindVariable, options *querypb.ExecuteOptions) (*sqltypes.Result, error)
ExecuteWithOptions executes a query using 'options'.
func (*QueryClient) GetSchema ¶ added in v0.16.0
func (client *QueryClient) GetSchema(tableType querypb.SchemaTableType, tableNames ...string) (map[string]string, error)
func (*QueryClient) MessageAck ¶
func (client *QueryClient) MessageAck(name string, ids []string) (int64, error)
MessageAck acks messages
func (*QueryClient) MessageStream ¶
func (client *QueryClient) MessageStream(name string, callback func(*sqltypes.Result) error) (err error)
MessageStream streams messages from the message table.
func (*QueryClient) Prepare ¶
func (client *QueryClient) Prepare(dtid string) error
Prepare executes a prepare on the current transaction.
func (*QueryClient) ReadTransaction ¶
func (client *QueryClient) ReadTransaction(dtid string) (*querypb.TransactionMetadata, error)
ReadTransaction returns the transaction metadata.
func (*QueryClient) Release ¶
func (client *QueryClient) Release() error
Release performs a Release.
func (*QueryClient) ReserveBeginExecute ¶
func (client *QueryClient) ReserveBeginExecute(query string, preQueries []string, postBeginQueries []string, bindvars map[string]*querypb.BindVariable) (*sqltypes.Result, error)
ReserveBeginExecute performs a ReserveBeginExecute.
func (*QueryClient) ReserveBeginStreamExecute ¶ added in v0.15.0
func (client *QueryClient) ReserveBeginStreamExecute(query string, preQueries []string, postBeginQueries []string, bindvars map[string]*querypb.BindVariable) (*sqltypes.Result, error)
ReserveBeginStreamExecute performs a ReserveBeginStreamExecute.
func (*QueryClient) ReserveExecute ¶
func (client *QueryClient) ReserveExecute(query string, preQueries []string, bindvars map[string]*querypb.BindVariable) (*sqltypes.Result, error)
ReserveExecute performs a ReserveExecute.
func (*QueryClient) ReserveStreamExecute ¶ added in v0.15.0
func (client *QueryClient) ReserveStreamExecute(query string, preQueries []string, bindvars map[string]*querypb.BindVariable) (*sqltypes.Result, error)
ReserveStreamExecute performs a ReserveStreamExecute.
func (*QueryClient) ReservedID ¶
func (client *QueryClient) ReservedID() int64
ReservedID returns reservedID
func (*QueryClient) Rollback ¶
func (client *QueryClient) Rollback() error
Rollback rolls back the current transaction.
func (*QueryClient) RollbackPrepared ¶
func (client *QueryClient) RollbackPrepared(dtid string, originalID int64) error
RollbackPrepared rolls back a prepared transaction.
func (*QueryClient) SetReservedID ¶
func (client *QueryClient) SetReservedID(id int64)
SetReservedID does what it says
func (*QueryClient) SetRollback ¶
func (client *QueryClient) SetRollback(dtid string, transactionID int64) error
SetRollback issues a SetRollback to TabletServer.
func (*QueryClient) SetServingType ¶
func (client *QueryClient) SetServingType(tabletType topodatapb.TabletType) error
SetServingType is for testing transitions. It currently supports only primary->replica and back.
func (*QueryClient) SetTransactionID ¶
func (client *QueryClient) SetTransactionID(id int64)
SetTransactionID does what it says
func (*QueryClient) StartCommit ¶
func (client *QueryClient) StartCommit(dtid string) error
StartCommit issues a StartCommit to TabletServer for the current transaction.
func (*QueryClient) Stream ¶
func (client *QueryClient) Stream(query string, bindvars map[string]*querypb.BindVariable, sendFunc func(*sqltypes.Result) error) error
Stream streams the results of a query.
func (*QueryClient) StreamBeginExecuteWithOptions ¶ added in v0.13.0
func (client *QueryClient) StreamBeginExecuteWithOptions(query string, preQueries []string, bindvars map[string]*querypb.BindVariable, options *querypb.ExecuteOptions) (*sqltypes.Result, error)
StreamBeginExecuteWithOptions starts a tx and executes a query using 'options', returning the results .
func (*QueryClient) StreamExecute ¶
func (client *QueryClient) StreamExecute(query string, bindvars map[string]*querypb.BindVariable) (*sqltypes.Result, error)
StreamExecute executes a query & returns the results.
func (*QueryClient) StreamExecuteWithOptions ¶
func (client *QueryClient) StreamExecuteWithOptions(query string, bindvars map[string]*querypb.BindVariable, options *querypb.ExecuteOptions) (*sqltypes.Result, error)
StreamExecuteWithOptions executes a query & returns the results using 'options'.
func (*QueryClient) StreamHealth ¶ added in v0.11.0
func (client *QueryClient) StreamHealth(sendFunc func(*querypb.StreamHealthResponse) error) error
StreamHealth receives the health response
func (*QueryClient) StreamHealthWithContext ¶ added in v0.17.0
func (client *QueryClient) StreamHealthWithContext(ctx context.Context, sendFunc func(*querypb.StreamHealthResponse) error) error
StreamHealthWithContext receives the health response
func (*QueryClient) TransactionID ¶
func (client *QueryClient) TransactionID() int64
TransactionID returns transactionID
func (*QueryClient) UpdateContext ¶ added in v0.16.0
func (client *QueryClient) UpdateContext(ctx context.Context)
type QueryStat ¶
type QueryStat struct {
Query, Table, Plan string
QueryCount, Time, MysqlTime, RowsAffected, RowsReturned, ErrorCount int
}
QueryStat contains the stats for one query.
type Table ¶
type Table struct { Name string Columns []TableColumn Type int }
Table is a subset of schema.Table. TODO(sougou): I'm getting a json parsing error on the 'Default' field of schema.TabletColumn. Otherwise, we should just be able to decode the json output into a schema.Table.
type TableColumn ¶
TableColumn contains info about a table's column.
type TestCase ¶
type TestCase struct { // Name gives a name to the test case. It will be used // for reporting failures. Name string // Query and BindVars are the input. Query string BindVars map[string]*querypb.BindVariable // Result is the list of rows that must be returned. // It's represented as 2-d strings. They byte values // will be compared against The bytes returned by the // query. The check is skipped if Result is nil. Result [][]string // RowsAffected affected can be nil or an int. RowsAffected any // RowsReturned affected can be nil or an int. RowsReturned any // Rewritten specifies how the query should have be rewritten. Rewritten []string // Plan specifies the plan type that was used. It will be matched // against tabletserver.PlanType(val).String(). Plan string // If Table is specified, then the framework will validate the // cache stats for that table. If the stat values are nil, then // the check is skipped. Table string Hits any Misses any Absent any Invalidations any }
TestCase represents one test case. It will execute the query and verify its results and effects against what must be expected. Expected fields are optional.
func (*TestCase) Benchmark ¶ added in v0.10.0
func (tc *TestCase) Benchmark(client *QueryClient) error
Benchmark executes the test case and discards the results without verifying them
type TestQuery ¶
type TestQuery string
TestQuery represents a plain query. It will be executed without a bind variable. The framework will check for errors, but nothing beyond. Statements like 'begin', etc. will be converted to the corresponding transaction commands.
func (TestQuery) Benchmark ¶ added in v0.10.0
func (tq TestQuery) Benchmark(client *QueryClient) error
Benchmark executes the query and discards the results
type Testable ¶
type Testable interface { Test(name string, client *QueryClient) error Benchmark(client *QueryClient) error }
Testable restricts the types that can be added to a test case.