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

Coalesce directory management to Envoy::TestEnvironment #9721

Merged
merged 16 commits into from
Jan 26, 2020
Merged

Coalesce directory management to Envoy::TestEnvironment #9721

merged 16 commits into from
Jan 26, 2020

Conversation

wrowe
Copy link
Contributor

@wrowe wrowe commented Jan 17, 2020

Description:

  • Drop std::[*]filesystem logic
  • Implement/tests for new Envoy::Filesystem::splitFileName
  • Remove unneeded TestEnvironment::createParentPath
  • Move/rename Envoy::TestUtility::createDirectory to Envoy::TestEnvironment::createPath
  • Move/rename Envoy::TestUtility::removeDirectory to Envoy::TestEnvironment::removePath
  • Move Envoy::TestUtility::renameFile to Envoy::TestEnvironment
  • Move Envoy::TestUtility::createSymlink to Envoy::TestEnvironment
  • Move AtomicFileUpdater from test_common utility to environment
  • Simplify Envoy::Filesystem::Watcher implementations using Filesystem
  • Clean up watcher_impl flavors for splitFileName API
  • Implement/new tests for Envoy::Filesystem::illegalPath for win32
  • Implement watcher_impl for win32 [Initial development by Sam Smith]
  • Ensure top level test tempdir exists when requested

Risk Level: low
Testing: local on linux gcc, windows msvc
Docs Changes: n/a
Release Notes: n/a

tools/check_format.py Outdated Show resolved Hide resolved
wrowe and others added 2 commits January 21, 2020 11:37
- Drop std::[*]filesystem logic
- Implement/tests for new Envoy::Filesystem::splitFileName
- Remove unneeded TestEnvironment::createParentPath
- Move/rename Envoy::TestUtility::createDirectory to Envoy::TestEnvironment::createPath
- Move/rename Envoy::TestUtility::removeDirectory to Envoy::TestEnvironment::removePath
- Move Envoy::TestUtility::renameFile to Envoy::TestEnvironment
- Move Envoy::TestUtility::createSymlink to Envoy::TestEnvironment
- Move AtomicFileUpdater from test_common utility to environment
- Simplify Envoy::Filesystem::Watcher implementations using Filesystem
- Clean up watcher_impl flavors for splitFileName API
- Implement/new tests for Envoy::Filesystem::illegalPath for win32
- Implement watcher_impl for win32 [Initial development by Sam Smith]
- Ensure top level test tempdir exists when requested

Co-authored-by: Sunjay Bhatia <[email protected]>
Co-authored-by: William A Rowe Jr <[email protected]>
Co-authored-by: Sam Smith <[email protected]>

Signed-off-by: William A Rowe Jr <[email protected]>
Avert making envoy tweaks within 'clang-format off' blocks

Signed-off-by: William A Rowe Jr <[email protected]>
Co-authored-by: Sunjay Bhatia <[email protected]>
Copy link
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

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

Overall LGTM, thanks for slogging through this. Some questions/comments. Note that I just did a very fast skim of the win32 watcher code so I would make sure to have other folks review that part.

/wait

include/envoy/filesystem/filesystem.h Outdated Show resolved Hide resolved
source/common/filesystem/inotify/watcher_impl.h Outdated Show resolved Hide resolved
source/common/filesystem/win32/watcher_impl.cc Outdated Show resolved Hide resolved
source/common/filesystem/win32/watcher_impl.h Outdated Show resolved Hide resolved
test/test_common/environment.cc Show resolved Hide resolved
tools/check_format.py Outdated Show resolved Hide resolved
test/test_common/utility.h Show resolved Hide resolved
wrowe and others added 2 commits January 22, 2020 17:28
- Streamline the clang-format sensitivity for Envoy check/fix
- Rename splitFileName to splitPathFromFilename for clarity
  and change to absl::string_views for args and std::pair results
- Expose Api to watcher_impl for Filesystem
- All addWatch() implementations now take absl::string_view name args
- Clean up member variable naming for win32 watcher_impl
- Prefer RELEASE_ASSERT to throw for anticipated normal behavior

Signed-off-by: William A Rowe Jr <[email protected]>
Signed-off-by: Sunjay Bhatia <[email protected]>
Co-authored-by: Sunjay Bhatia <[email protected]>
Co-authored-by: William A Rowe Jr <[email protected]>
Co-authored-by: Sunjay Bhatia <[email protected]>
Don't blow up in the DirectoryIterator for a broken link.
Treat broken symlinks as 'Regular' files to be unlinked.

Co-authored-by: Sunjay Bhatia <[email protected]>
Co-authored-by: William A Rowe Jr <[email protected]>
Signed-off-by: Sunjay Bhatia <[email protected]>
Signed-off-by: William A Rowe Jr <[email protected]>
Co-authored-by: William A Rowe Jr <[email protected]>
Copy link
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

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

LGTM modulo some nits. Thank you!

/wait

include/envoy/filesystem/filesystem.h Outdated Show resolved Hide resolved
Comment on lines 60 to 61
if (::lstat(full_path.c_str(), &stat_buf) == 0 && S_ISLNK(stat_buf.st_mode))
return FileType::Regular;
Copy link
Member

Choose a reason for hiding this comment

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

braces around all if statements please, here and below. This should be caught by clang-tidy but clang-tidy is currently broken. @lizan @derekargueta any ETA on fixing that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ack, reviewed and fixed throughout. Leaving unresolved for the open question of clang-tidy.

source/common/filesystem/posix/directory_iterator_impl.cc Outdated Show resolved Hide resolved
source/common/filesystem/posix/filesystem_impl.cc Outdated Show resolved Hide resolved
source/common/filesystem/win32/filesystem_impl.cc Outdated Show resolved Hide resolved
test/common/filesystem/filesystem_impl_test.cc Outdated Show resolved Hide resolved
test/test_common/environment.cc Show resolved Hide resolved
tools/check_format.py Show resolved Hide resolved
Copy link
Contributor

