-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Check file access information in conformance tests #5102
Check file access information in conformance tests #5102
Conversation
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.
@shashwathi: 0 warnings.
In response to this:
Fixes #4083
Proposed Changes
- Update file conformance test by attempting to read & write to files or dir
/lint
/area test-and-release/assign @dgerd
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.
type permissionBits uint32 | ||
|
||
const ( | ||
userRead permissionBits = 1 << (9 - 1 - iota) |
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.
Should we assign blank identifiers for the ones that are not being used? Looks like only otherRead
and otherWrite
are used.
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.
We've updated to only list the two we use.
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ |
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.
I think the copied license is not the correct format.
Empty line has to be there after line number 5 and 6
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 catch, we've fixed this now
|
||
riFileAccess, ok := ri.Host.FileAccess[path] | ||
if ok && riFileAccess.ReadErr != "" { | ||
return fmt.Errorf("Want no read errors for file %s, got error: %s", path, riFileAccess.ReadErr) |
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.
return fmt.Errorf("Want no read errors for file %s, got error: %s", path, riFileAccess.ReadErr) | |
return fmt.Errorf("want no read errors for file %s, got error: %s", path, riFileAccess.ReadErr) |
return fmt.Errorf("Want no read errors for file %s, got error: %s", path, riFileAccess.ReadErr) | ||
} | ||
if ok && riFileAccess.WriteErr != "" { | ||
return fmt.Errorf("Want no write errors for file %s, got error: %s", path, riFileAccess.WriteErr) |
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.
return fmt.Errorf("Want no write errors for file %s, got error: %s", path, riFileAccess.WriteErr) | |
return fmt.Errorf("want no write errors for file %s, got error: %s", path, riFileAccess.WriteErr) |
e0acbfd
to
ddfe245
Compare
All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the ℹ️ Googlers: Go here for more info. |
@googlebot I consent. |
CLAs look good, thanks! ℹ️ Googlers: Go here for more info. |
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.
Is there a reason why we actually need to test to write and cannot rely on the permission bits to tell us?
var paths []string | ||
for _, path := range filePaths { | ||
excluded := false | ||
for i := len(excludedPaths) - 1; i >= 0 && !excluded; i-- { |
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.
Why not do a way simpler:
for _, excluded := range excludedPaths {
if path == excluded {
excluded = true
break
}
}
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 suggestion. Updated 👍
@markusthoemmes : Great question. I believe the context lies in this conversation #4074 (review) |
"knative.dev/serving/test/types" | ||
) | ||
|
||
type permissionBits uint32 |
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.
https://golang.org/pkg/os/#FileMode should work just as well?
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.
Yeah both FileMode and permissionBits
are both unint32. Reason we went with custom type in this test case was to add the ability to compare permission bits via hasPermission
function. This makes the code more readable.
84d8bd4
to
177228a
Compare
return err | ||
} | ||
readFile, err := os.OpenFile(path, os.O_RDONLY, 0) | ||
defer readFile.Close() |
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.
I am close to be sure that this will panic, if the error is not nil (since if file isn't there it won't open it).
if err != nil {return err}
readFile.Close()
return nil
The following jobs failed:
Automatically retrying due to test flakiness... |
177228a
to
50a7667
Compare
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.
/lgtm
/approve
/hold
for comment
if err != nil { | ||
return err | ||
} | ||
readFile.Close() |
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.
For fun of it we can do return readfile.Close()
, but if you think that can't happen that's fine as well
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: shashwathi, vagababov The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
- Use permissions to determine whether we can read or write to file/directory. - Validate response body for file access information Signed-off-by: Shash Reddy <shashwathireddy@gmail.com>
- Thanks to Markus for suggestion about simplify the logic to get excluded file paths
50a7667
to
49f5e57
Compare
@vagababov : Addressed your comment. Please review again. |
/hold cancel |
/lgtm |
Fixes #4083
Proposed Changes
/lint
/area test-and-release
/assign @dgerd