-
Notifications
You must be signed in to change notification settings - Fork 894
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
Fuzz testing jsonchema #1499
Fuzz testing jsonchema #1499
Conversation
0babd39
to
8100847
Compare
This PR enables
|
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.
Nice, thanks for this! I'm just starting the review, but I have a quick comment:
- Due to the nature of hypothesis testing, failed tests may be discovered at any time that are not related to code changed in a PR.
- Additionally, running this locally it looks like this adds a full minute to the tox py3 environment.
Due to the above reasons, I think we want this separate from the py3
environment, and we may want to think about how (and whether) this works with CI, since a failed test might not correlate to a users changes.
I'm looking forward to digging more into this PR (tomorrow)!
We could create a separated tox and CI environment by:
Thanks for the feedback, and I am also looking forward to integrating this PR, I think |
I agree that we shouldn't include hypothesis in CI. I think it makes more sense as a separate jenkins job and separate tox definition with the test having a mark so that is not run by default (unless it can run fast). My goal in suggesting the Also, running unit tests by directly invoking pytest on the command line leads to |
Noted, I will improve this.
I added
I did not test that, let me check it. |
- Implement JsonLocalResolver to avoid errors in hypothesis-jsonschema due to not resolving json references at all - Handle profile registration for hypothesis<3.47
5fcdc82
to
2561781
Compare
Revert .travis as long tests are going to be run in Jenkins.
2561781
to
4feedc2
Compare
I created a new
|
I made |
I think the real reason for the need of Furthermore, if I remove that schema and execute the test without I am going to mark this PR as WIP and investigate why this is happening. @holmanb |
I think the real reason for the need of JsonLocalResolver is that there is some kind of inconsistency with the cc_users_groups schema which causes hypothesis-jsonschema to fail in the generation of samples. It seems this sub-schema is not fully jsonschema compliant, symptoms:
As this PR is only to enable fuzz testing, I decided to avoid the problem: tests/unittests/config/test_schema.py#L1146
This was my fault, as I was reusing the same schema in hypothesis-jsonschema.given and our validation, but hypothesis do not deep-copy it and as a result I was validating against a modified schema. This PR is ready to be reviewed, @holmanb. |
More of a comment/question than a review: In the run output I see that
I know the docs say they support draft4. Maybe we need to configure a setting to use the correct version? |
Interesting find. Thanks for documenting that. It seems the fuzz tester found it's first bug?
And second bug and ....? |
In your example, they are generating values of a sub-schema If you want me to have a deeper inspection into
Indirectly, yes, as
This was my fault, I described it here: #1499 (comment) |
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.
Thanks for working through our requests and suggestions, I am happy with how this looks.
I know the docs say they support draft4. Maybe we need to configure a setting to use the correct version?
hypothesis-jsonschema
does not offer how to configure / force this. I guess they select the validator depending on the$schema
value.In your example, they are generating values of a sub-schema
{'type': 'string'}
which seems to be a leaf of our schema and does not contain a specified$schema
. I guess they will generate and merge sub-config from leaves to root and the final validator will contain the correctDraft*Validator
as we specify"$schema": "http://json-schema.org/draft-04/schema#"
. But this is only a guess.
Interesting, thanks :)
If you want me to have a deeper inspection into
hypothesis-jsonschema
I can do it.
I don't think that's needed.
Indirectly, yes, as
hypothesis-jsonschema
fails while generating examples from our schema when we do not removecc_users_groups
from it.
Nice :)
This was my fault..
No problem at all. No need for this to be blocked on an external bug it found. Once that is fixed we can circle back and drop the schema cleaning functions. Thanks for putting this together. I think I'm good with it, pending any remaining changes by other reviewers.
@TheRealFalcon Do you have any unresolved issues with this PR? If not I can merge it. I just want to make sure there isn't anything outstanding. |
@holmanb I'm good, thanks! |
Proposed Commit Message
Additional Context
SC-829
Test Steps
pytest tox --recreate -e hypothesis-slow # To test the deb build process make deb
Checklist: