go-vitess.v1: gopkg.in/src-d/go-vitess.v1/vt/vttablet/endtoend/framework Index | Files

package framework

import "gopkg.in/src-d/go-vitess.v1/vt/vttablet/endtoend/framework"

Index

Package Files

client.go debugschema.go debugvars.go eventcatcher.go querystats.go server.go streamqueryz.go testcase.go

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)
)

func DebugSchema Uses

func DebugSchema() map[string]Table

DebugSchema parses /debug/schema and returns a map of the tables keyed by the table name.

func DebugVars Uses

func DebugVars() map[string]interface{}

DebugVars parses /debug/vars and returns a map. The function returns an empty map on error.

func FetchInt Uses

func FetchInt(vars map[string]interface{}, tags string) int

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 Uses

func FetchJSON(urlPath string) map[string]interface{}

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 Uses

func FetchURL(urlPath string) string

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 Uses

func FetchVal(vars map[string]interface{}, tags string) interface{}

FetchVal fetches the specified slash-separated tag and returns the value as an interface. It returns nil on error, or if not found.

func QueryStats Uses

func QueryStats() map[string]QueryStat

QueryStats parses /debug/query_stats and returns a map of the query stats keyed by the query.

func RowsToStrings Uses

func RowsToStrings(qr *sqltypes.Result) [][]string

RowsToStrings converts qr.Rows to [][]string.

func StartServer Uses

func StartServer(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 StopServer Uses

func StopServer()

StopServer must be called once all the tests are done.

func StreamTerminate Uses

func StreamTerminate(connID int) error

StreamTerminate terminates the specified streaming query.

type MultiCase Uses

type MultiCase struct {
    Name  string
    Cases []Testable
}

MultiCase groups a number of test cases under a name. A MultiCase is also Testable. So, it can be recursive.

func (*MultiCase) Test Uses

func (mc *MultiCase) Test(name string, client *QueryClient) error

Test executes the test cases in MultiCase. The test is interrupted if there is a failure. The name parameter is used if MultiCase doesn't have a Name.

type QueryCatcher Uses

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

QueryCatcher allows you to capture and fetch queries that are being executed by TabletServer.

func NewQueryCatcher Uses

func NewQueryCatcher() QueryCatcher

NewQueryCatcher sets up the capture and retuns a QueryCatcher. You must call Close when done.

func (*QueryCatcher) Close Uses

func (qc *QueryCatcher) Close()

Close closes the QueryCatcher.

func (*QueryCatcher) Next Uses

func (qc *QueryCatcher) Next() (*tabletenv.LogStats, error)

Next fetches the next captured query. If the wait is longer than one second, it returns an error.

type QueryClient Uses

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 NewClient Uses

func NewClient() *QueryClient

NewClient creates a new client for Server.

func NewClientWithContext Uses

func NewClientWithContext(ctx context.Context) *QueryClient

NewClientWithContext creates a new client for Server with the provided context.

func (*QueryClient) Begin Uses

func (client *QueryClient) Begin(clientFoundRows bool) error

Begin begins a transaction.

func (*QueryClient) BeginExecute Uses

func (client *QueryClient) BeginExecute(query string, bindvars map[string]*querypb.BindVariable) (*sqltypes.Result, error)

BeginExecute performs a BeginExecute.

func (*QueryClient) Commit Uses

func (client *QueryClient) Commit() error

Commit commits the current transaction.

func (*QueryClient) CommitPrepared Uses

func (client *QueryClient) CommitPrepared(dtid string) error

CommitPrepared commits a prepared transaction.

func (*QueryClient) ConcludeTransaction Uses

func (client *QueryClient) ConcludeTransaction(dtid string) error

ConcludeTransaction issues a ConcludeTransaction to TabletServer.

func (*QueryClient) CreateTransaction Uses

func (client *QueryClient) CreateTransaction(dtid string, participants []*querypb.Target) error

CreateTransaction issues a CreateTransaction to TabletServer.

func (*QueryClient) Execute Uses

func (client *QueryClient) Execute(query string, bindvars map[string]*querypb.BindVariable) (*sqltypes.Result, error)

Execute executes a query.

func (*QueryClient) ExecuteBatch Uses

func (client *QueryClient) ExecuteBatch(queries []*querypb.BoundQuery, asTransaction bool) ([]sqltypes.Result, error)

ExecuteBatch executes a batch of queries.

func (*QueryClient) ExecuteWithOptions Uses

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) MessageAck Uses

