SOLR-16903: Migrate all tests using File to NIO Path#3263
SOLR-16903: Migrate all tests using File to NIO Path#3263dsmiley merged 23 commits intoapache:mainfrom
Conversation
epugh
left a comment
There was a problem hiding this comment.
Wow, so much work! In general I love the removing of the indirection that using Path is showing....
solr/core/src/test/org/apache/solr/cli/TestSolrCLIRunExample.java
Outdated
Show resolved
Hide resolved
|
Tests seem to fail on Seems |
|
A quick google suggests we should add this to our tests policy for the security manager: But it wasn't needed before... nonetheless if this fixes the matter then it's fine. Eventually we'll be disabling the security manager and perhaps implementing other measures to stop tests from writing where they shouldn't. |
I think that worked. I removed permissions from |
dsmiley
left a comment
There was a problem hiding this comment.
Just a few more observations but I won't be looking further than this. I expect a contributor on Windows that I've been chatting with will validate this as well.
solr/core/src/test/org/apache/solr/core/TestFileSystemConfigSetService.java
Show resolved
Hide resolved
solr/core/src/test/org/apache/solr/handler/component/FacetPivot2CollectionsTest.java
Outdated
Show resolved
Hide resolved
mlbiscoc
left a comment
There was a problem hiding this comment.
Got a VM of windows on my laptop to run the tests. The only test that failed was the file permissions tests in TestCoreDiscovery and fixed that accordingly. Still think would be good if someone else ran the test locally (windows and unix). I think this is in a state I'm happy with.
solr/core/src/test/org/apache/solr/core/TestFileSystemConfigSetService.java
Show resolved
Hide resolved
solr/core/src/test/org/apache/solr/handler/component/FacetPivot2CollectionsTest.java
Outdated
Show resolved
Hide resolved
| try { | ||
| Set<PosixFilePermission> perms = Files.getPosixFilePermissions(homeDir); | ||
| perms.remove(PosixFilePermission.OWNER_READ); | ||
| perms.remove(PosixFilePermission.GROUP_READ); | ||
| perms.remove(PosixFilePermission.OTHERS_READ); | ||
| Files.setAttribute(homeDir, "posix:permissions", perms); | ||
| } catch (IOException e) { | ||
| throw new AssumptionViolatedException( | ||
| "Cannot make " + homeDir + " non-readable. Test aborted.", e); | ||
| } |
There was a problem hiding this comment.
Looks like on windows this wasn't possible which is why there is a assumeTrue call. This will replicate that and just ignore the test on windows.
|
I ran the tests last Friday, especially the Windows sensitive one you found and they all passed. I don't recall if there's any outstanding comment of mine that is unfulfilled. I know there's a contributor that may share his results when running Windows. |
Thanks for helping run the tests. Trying to be careful for something this large of a change. Did a few passthroughs of the PR since opening this. At this point I should have went through all the comments in this PR and resolved them but happy to make more changes if anyone catches something. |
|
I plan to merge this Friday afternoon. Looks like the tests passed on Windows for another contributor. |
|
In IntelliJ, I did a find-usages of File (methods, fields, etc.) across project files. Excluding gradle (uses File a lot), there are still a number of usages. For example TestRestore. On that spot in particular, wow, the few lines there are so back & forth on Path -> File -> String -> Path ... makes my head spin |
|
@mlbiscoc I think we only have 1 failing test from this, so good job!
|
Ah so close.... Thanks @HoustonPutman Will try and fix this today. |
|
Oh, well it looks like the nightly tests are less happy... https://ci-builds.apache.org/job/Solr/job/Solr-NightlyTests-main |
|
Thats sad. I ran these tests many times locally. Does nightly not clean up directories? Many of those tests seem to fail where a file/directory already exists.
Will try to fix these errors today. |
|
PR to fix nightly tests and |
* Remove unnecessary toAbsolutePath() calls * Remove some callers of FileSystems.getDefault().getSeparator() * Remove Path.toString in where it could easily be avoided. * Use Path.toFile().setReadable in TestCoreDiscovery * Throw AssumptionViolatedException for file permissions on windows Co-authored-by: David Smiley <dsmiley@salesforce.com>
https://issues.apache.org/jira/browse/SOLR-16903
Description
WIP - Leaving in draft state for now as there is still more work from refactor needed but most tests pass so can be semi-reviewed.
Migrate all imports using
FiletoPath. There should be no more imports usingFilein the project. We are close to makingFilea forbidden API after this but still more work needed.Checklist
Please review the following and check all that apply:
mainbranch../gradlew check.