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

initial version manager fuzz test and testing doc #26

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
2 changes: 1 addition & 1 deletion docs/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ Since fuzzing involves generating inputs at time intervals, you explicitly run t
Watch the output, and view any errors that may arise. When you are satisfied the tests confirm your code working as expected, you can exit the test.

eg.
` go test -fuzz=FuzzNewVersionManager -v`
` go test -fuzz=FuzzVersionManager_Delete -v`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think it would be a good idea to update GitHub actions with fuzzing? Alternatively, we could create a GitHub action that PRs don't depend on that performs fuzzing.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi! Is this question about whether these tests will run automatically?

Currently, the fuzz tests will need to be run manually, as described in the doc.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, thank you!

60 changes: 60 additions & 0 deletions versions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,3 +195,63 @@ func FuzzNewVersionManager(f *testing.F) {
}
})
}

// FuzzVersionManager_Update implements fuzzer for the version manager update method
func FuzzVersionManager_Update(f *testing.F) {
f.Fuzz(func(t *testing.T, data []byte) {
f := fuzz.NewConsumer(data)
c := config.ReplicaConfig{
PID: 8,
Region: "us-east-2c",
}
err := f.GenerateStruct(&c)
if err != nil {
return
}

meta := pb.Object{}
err = f.GenerateStruct(&meta)
if err != nil {
return
}
vm, err := NewVersionManager(c)
if err != nil {
return
}

err = vm.Update(&meta)
if err != nil {
return
}
})
}

// FuzzVersionManager_Delete implements fuzzer for the version manager update method
func FuzzVersionManager_Delete(f *testing.F) {
f.Fuzz(func(t *testing.T, data []byte) {
f := fuzz.NewConsumer(data)
c := config.ReplicaConfig{
PID: 8,
Region: "us-east-2c",
}
err := f.GenerateStruct(&c)
if err != nil {
return
}

meta := pb.Object{}
err = f.GenerateStruct(&meta)
if err != nil {
return
}
vm, err := NewVersionManager(c)
if err != nil {
return
}

err = vm.Delete(&meta)
if err != nil {
return
}
})
}