Skip to content

Commit

Permalink
feat: only generate queries that have fk checks turned on for the ben…
Browse files Browse the repository at this point in the history
…chmark

Signed-off-by: Manan Gupta <[email protected]>
  • Loading branch information
GuptaManan100 committed Nov 24, 2023
1 parent 7f7e7b4 commit 2ef8fa6
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion go/test/endtoend/vtgate/foreignkey/fk_fuzz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ type fuzzer struct {
updateShare int
concurrency int
queryFormat QueryFormat
noFkSetVar bool
fkState *bool

// shouldStop is an internal state variable, that tells the fuzzer
Expand Down Expand Up @@ -85,6 +86,7 @@ func newFuzzer(concurrency int, maxValForId int, maxValForCol int, insertShare i
updateShare: updateShare,
queryFormat: queryFormat,
fkState: fkState,
noFkSetVar: false,
wg: sync.WaitGroup{},
}
// Initially the fuzzer thread is stopped.
Expand Down Expand Up @@ -477,7 +479,7 @@ func (fz *fuzzer) generateParameterizedDeleteQuery() (query string, params []any

// getSetVarFkChecksVal generates an optimizer hint to randomly set the foreign key checks to on or off or leave them unaltered.
func (fz *fuzzer) getSetVarFkChecksVal() string {
if fz.concurrency != 1 {
if fz.concurrency != 1 || fz.noFkSetVar {
return ""
}
val := rand.Intn(3)
Expand Down Expand Up @@ -720,6 +722,7 @@ func BenchmarkFkFuzz(b *testing.B) {
startBenchmark(b)
// Create a fuzzer to generate and store a certain set of queries.
fz := newFuzzer(1, maxValForId, maxValForCol, insertShare, deleteShare, updateShare, SQLQueries, nil)
fz.noFkSetVar = true
var queries []string
for j := 0; j < numQueries; j++ {
genQueries := fz.generateQuery()
Expand Down

0 comments on commit 2ef8fa6

Please sign in to comment.