Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improving random query generation for endtoend testing #13460

Merged
merged 29 commits into from
Aug 17, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
3d10df5
added flag for if the randomly generated query can have aggregation
arvind-murty Jun 30, 2023
b40e319
added ExprGeneratorConfig to random expression generation
arvind-murty Jul 4, 2023
54368c6
refactor tableT struct
arvind-murty Jul 4, 2023
0b07313
simplified random predicate generation
arvind-murty Jul 6, 2023
f14943d
refactor column struct
arvind-murty Jul 8, 2023
e005e78
added aggregation to random expressions and changed random query gene…
arvind-murty Jul 10, 2023
8e28e60
added queryGen struct to pass along Rand and ExprGeneratorConfig
arvind-murty Jul 11, 2023
f32f5dd
added random column aliases
arvind-murty Jul 13, 2023
e92b3c2
added more complex aggregate expressions
arvind-murty Jul 13, 2023
1953053
added scalar subqueries to fuzzer
arvind-murty Jul 16, 2023
bf53801
added scalar subqueries to all random expression generation for the f…
arvind-murty Jul 17, 2023
98055b7
added support for tuple random expressions
arvind-murty Jul 18, 2023
dccd6ec
added support for random expressions with exists
arvind-murty Jul 19, 2023
35e045b
added union queries in fuzzer
arvind-murty Jul 20, 2023
13c89ca
added tuple comparisons to random expression generator
arvind-murty Jul 21, 2023
60ec73c
exported vschemaWrapper to go/test/utils
arvind-murty Jul 21, 2023
a0acb5a
added query simplification to fuzzer
arvind-murty Jul 24, 2023
a28cd5f
simplified vschema and schema for simplifying fuzzer queries
arvind-murty Jul 24, 2023
ce019af
added simplification for case expressions
arvind-murty Jul 24, 2023
10c2034
moved VSchemaWrapper to its own package
arvind-murty Jul 24, 2023
a066e09
updated caseExpr simplification and reverted reverted simplifier changes
arvind-murty Jul 25, 2023
a2f7920
added sqlparser.NewCaseExpr
arvind-murty Jul 25, 2023
1d2ab6c
removed separate testing runs from simplifier in query fuzzer
arvind-murty Jul 26, 2023
756ad95
simplified existing results mismatched queries
arvind-murty Jul 26, 2023
359189e
minor fixes/improvements
arvind-murty Jul 27, 2023
a60a1c2
fixed goimports and failing endtoend tests
arvind-murty Jul 28, 2023
6736793
skip TestRandom
arvind-murty Jul 28, 2023
2c85a63
Merge remote-tracking branch 'upstream/main' into am-random-2
systay Aug 9, 2023
5c159f9
Merge remote-tracking branch 'upstream/main' into am-random-2
systay Aug 9, 2023
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
Prev Previous commit
Next Next commit
fixed goimports and failing endtoend tests
Signed-off-by: Arvind Murty <10248018+arvind-murty@users.noreply.github.com>
  • Loading branch information
arvind-murty committed Jul 28, 2023
commit a60a1c2860b2165233d86b0e44a5d780c874c2c9
3 changes: 0 additions & 3 deletions go/test/endtoend/vtgate/queries/random/query_gen_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ import (

// TestSeed makes sure that the seed is deterministic
func TestSeed(t *testing.T) {
sel, err := sqlparser.Parse("select 1 < any (select empno from emp)")
fmt.Println(sel, err)

// specify the schema (that is defined in schema.sql)
schemaTables := []tableT{
{tableExpr: sqlparser.NewTableName("emp")},
Expand Down
23 changes: 2 additions & 21 deletions go/test/endtoend/vtgate/queries/random/random_expr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,16 @@ limitations under the License.
package random

import (
"fmt"
"math/rand"
"testing"
"time"

"github.com/stretchr/testify/require"

"vitess.io/vitess/go/test/endtoend/utils"

"vitess.io/vitess/go/slices2"
"vitess.io/vitess/go/vt/sqlparser"
)

// This test tests that generating random expressions with a schema does not panic
func TestRandomExprWithTables(t *testing.T) {
//t.Skip("Skip CI")
mcmp, closer := start(t)
defer closer()

require.NoError(t, utils.WaitForAuthoritative(t, keyspaceName, "emp", clusterInstance.VtgateProcess.ReadVSchema))
require.NoError(t, utils.WaitForAuthoritative(t, keyspaceName, "dept", clusterInstance.VtgateProcess.ReadVSchema))

// specify the schema (that is defined in schema.sql)
schemaTables := []tableT{
{tableExpr: sqlparser.NewTableName("emp")},
Expand All @@ -63,16 +51,9 @@ func TestRandomExprWithTables(t *testing.T) {
for i := 0; i < 100; i++ {

seed := time.Now().UnixNano()
fmt.Printf("seed: %d\n", seed)

r := rand.New(rand.NewSource(seed))
genConfig := sqlparser.NewExprGeneratorConfig(sqlparser.CannotAggregate, "", 0, false)
genConfig := sqlparser.NewExprGeneratorConfig(sqlparser.CanAggregate, "", 0, false)
g := sqlparser.NewGenerator(r, 3, slices2.Map(schemaTables, func(t tableT) sqlparser.ExprGenerator { return &t })...)
expr := g.Expression(genConfig)
fmt.Println(sqlparser.String(expr))

from := sqlparser.TableExprs{sqlparser.NewAliasedTableExpr(sqlparser.NewTableName("emp"), ""), sqlparser.NewAliasedTableExpr(sqlparser.NewTableName("dept"), "")}
query := sqlparser.NewSelect(nil, sqlparser.SelectExprs{sqlparser.NewAliasedExpr(expr, "")}, nil, nil, from, nil, nil, nil, nil)
mcmp.ExecAllowAndCompareError(sqlparser.String(query))
g.Expression(genConfig)
}
}
4 changes: 2 additions & 2 deletions go/test/vschemawrapper/vschema_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"context"
"fmt"
"strings"

"vitess.io/vitess/go/mysql/collations"
"vitess.io/vitess/go/sqltypes"
"vitess.io/vitess/go/vt/key"
Expand Down Expand Up @@ -82,8 +83,7 @@ func (vw *VSchemaWrapper) PlanPrepareStatement(ctx context.Context, query string
return plan, stmt, nil
}

func (vw *VSchemaWrapper) ClearPrepareData(lowered string) {
}
func (vw *VSchemaWrapper) ClearPrepareData(string) {}

func (vw *VSchemaWrapper) StorePrepareData(string, *vtgatepb.PrepareData) {}

Expand Down