func (client *QueryClient) MessageAck(name string, ids []string) (int64, error)

MessageAck acks messages

func (*QueryClient) MessageStream Uses

func (client *QueryClient) MessageStream(name string, callback func(*sqltypes.Result) error) (err error)

MessageStream streams messages from the message table.

func (*QueryClient) Prepare Uses

func (client *QueryClient) Prepare(dtid string) error

Prepare executes a prepare on the current transaction.

func (*QueryClient) ReadTransaction Uses

func (client *QueryClient) ReadTransaction(dtid string) (*querypb.TransactionMetadata, error)

ReadTransaction returns the transaction metadata.

func (*QueryClient) Rollback Uses

func (client *QueryClient) Rollback() error

Rollback rolls back the current transaction.

func (*QueryClient) RollbackPrepared Uses

func (client *QueryClient) RollbackPrepared(dtid string, originalID int64) error

RollbackPrepared rollsback a prepared transaction.

func (*QueryClient) SetRollback Uses

func (client *QueryClient) SetRollback(dtid string, transactionID int64) error

SetRollback issues a SetRollback to TabletServer.

func (*QueryClient) SetServingType Uses

func (client *QueryClient) SetServingType(tabletType topodatapb.TabletType) error

SetServingType is for testing transitions. It currently supports only master->replica and back.

func (*QueryClient) StartCommit Uses

func (client *QueryClient) StartCommit(dtid string) error

StartCommit issues a StartCommit to TabletServer for the current transaction.

func (*QueryClient) Stream Uses

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) StreamExecute Uses

func (client *QueryClient) StreamExecute(query string, bindvars map[string]*querypb.BindVariable) (*sqltypes.Result, error)

StreamExecute executes a query & returns the results.

func (*QueryClient) StreamExecuteWithOptions Uses

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'.

type QueryStat Uses

type QueryStat struct {
    Query, Table, Plan                                string
    QueryCount, Time, MysqlTime, RowCount, ErrorCount int
}

QueryStat contains the stats for one query.

type StreamQuery Uses

type StreamQuery struct {
    Query             string
    ContextHTML       string
    Start             time.Time
    Duration          int64
    ConnID            int
    State             string
    ShowTerminateLink bool
}

StreamQuery contains the streaming query info.

func StreamQueryz Uses

func StreamQueryz() []StreamQuery

StreamQueryz returns the contents of /streamqueryz?format=json. as a []StreamQuery. The function returns an empty list on error.

type Table Uses

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 Uses

type TableColumn struct {
    Name     string
    Category int
    IsAuto   bool
}

TableColumn contains info about a table's column.

type TestCase Uses

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

    // Rows affected can be nil or an int.
    RowsAffected interface{}

    // 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          interface{}
    Misses        interface{}
    Absent        interface{}
    Invalidations interface{}
}

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) Test Uses

func (tc *TestCase) Test(name string, client *QueryClient) error

Test executes the test case and returns an error if it failed. The name parameter is used if the test case doesn't have a name.

type TestQuery Uses

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) Test Uses

func (tq TestQuery) Test(name string, client *QueryClient) error

Test executes the query and returns an error if it failed.

type Testable Uses

type Testable interface {
    Test(name string, client *QueryClient) error
}

Testable restricts the types that can be added to a test case.

type TxCatcher Uses

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

TxCatcher allows you to capture and fetch transactions that are being executed by TabletServer.

func NewTxCatcher Uses

func NewTxCatcher() TxCatcher

NewTxCatcher sets up the capture and returns a new TxCatcher. You must call Close when done.

func (*TxCatcher) Close Uses

func (tc *TxCatcher) Close()

Close closes the TxCatcher.

func (*TxCatcher) Next Uses

func (tc *TxCatcher) Next() (*tabletserver.TxConnection, error)

Next fetches the next captured transaction. If the wait is longer than one second, it returns an error.

Package framework imports 23 packages (graph). Updated 2019-06-13. Refresh now. Tools for package owners.