-
Notifications
You must be signed in to change notification settings - Fork 40.1k
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
Sketch: a third take on defaulting values #2587
Conversation
This still fails round-trip tests. Ideas there?
Liking the look of this more. I expect if you tell the fuzzer not to generate blank strings, then round-trip would pass. Longer-term, we need two separate fuzz tests:
The second one ought to get fuzz functions that generate a random but valid setting for enum fields; this would also make the round-trip test pass for you, I expect. |
Brian asked for test that was failing. As an example, it looks like the default value for Volume.Source is being used. Not sure why the fuzzer doesn't descend. Maybe that's the better fix?
|
How hard would it be to use the same approach to diffing that we plan to use for config: only diff the fields set in the source? |
) | ||
|
||
func init() { | ||
api.Scheme.AddDefaultingFuncs( |
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.
This is pretty clear/clean. I like it.
New push is up with a new commit that hacks a bit at the testing. @lavalamp might be that improving the fuzzer lib could help... |
@bgrant0607 what does "set" mean for somethign that did not come from JSON/YAML? All fields are set, just some are set to nil or "" |
How do we ensure that objects created this way are valid? We could create versioned objects, marshal them, decode, encode, compare set fields, re-decode, and compare with previously decoded objects. |
They are not valid in the sense of validation would pass them, but all this test is verifying is round-trip between internal and external - all of the registered conversion functions. This has been sufficient and useful so far, but maybe not any further. Would be nice if it still held. |
Can one of the admins verify this patch? |
@@ -138,6 +145,16 @@ var apiObjectFuzzer = fuzz.New().NilChance(.5).NumElements(1, 1).Funcs( | |||
c.RandString(): c.RandString(), | |||
} | |||
}, | |||
func(rp *api.RestartPolicy, c fuzz.Continue) { | |||
// Exactly one of the fields should be set. | |||
//FIXME: the fuzz can still end up nil. What if fuzz allowed me to say that? |
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.
Just look up a bit at the "NilChance(.5)". Maybe fuzz.Continue should let you modify that temporarily.
What is blocking us on making progress of this PR beside rebase? |
I think this was blocked on a couple fuzzer-related things:
Alternatives for (1) are to apply defaults before round-tripping or to only diff selected fields, as we plan to do in config, such as by keeping track of which fields the fuzzer populates. I think the only sane thing to do for (2) is to ensure that we round-trip only valid objects. This means they must have defaults applied and must pass validation. |
A solution to 1 is to use the Semantic.DeepEqual I added the other day, or make a separate one that specifically ignores defaults (probably a good idea anyway). The conversion routines don't have to do correct things on random input, but they must NOT crash. Fuzz testing should continue to be used to verify this property even if we have to do something more fancy to verify the round-trip property. There should be two tests here, not the one we have right now. |
Main blocker is a person. To work on it.
|
#3854 has been merged. This is obsolete. |
This still fails round-trip tests. Ideas there?
ref #1502