diff --git a/main.go b/main.go index 1fc2311..f5930a2 100644 --- a/main.go +++ b/main.go @@ -18,8 +18,6 @@ import ( "flag" "fmt" "os" - "path/filepath" - "strings" log "github.com/sirupsen/logrus" "vitess.io/vitess/go/mysql" @@ -37,7 +35,6 @@ var ( olap bool vschemaFile string xunit bool - testDir string ) func init() { @@ -46,33 +43,12 @@ func init() { flag.BoolVar(&sharded, "sharded", false, "run all tests on a sharded keyspace") flag.StringVar(&vschemaFile, "vschema", "", "Disable auto-vschema by providing your own vschema file") flag.BoolVar(&xunit, "xunit", false, "Get output in an xml file instead of errors directory") - flag.StringVar(&testDir, "test-dir", "./t/", "Directory for the test files") -} - -func loadAllTests() (tests []string, err error) { - // tests must be in t folder or subdir in t folder - err = filepath.Walk(testDir, func(path string, info os.FileInfo, err error) error { - if err != nil { - return err - } - - if !info.IsDir() && strings.HasSuffix(path, ".test") { - name := strings.TrimSuffix(info.Name(), ".test") - tests = append(tests, name) - } - return nil - }) - - if err != nil { - return nil, err - } - return tests, nil } func executeTests(clusterInstance *cluster.LocalProcessCluster, vtParams, mysqlParams mysql.ConnParams, fileNames []string, s vitess_tester.Suite) (failed bool) { for _, name := range fileNames { errReporter := s.NewReporterForFile(name) - vTester := vitess_tester.NewTester(name, errReporter, clusterInstance, vtParams, mysqlParams, olap, keyspaceName, vschema, testDir, vschemaFile) + vTester := vitess_tester.NewTester(name, errReporter, clusterInstance, vtParams, mysqlParams, olap, keyspaceName, vschema, vschemaFile) err := vTester.Run() if err != nil { failed = true @@ -240,12 +216,9 @@ func main() { log.SetLevel(ll) } - // we will run all tests if no tests assigned if len(tests) == 0 { - var err error - if tests, err = loadAllTests(); err != nil { - log.Fatalf("load all tests err %v", err) - } + log.Errorf("no tests specified") + os.Exit(1) } log.Infof("running tests: %v", tests) diff --git a/src/vitess-tester/tester.go b/src/vitess-tester/tester.go index 92ed763..5d37737 100644 --- a/src/vitess-tester/tester.go +++ b/src/vitess-tester/tester.go @@ -36,7 +36,6 @@ import ( ) type tester struct { - dir string name string clusterInstance *cluster.LocalProcessCluster @@ -59,14 +58,14 @@ type tester struct { reporter Reporter } -func NewTester(name string, reporter Reporter, +func NewTester( + name string, + reporter Reporter, clusterInstance *cluster.LocalProcessCluster, - vtParams, - mysqlParams mysql.ConnParams, + vtParams, mysqlParams mysql.ConnParams, olap bool, keyspaceName string, vschema vindexes.VSchema, - dir string, vschemaFile string, ) *tester { t := &tester{ @@ -78,7 +77,6 @@ func NewTester(name string, reporter Reporter, keyspaceName: keyspaceName, vschema: vschema, vschemaFile: vschemaFile, - dir: dir, olap: olap, } return t @@ -275,7 +273,7 @@ func (t *tester) readData() ([]byte, error) { defer res.Body.Close() return io.ReadAll(res.Body) } - return os.ReadFile(t.testFileName()) + return os.ReadFile(t.name) } func (t *tester) execute(query query) error { @@ -402,10 +400,6 @@ func (t *tester) handleCreateTable(create *sqlparser.CreateTable) { } } -func (t *tester) testFileName() string { - return fmt.Sprintf("%s/%s.test", t.dir, t.name) -} - func (t *tester) Errorf(format string, args ...interface{}) { t.reporter.AddFailure(t.vschema, errors.Errorf(format, args...)) }