Skip to content

Commit

Permalink
Merge pull request #28 from kinshukdua/seed
Browse files Browse the repository at this point in the history
Add seed as CLA for reproducible fuzzing
  • Loading branch information
PumpkinSeed authored Oct 7, 2021
2 parents 30d6c79 + 411ddde commit 54b18bc
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ sqlfuzz -u username -p password -d database -h 127.0.0.1 -t table -n 100000 -w 1
- `t`: Table for fuzzing
- `n`: Number of rows to fuzz
- `w`: Concurrent workers to work on fuzzing
- `s`: Seed value for reproducibility of data

### Package usage

Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (

func main() {
f := flags.Get()
gofakeit.Seed(0)
gofakeit.Seed(int64(f.Seed))
driver := drivers.New(f.Driver)
db := connector.Connection(driver, f)
defer db.Close()
Expand Down
12 changes: 8 additions & 4 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ func TestFuzz(t *testing.T) {
f.Parsed = true
f.Num = 10
f.Workers = 2
f.Seed = 1

gofakeit.Seed(0)
gofakeit.Seed(int64(f.Seed))
driver := drivers.New(f.Driver)
testable := drivers.NewTestable(f.Driver)
db := connector.Connection(driver, f)
Expand Down Expand Up @@ -82,8 +83,9 @@ func TestFuzzPostgres(t *testing.T) {
f.Parsed = true
f.Num = 10
f.Workers = 2
f.Seed = 1

gofakeit.Seed(0)
gofakeit.Seed(int64(f.Seed))
driver := drivers.New(f.Driver)
testable := drivers.NewTestable(f.Driver)
db := connector.Connection(driver, f)
Expand Down Expand Up @@ -149,8 +151,9 @@ func TestMysqlMultiInsert(t *testing.T) {
f.Parsed = true
f.Num = 10
f.Workers = 2
f.Seed = 1

gofakeit.Seed(0)
gofakeit.Seed(int64(f.Seed))
driver := drivers.New(f.Driver)
testable := drivers.NewTestable(f.Driver)
test, err := testable.GetTestCase("multi")
Expand Down Expand Up @@ -190,8 +193,9 @@ func TestPostgresMultiInsert(t *testing.T) {
f.Parsed = true
f.Num = 10
f.Workers = 2
f.Seed = 1

gofakeit.Seed(0)
gofakeit.Seed(int64(f.Seed))
driver := drivers.New(f.Driver)
testable := drivers.NewTestable(f.Driver)
test, err := testable.GetTestCase("multi")
Expand Down
2 changes: 2 additions & 0 deletions pkg/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type Flags struct {
ConnMaxLifetimeInSec time.Duration
MaxIdleConns int
MaxOpenConns int
Seed int

Parsed bool
}
Expand Down Expand Up @@ -46,6 +47,7 @@ func parse() {
flag.IntVar(&f.Workers, "w", 20, "Number of workers")
flag.IntVar(&f.MaxIdleConns, "i", 200, "Number of max sql db idle connections")
flag.IntVar(&f.MaxOpenConns, "o", 1000, "Number of max sql db open connections")
flag.IntVar(&f.Seed, "s", 0, "Seed value for reproducibility")
flag.DurationVar(&f.ConnMaxLifetimeInSec, "l", 100*time.Second, "Maximum lifetime of each open connection")
flag.Parse()
}
Expand Down

0 comments on commit 54b18bc

Please sign in to comment.