Skip to content

Commit

Permalink
Add skip_e2e to the plan tests
Browse files Browse the repository at this point in the history
Signed-off-by: Florent Poinsard <[email protected]>
  • Loading branch information
frouioui committed Oct 29, 2024
1 parent 31229d9 commit ff82993
Show file tree
Hide file tree
Showing 3 changed files with 278 additions and 115 deletions.
12 changes: 12 additions & 0 deletions go/test/endtoend/utils/cmp.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,18 @@ func (mcmp *MySQLCompare) Exec(query string) *sqltypes.Result {
return vtQr
}

// ExecAssert is the same as Exec, but it only does assertions, it won't FailNow
func (mcmp *MySQLCompare) ExecAssert(query string) *sqltypes.Result {
mcmp.t.Helper()
vtQr, err := mcmp.VtConn.ExecuteFetch(query, 1000, true)
assert.NoError(mcmp.t, err, "[Vitess Error] for query: "+query)

mysqlQr, err := mcmp.MySQLConn.ExecuteFetch(query, 1000, true)
assert.NoError(mcmp.t, err, "[MySQL Error] for query: "+query)
compareVitessAndMySQLResults(mcmp.t, query, mcmp.VtConn, vtQr, mysqlQr, CompareOptions{})
return vtQr
}

// ExecNoCompare executes the query on vitess and mysql but does not compare the result with each other.
func (mcmp *MySQLCompare) ExecNoCompare(query string) (*sqltypes.Result, *sqltypes.Result) {
mcmp.t.Helper()
Expand Down
42 changes: 40 additions & 2 deletions go/test/endtoend/vtgate/queries/plan_tests/plan_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
Copyright 2024 The Vitess Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package plan_tests

import (
Expand All @@ -21,6 +37,7 @@ func readJSONTests(filename string) []planbuilder.PlanTest {
if err != nil {
panic(err)
}
defer file.Close()
dec := json.NewDecoder(file)
err = dec.Decode(&output)
if err != nil {
Expand All @@ -36,12 +53,30 @@ func locateFile(name string) string {
func TestPlan(t *testing.T) {
mcmp, closer := start(t)
defer closer()
tests := readJSONTests("select_cases.json")
tests := readJSONTests("select_cases_new.json")
for _, test := range tests {
if test.SkipE2E {
continue
}
mcmp.Run(test.Query, func(mcmp *utils.MySQLCompare) {
mcmp.Exec(test.Query)
// if mcmp.AsT().Failed() {
// tests[i].SkipE2E = true
// }
})
}

// file, err := os.Create(locateFile("select_cases_new.json"))
// if err != nil {
// panic(err)
// }
// defer file.Close()
//
// enc := json.NewEncoder(file)
// enc.SetEscapeHTML(false)
// enc.SetIndent("", " ")
// err = enc.Encode(tests)
// require.NoError(t, err)
}

var (
Expand Down Expand Up @@ -119,6 +154,7 @@ func TestMain(m *testing.M) {
// Start topo server
err := clusterInstance.StartTopo()
if err != nil {
fmt.Println(err.Error())
return 1
}

Expand All @@ -130,6 +166,7 @@ func TestMain(m *testing.M) {
}
err = clusterInstance.StartKeyspace(*keyspace, []string{"-80", "80-"}, 0, false)
if err != nil {
fmt.Println(err.Error())
return 1
}

Expand All @@ -142,6 +179,7 @@ func TestMain(m *testing.M) {
// Start vtgate
err = clusterInstance.StartVtgate()
if err != nil {
fmt.Println(err.Error())
return 1
}

Expand All @@ -150,7 +188,7 @@ func TestMain(m *testing.M) {
// create mysql instance and connection parameters
conn, closer, err := utils.NewMySQL(clusterInstance, keyspaceName, schemaSQL)
if err != nil {
fmt.Println(err)
fmt.Println(err.Error())
return 1
}
defer closer()
Expand Down
Loading

0 comments on commit ff82993

Please sign in to comment.