@jmarantz jmarantz left a comment

Choose a reason for hiding this comment

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

check_format.py looks great generally; nice improvement. Just a minor suggestion.

tools/check_format.py Outdated Show resolved Hide resolved
wrowe and others added 3 commits January 23, 2020 12:45
Note: kqueue remains untested locally

Signed-off-by: William A Rowe Jr <[email protected]>
Co-authored-by: Sunjay Bhatia <[email protected]>
- describe changes to directory_iterator_impl
- use braces on all if/for statements
- document source of windows invalid character table
- add more description to AtomicFileUpdater class
- capitalize test names in filesystem_impl_test

Signed-off-by: Sunjay Bhatia <[email protected]>
Co-authored-by: William A Rowe Jr <[email protected]>
- clang-format off blocks must be closed with clang-format on
- clang-format may not be nested

Signed-off-by: William A Rowe Jr <[email protected]>
Co-authored-by: Sunjay Bhatia <[email protected]>

Signed-off-by: Sunjay Bhatia <[email protected]>
Co-authored-by: William A Rowe Jr <[email protected]>
Copy link
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

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

Awesome, LGTM other than small remaining comments and master merge.

/wait

wrowe and others added 3 commits January 23, 2020 14:45
Signed-off-by: William A Rowe Jr <[email protected]>
Co-authored-by: Sunjay Bhatia <[email protected]>
Signed-off-by: Sunjay Bhatia <[email protected]>
Co-authored-by: William A Rowe Jr <[email protected]>
Signed-off-by: William A Rowe Jr <[email protected]>
Co-authored-by: Sunjay Bhatia <[email protected]>
sunjayBhatia and others added 2 commits January 23, 2020 15:37
Signed-off-by: Sunjay Bhatia <[email protected]>
Co-authored-by: William A Rowe Jr <[email protected]>
Signed-off-by: William A Rowe Jr <[email protected]>
Co-authored-by: Sunjay Bhatia <[email protected]>
Copy link
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

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

Thanks LGTM with small remaining nit/cleanup.

/wait

source/common/filesystem/inotify/watcher_impl.cc Outdated Show resolved Hide resolved
source/common/filesystem/inotify/watcher_impl.cc Outdated Show resolved Hide resolved
Resolves test failing due to no file to substitute within

Signed-off-by: William A Rowe Jr <[email protected]>
Co-authored-by: Sunjay Bhatia <[email protected]>
Signed-off-by: William A Rowe Jr <[email protected]>
Co-authored-by: Sunjay Bhatia <[email protected]>
@wrowe
Copy link
Contributor Author

wrowe commented Jan 23, 2020

nit: this error-message syntax is repeated also in the def reportError code in the call-site. I think a small refactoring can be done where you pass in a reportError function to evaluateLines from its call-site.
This will require some minor function refactoring as the reportError function captures the line-number from context, and you'd need to factor out one that took the line-number as an argument. But I think it will clean this up a little. Not that it matters a huge amount but it would also enable multiple clang-format errors to be reported; the current structure where you return the error message will only show the last error.

Hi @jmarantz - thanks for your observations and suggestions.

One concern, if we wanted to show >1 error, we would want to constrain this to some sane number of errors (1..100?) I think we are mostly satisfied with the single error, although it can take more iterations to correct all the defects (provided one isn't using check_format.py fix).

Otherwise, @sunjayBhatia and I reviewed your proposal and suspect it would be easier, if you like, to have you directly modify the branch with your proposal as you envision it (or, we can merge master and start a new effort.) Please feel free to @ include us on any re-tooling, since we are frequent users of these facilities :)

@jmarantz
Copy link
Contributor

I wouldn't expect a large # of errors but if there were more than one and you only showed one, I'd want the first one and not the last :)

@wrowe
Copy link
Contributor Author

wrowe commented Jan 23, 2020

I wouldn't expect a large # of errors but if there were more than one and you only showed one, I'd want the first one and not the last :)

We've updated the code since the first draft to report on the first issue encountered.

Initially we didn't believe the test framework required this, but those
tests named with the convention FooTest/PROTO will require FooTest to
first be created before PROTO.

Signed-off-by: William A Rowe Jr <[email protected]>
@wrowe
Copy link
Contributor Author

wrowe commented Jan 24, 2020

I believe the requested changes are now addressed, please clarify if we've missed anything.

Resolves TapIntegrationTest failure

Signed-off-by: William A Rowe Jr <[email protected]>
for line_number, line in enumerate(readLines(path)):
if line.find("// clang-format off") != -1:
if not format_flag and error_message is None:
error_message = "%s:%d: %s" % (path, line_number + 1, "clang-format nested off")
Copy link
Contributor

Choose a reason for hiding this comment

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

as suggested earlier, can you pass reportError as a lambda into evaluateLines so you don't have to repeat the error-message formatting logic here & below? You can still show only one clang-format nesting error if you want by keeping a local bool.

Copy link
Member

Choose a reason for hiding this comment

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

I'm going to go ahead and merge this so we don't keep having merge conflicts. @wrowe can you do a follow up to address @jmarantz comments on this file? Thank you.

@mattklein123
Copy link
Member

/azp run envoy-linux

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

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

Thanks!

@mattklein123 mattklein123 merged commit 1dc6e43 into envoyproxy:master Jan 26, 2020
@wrowe wrowe deleted the fix-filesystem-usage branch January 27, 2020 23:26
@sunjayBhatia sunjayBhatia mentioned this pull request Feb 28, 2020
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