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

Check file access information in conformance tests #5102

Merged
merged 4 commits into from
Oct 29, 2019

Conversation

shashwathi
Copy link
Contributor

Fixes #4083

Proposed Changes

  • Update file conformance test by attempting to read & write to files or dir

/lint
/area test-and-release

/assign @dgerd

@knative-prow-robot knative-prow-robot added the area/test-and-release It flags unit/e2e/conformance/perf test issues for product features label Aug 8, 2019
@googlebot googlebot added the cla: yes Indicates the PR's author has signed the CLA. label Aug 8, 2019
@knative-prow-robot knative-prow-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Aug 8, 2019
Copy link
Contributor

@knative-prow-robot knative-prow-robot left a 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)
Copy link
Contributor

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.

Copy link
Member

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.
*/
Copy link
Contributor

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

Copy link
Member

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)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
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)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
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)

@googlebot
Copy link

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 @googlebot I consent. in this pull request.

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 cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

@googlebot googlebot added cla: no Indicates the PR's author has not signed the CLA. and removed cla: yes Indicates the PR's author has signed the CLA. labels Sep 30, 2019
@andrew-su
Copy link
Member

@googlebot I consent.

@googlebot
Copy link

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

@googlebot googlebot added cla: yes Indicates the PR's author has signed the CLA. and removed cla: no Indicates the PR's author has not signed the CLA. labels Sep 30, 2019
Copy link
Contributor

@markusthoemmes markusthoemmes left a 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-- {
Copy link
Contributor

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
  }
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for suggestion. Updated 👍

@shashwathi
Copy link
Contributor Author

@markusthoemmes : Great question. I believe the context lies in this conversation #4074 (review)

"knative.dev/serving/test/types"
)

type permissionBits uint32
Copy link
Contributor

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?

Copy link
Contributor Author

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.

return err
}
readFile, err := os.OpenFile(path, os.O_RDONLY, 0)
defer readFile.Close()
Copy link
Contributor

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

@knative-test-reporter-robot

The following jobs failed:

Test name Triggers Retries
pull-knative-serving-integration-tests pull-knative-serving-integration-tests 1/3

Automatically retrying due to test flakiness...
/test pull-knative-serving-integration-tests

Copy link
Contributor

@vagababov vagababov left a 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()
Copy link
Contributor

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

@knative-prow-robot knative-prow-robot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. lgtm Indicates that a PR is ready to be merged. labels Oct 29, 2019
@knative-prow-robot
Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@knative-prow-robot knative-prow-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 29, 2019
shashwathi and others added 4 commits October 29, 2019 09:45
- 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
@knative-prow-robot knative-prow-robot removed the lgtm Indicates that a PR is ready to be merged. label Oct 29, 2019
@shashwathi
Copy link
Contributor Author

@vagababov : Addressed your comment. Please review again.

@shashwathi
Copy link
Contributor Author

/hold cancel

@knative-prow-robot knative-prow-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 29, 2019
@vagababov
Copy link
Contributor

/lgtm

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Oct 29, 2019
@knative-prow-robot knative-prow-robot merged commit 8fb75cc into knative:master Oct 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/test-and-release It flags unit/e2e/conformance/perf test issues for product features cla: yes Indicates the PR's author has signed the CLA. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve Filesystem Conformance tests
10 participants