Skip to content

Commit

Permalink
incorporated feedback on e2e testcases
Browse files Browse the repository at this point in the history
Signed-off-by: c-r-dev <[email protected]>
  • Loading branch information
c-r-dev committed Dec 19, 2024
1 parent 1c8e8d7 commit 7ac0eb2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 36 deletions.
6 changes: 3 additions & 3 deletions go/test/endtoend/vtgate/plan_tests/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ func start(t *testing.T) (utils.MySQLCompare, func()) {
}
}

// parseSQL statements - querySQL may be a multi-line sql blob
func parseSQL(querySQL ...string) ([]string, error) {
// splitSQL statements - querySQL may be a multi-line sql blob
func splitSQL(querySQL ...string) ([]string, error) {
parser := sqlparser.NewTestParser()
var sqls []string
for _, sql := range querySQL {
Expand All @@ -145,7 +145,7 @@ func parseSQL(querySQL ...string) ([]string, error) {

func loadSampleData(t *testing.T, mcmp utils.MySQLCompare) {
sampleDataSQL := readFile("sampledata/user.sql")
insertSQL, err := parseSQL(sampleDataSQL)
insertSQL, err := splitSQL(sampleDataSQL)
if err != nil {
require.NoError(t, err)
}
Expand Down
50 changes: 17 additions & 33 deletions go/test/endtoend/vtgate/plan_tests/plan_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,41 +22,25 @@ import (
"vitess.io/vitess/go/test/endtoend/utils"
)

func TestSelectCases(t *testing.T) {
mcmp, closer := start(t)
defer closer()
tests := readJSONTests("select_cases.json")
for _, test := range tests {
mcmp.Run(test.Comment, func(mcmp *utils.MySQLCompare) {
if test.SkipE2E {
mcmp.AsT().Skip(test.Query)
}
mcmp.Exec(test.Query)
pd := utils.ExecTrace(mcmp.AsT(), mcmp.VtConn, test.Query)
verifyTestExpectations(mcmp.AsT(), pd, test)
if mcmp.VtConn.IsClosed() {
mcmp.AsT().Fatal("vtgate connection is closed")
}
})
}
}

func TestFilterCases(t *testing.T) {
func TestE2ECases(t *testing.T) {
e2eTestCaseFiles := []string{"select_cases.json", "filter_cases.json"}
mcmp, closer := start(t)
defer closer()
loadSampleData(t, mcmp)
tests := readJSONTests("filter_cases.json")
for _, test := range tests {
mcmp.Run(test.Comment, func(mcmp *utils.MySQLCompare) {
if test.SkipE2E {
mcmp.AsT().Skip(test.Query)
}
mcmp.Exec(test.Query)
pd := utils.ExecTrace(mcmp.AsT(), mcmp.VtConn, test.Query)
verifyTestExpectations(mcmp.AsT(), pd, test)
if mcmp.VtConn.IsClosed() {
mcmp.AsT().Fatal("vtgate connection is closed")
}
})
for _, fileName := range e2eTestCaseFiles {
tests := readJSONTests(fileName)
for _, test := range tests {
mcmp.Run(test.Comment, func(mcmp *utils.MySQLCompare) {
if test.SkipE2E {
mcmp.AsT().Skip(test.Query)
}
mcmp.Exec(test.Query)
pd := utils.ExecTrace(mcmp.AsT(), mcmp.VtConn, test.Query)
verifyTestExpectations(mcmp.AsT(), pd, test)
if mcmp.VtConn.IsClosed() {
mcmp.AsT().Fatal("vtgate connection is closed")
}
})
}
}
}

0 comments on commit 7ac0eb2

Please sign in to comment.