-
Notifications
You must be signed in to change notification settings - Fork 2
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
eggyhead
wants to merge
3
commits into
rotationalio:main
Choose a base branch
from
eggyhead:eggyhead/fuzz-testing-versions
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
## Fuzz Tests | ||
|
||
### Background | ||
To help us catch edge cases, we use a strategy to generate inputs called [fuzzing](https://go.dev/security/fuzz/) | ||
|
||
Fuzzing is native in Go 1.18, but only for the following input types: | ||
> string, []byte | ||
|
||
> int, int8, int16, int32/rune, int64 | ||
|
||
> uint, uint8/byte, uint16, uint32, uint64 | ||
|
||
> float32, float64 | ||
|
||
> bool | ||
|
||
To test struct inputs, we use a library called [`go-fuzz-headers`](https://github.com/AdaLogics/go-fuzz-headers#projects-that-use-go-fuzz-headers) | ||
|
||
|
||
### Running Fuzz Tests | ||
Since fuzzing involves generating inputs at time intervals, you explicitly run the tests with the `-fuzz` option. | ||
|
||
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=FuzzVersionManager_Delete -v` | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,11 +3,12 @@ module github.com/rotationalio/honu | |
go 1.16 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We'll have to update this to go 1.19 for the tests to pass! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please do! |
||
|
||
require ( | ||
github.com/AdaLogics/go-fuzz-headers v0.0.0-20221007124625-37f5449ff7df | ||
github.com/cockroachdb/pebble v0.0.0-20211021161301-9106d5d2238f | ||
github.com/gogo/protobuf v1.3.2 // indirect | ||
github.com/golang/protobuf v1.5.2 | ||
github.com/klauspost/compress v1.12.3 // indirect | ||
github.com/stretchr/testify v1.6.1 | ||
github.com/stretchr/testify v1.7.0 | ||
github.com/syndtr/goleveldb v1.0.0 | ||
google.golang.org/grpc v1.39.0 | ||
google.golang.org/protobuf v1.27.1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, thank you!