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

validate/validate_test: Add linux.rootfsPropagation checks #476

Merged
Merged
Changes from all commits
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
34 changes: 34 additions & 0 deletions validate/validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,40 @@ func TestJSONSchema(t *testing.T) {
},
error: "process.args: Invalid type. Expected: array, given: null",
},
{
config: &rspec.Spec{
Version: "1.0.0",
Linux: &rspec.Linux{},
},
error: "",
},
{
config: &rspec.Spec{
Version: "1.0.0",
Linux: &rspec.Linux{
RootfsPropagation: "",

Choose a reason for hiding this comment

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

"" is not valid value for RootfsPropagation why error is ""?

Copy link
Contributor Author

@wking wking Sep 15, 2017

Choose a reason for hiding this comment

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

"" is not valid value for RootfsPropagation why error is ""?

I expect because it's omitempty, although I haven't tracked that down to specific gojsonschema code.

Choose a reason for hiding this comment

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

I think omitempty means it can be unset but not ""

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think omitempty means it can be unset but not ""

For a non-pointer omitempty like RootfsPropagation, an empty string is as close as you can get to unset.

Choose a reason for hiding this comment

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

I think the RootfsPropagation: "" test should be deleted.

Copy link
Contributor Author

@wking wking Sep 18, 2017

Choose a reason for hiding this comment

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

I think the RootfsPropagation: "" test should be deleted.

Why? With the current non-pointer property, that's how you explicitly unset the property. I think we need to be sure clearing RootfsPropagation is legal, because as this thread demonstrates, it's not immediately obvious.

Choose a reason for hiding this comment

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

If it is not set, its value is also "", which is repeated with the previous test (without setting the value), and I think the test of this value is meaningless.

Copy link
Contributor Author

@wking wking Sep 18, 2017

Choose a reason for hiding this comment

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

If it is not set, its value is also "", which is repeated with the previous test (without setting the value)...

Yeah, but it doesn't hurt to double check, and the explicit-empty-string case surprised @Mashimiao at first. If test rephrasings help expose surprises, I think we want them.

},
},
error: "",
},
{
config: &rspec.Spec{
Version: "1.0.0",
Linux: &rspec.Linux{
RootfsPropagation: "shared",
},
},
error: "",
},
{
config: &rspec.Spec{
Version: "1.0.0",
Linux: &rspec.Linux{
RootfsPropagation: "rshared",
},
},
error: "linux.rootfsPropagation: linux.rootfsPropagation must be one of the following: \"private\", \"shared\", \"slave\", \"unbindable\"",
},
{
config: &rspec.Spec{
Version: "1.0.0-rc5",
Expand Down