Skip to content

Commit

Permalink
Reduce the number of unit tests that require VTROOT by moving testdat…
Browse files Browse the repository at this point in the history
…a closer to the tests

Signed-off-by: David Weitzman <[email protected]>
  • Loading branch information
dweitzman committed Jan 24, 2019
1 parent a88142d commit 349a564
Show file tree
Hide file tree
Showing 50 changed files with 10 additions and 94 deletions.
2 changes: 1 addition & 1 deletion doc/FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ The general convention is to send OLTP queries to `REPLICA` tablet types, and OL

## Is there a list of supported/unsupported queries?

The list of unsupported constructs is currently in the form of test cases contained in this [test file](https://github.com/vitessio/vitess/blob/master/data/test/vtgate/unsupported_cases.txt). However, contrary to the test cases, there is limited support for SET, DDL and DBA constructs. This will be documented soon.
The list of unsupported constructs is currently in the form of test cases contained in this [test file](https://github.com/vitessio/vitess/blob/master/go/vt/vtgate/planbuilder/testdata/unsupported_cases.txt). However, contrary to the test cases, there is limited support for SET, DDL and DBA constructs. This will be documented soon.


## If I have a log of all queries from my app. Is there a way I can try them against vitess to see how they’ll work?
Expand Down
5 changes: 1 addition & 4 deletions go/cgzip/eof_read_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ import (
"io"
"io/ioutil"
"testing"

"vitess.io/vitess/go/testfiles"
)

// specialReader is a test class that will return bytes it reads from a file,
Expand All @@ -33,7 +31,6 @@ type specialReader struct {
}

func newSpecialReader(t *testing.T, filename string) *specialReader {
filename = testfiles.Locate(filename)
b, err := ioutil.ReadFile(filename)
if err != nil {
t.Fatalf("Cannot read file %v: %v", filename, err)
Expand Down Expand Up @@ -61,7 +58,7 @@ func (sr *specialReader) Read(p []byte) (int, error) {
// So it will be read as 32k + 22k, and decompressed into 2MB + 2MB + 1M and
// then 2MB + 2MB + 1M again. So it's a great test for corner cases.
func TestEofAndData(t *testing.T) {
r := newSpecialReader(t, "cgzip_eof.gz")
r := newSpecialReader(t, "testdata/cgzip_eof.gz")
gz, err := NewReader(r)
if err != nil {
t.Fatalf("NewReader failed: %v", err)
Expand Down
File renamed without changes.
64 changes: 0 additions & 64 deletions go/testfiles/locate.go

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 4 additions & 6 deletions go/vt/vtexplain/vtexplain_flaky_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ import (
"path"
"strings"
"testing"

"vitess.io/vitess/go/testfiles"
)

var testOutputTempDir string
Expand All @@ -40,12 +38,12 @@ func defaultTestOpts() *Options {
}

func initTest(mode string, opts *Options, t *testing.T) {
schema, err := ioutil.ReadFile(testfiles.Locate("vtexplain/test-schema.sql"))
schema, err := ioutil.ReadFile("testdata/test-schema.sql")
if err != nil {
t.Fatalf("error: %v", err)
}

vSchema, err := ioutil.ReadFile(testfiles.Locate("vtexplain/test-vschema.json"))
vSchema, err := ioutil.ReadFile("testdata/test-vschema.json")
if err != nil {
t.Fatalf("error: %v", err)
}
Expand Down Expand Up @@ -75,13 +73,13 @@ func runTestCase(testcase, mode string, opts *Options, t *testing.T) {
t.Logf("vtexplain test: %s mode: %s", testcase, mode)
initTest(mode, opts, t)

sqlFile := testfiles.Locate(fmt.Sprintf("vtexplain/%s-queries.sql", testcase))
sqlFile := fmt.Sprintf("testdata/%s-queries.sql", testcase)
sql, err := ioutil.ReadFile(sqlFile)
if err != nil {
t.Fatalf("vtexplain error: %v", err)
}

textOutFile := testfiles.Locate(fmt.Sprintf("vtexplain/%s-output/%s-output.txt", mode, testcase))
textOutFile := fmt.Sprintf("testdata/%s-output/%s-output.txt", mode, testcase)
textOut, _ := ioutil.ReadFile(textOutFile)

explains, err := Run(string(sql))
Expand Down
7 changes: 1 addition & 6 deletions go/vt/vtgate/planbuilder/plan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,10 @@ import (
"fmt"
"io"
"os"
"path"
"strings"
"testing"

"vitess.io/vitess/go/sqltypes"
"vitess.io/vitess/go/testfiles"
"vitess.io/vitess/go/vt/key"
"vitess.io/vitess/go/vt/sqlparser"
"vitess.io/vitess/go/vt/topo/topoproto"
Expand Down Expand Up @@ -334,8 +332,5 @@ func iterateExecFile(name string) (testCaseIterator chan testCase) {
}

func locateFile(name string) string {
if path.IsAbs(name) {
return name
}
return testfiles.Locate("vtgate/" + name)
return "testdata/" + name
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 1 addition & 6 deletions go/vt/vtgate/vindexes/numeric_static_map_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,14 @@ import (
"strings"

"vitess.io/vitess/go/sqltypes"
"vitess.io/vitess/go/testfiles"
"vitess.io/vitess/go/vt/key"
)

// createVindex creates the "numeric_static_map" vindex object which is used by
// each test.
//
// IMPORTANT: This code is called per test and must not be called from init()
// because our internal implementation of testfiles.Locate() does not support to
// be called from init().
func createVindex() (Vindex, error) {
m := make(map[string]string)
m["json_path"] = testfiles.Locate("vtgate/numeric_static_map_test.json")
m["json_path"] = "testdata/numeric_static_map_test.json"
return CreateVindex("numeric_static_map", "numericStaticMap", m)
}

Expand Down
9 changes: 2 additions & 7 deletions go/vt/vttablet/tabletserver/planbuilder/plan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,11 @@ import (
"io/ioutil"
"log"
"os"
"path"
"path/filepath"
"strings"
"testing"

"vitess.io/vitess/go/sqltypes"
"vitess.io/vitess/go/testfiles"
"vitess.io/vitess/go/vt/sqlparser"
"vitess.io/vitess/go/vt/tableacl"
"vitess.io/vitess/go/vt/vttablet/tabletserver/schema"
Expand Down Expand Up @@ -112,7 +110,7 @@ func TestPlan(t *testing.T) {
}

func TestCustom(t *testing.T) {
testSchemas := testfiles.Glob("tabletserver/*_schema.json")
testSchemas, _ := filepath.Glob("testdata/*_schema.json")
if len(testSchemas) == 0 {
t.Log("No schemas to test")
return
Expand Down Expand Up @@ -325,8 +323,5 @@ func iterateExecFile(name string) (testCaseIterator chan testCase) {
}

func locateFile(name string) string {
if path.IsAbs(name) {
return name
}
return testfiles.Locate("tabletserver/" + name)
return "testdata/" + name
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 349a564

Please sign in to comment.