Skip to content

add test for preserved intermediate folder permissions#2477

Merged
enkore merged 2 commits intoborgbackup:masterfrom
edgimar:master
May 21, 2017
Merged

add test for preserved intermediate folder permissions#2477
enkore merged 2 commits intoborgbackup:masterfrom
edgimar:master

Conversation

@edgimar
Copy link
Copy Markdown
Contributor

@edgimar edgimar commented May 2, 2017

This tests whether the permissions metadata is preserved when a folder is excluded but still recursed into to find a matching file in a subfolder.

To my surprise, it passes, which seems to indicate that the concern raised by @ThomasWaldmann in PR #2322 may not be a problem after all.

This tests whether the permissions metadata is preserved when a folder is excluded but still recursed into to find a matching file in a subfolder.
@edgimar
Copy link
Copy Markdown
Contributor Author

edgimar commented May 2, 2017

@codecov-io
Copy link
Copy Markdown

codecov-io commented May 3, 2017

Codecov Report

Merging #2477 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@          Coverage Diff           @@
##           master   #2477   +/-   ##
======================================
  Coverage    83.1%   83.1%           
======================================
  Files          21      21           
  Lines        7586    7586           
  Branches     1289    1289           
======================================
  Hits         6304    6304           
  Misses        926     926           
  Partials      356     356

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7c9a57b...eb51c3c. Read the comment docs.

@ThomasWaldmann
Copy link
Copy Markdown
Member

@edgimar right, the stat.S_IF* part at both places looks wrong.

stat.S_IF* is for interpreting the type-part of the mode and can not be used to set it (AFAIK), so that should be removed at both places.

Separate PR please.

@edgimar
Copy link
Copy Markdown
Contributor Author

edgimar commented May 9, 2017

any thoughts on whether this test is OK? Is it legitimately testing for metadata preservation? If so, does it mean that we don't need to do anything to try to ensure that "intermediate" nested folders are explicitly included in the backup?


def test_create_pattern_intermediate_folder_permissions(self):
"""test for correct metadata when patterns exclude a parent folder but include a child"""
self.patterns_file_path2 = os.path.join(self.tmpdir, 'patterns2')
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

is "self." needed for this?

self.create_regular_file('x/b/foo_b', size=1024 * 80)
with changedir('input'):
os.chmod('x/a', 0o750)
os.chmod('x/b', 0o700)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

maybe use 0o600 here so we have a difference in owner x bit, which is usually never masked by umask.


for fname, mode in [('x/a', 0o750), ('x/b', 0o700)]:
st = os.stat(fname)
self.assert_equal(st.st_mode & 0o777, mode)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

hmm, wasn't the point of this test to make an assertion about 'x' (which is excluded) rather than 'x/a' and 'x/b', which both are normally included files?

@enkore
Copy link
Copy Markdown
Contributor

enkore commented May 9, 2017

I'd approach this differently. Tests using chmod/chown/chgrp and such frequently fall apart (though it does pass) for various reasons.

Since the test wants to assert that the parent directories are included, I'd just borg list (--format "{type} {path}{NL}" seems handy here) and check that the directories are in there before the files. That way the test only needs to setup the directory structure, but doesn't need to set nor verify permission bits.

@ThomasWaldmann
Copy link
Copy Markdown
Member

@enkore yup, sounds good and easy.

@ThomasWaldmann
Copy link
Copy Markdown
Member

@edgimar can you update your PR?

Removed last test, and replaced with simpler test to verify that an intermediate folder is included in the archive prior to its contents when a folder is excluded but still recursed into to find a matching file in a subfolder.
@edgimar
Copy link
Copy Markdown
Contributor Author

edgimar commented May 20, 2017

@ThomasWaldmann done.

Copy link
Copy Markdown
Member

@ThomasWaldmann ThomasWaldmann left a comment

Choose a reason for hiding this comment

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

looks good. before merging, we need to collapse the changesets.

@enkore enkore merged commit ed14181 into borgbackup:master May 21, 2017
@enkore
Copy link
Copy Markdown
Contributor

enkore commented May 22, 2017

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants