Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions go/vt/vttablet/endtoend/framework/testcase.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
// a test case.
type Testable interface {
Test(name string, client *QueryClient) error
Benchmark(client *QueryClient) error
}

var (
Expand Down Expand Up @@ -59,6 +60,12 @@ func (tq TestQuery) Test(name string, client *QueryClient) error {
return nil
}

// Benchmark executes the query and discards the results
func (tq TestQuery) Benchmark(client *QueryClient) error {
_, err := exec(client, string(tq), nil)
return err
}

// 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.
Expand Down Expand Up @@ -100,6 +107,12 @@ type TestCase struct {
Invalidations interface{}
}

// Benchmark executes the test case and discards the results without verifying them
func (tc *TestCase) Benchmark(client *QueryClient) error {
_, err := exec(client, tc.Query, tc.BindVars)
return err
}

// 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.
func (tc *TestCase) Test(name string, client *QueryClient) error {
Expand Down Expand Up @@ -221,3 +234,15 @@ func (mc *MultiCase) Test(name string, client *QueryClient) error {
}
return nil
}

// Benchmark executes the test cases in MultiCase and discards the
// results without validating them.
func (mc *MultiCase) Benchmark(client *QueryClient) error {
for _, tcase := range mc.Cases {
if err := tcase.Benchmark(client); err != nil {
client.Rollback()
return err
}
}
return nil
}
Loading