SOLR-10075: TestNonWritablePersistFile fails when run as a single test under root.

This commit is contained in:
markrmiller 2018-03-22 09:32:37 -05:00
parent e364f5be31
commit 848a410ca1
1 changed files with 18 additions and 4 deletions

View File

@ -70,10 +70,24 @@ public class TestNonWritablePersistFile extends AbstractDataImportHandlerTestCas
try { try {
// execute the test only if we are able to set file to read only mode // execute the test only if we are able to set file to read only mode
assumeTrue("No dataimport.properties file", f.exists() || f.createNewFile()); // we don't use assume because if no tests executes when you run a single test
assumeTrue("dataimport.properties can't be set read only", f.setReadOnly()); // it's considered a fail
assumeFalse("dataimport.properties is still writable even though " +
"marked readonly - test running as superuser?", f.canWrite()); if (!(f.exists() || f.createNewFile())) {
System.err.println("No dataimport.properties file, skipping rest of test ...");
return;
}
if (!f.setReadOnly()) {
System.err.println("dataimport.properties can't be set read only, skipping rest of test ...");
return;
}
if (f.canWrite()) {
System.err.println("dataimport.properties is still writable even though \" + \n" +
" \"marked readonly - test running as superuser?, skipping rest of test ...");
return;
}
ignoreException("Properties is not writable"); ignoreException("Properties is not writable");