[ 
https://issues.apache.org/jira/browse/SOLR-4195?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Uwe Schindler updated SOLR-4195:
--------------------------------

    Attachment: SOLR-4195.patch

Hi,

here is the simpliest patch that solves the issue. As the test framework 
improved, I further restricted the java policy to the temporrary directory, 
where the tests run inside: build.dir/test (the one where the 
randomized-testing frameworks files and per-JVM subdirs are in. Code can no 
longer write to the build.dir itsself (which includes the test-files of the 
classpath).

Without the DIH fix from Hoss' patch, the test fails successfully:

{noformat}
[junit4:junit4] ERROR   0.06s | 
TestNonWritablePersistFile.testNonWritablePersistFile <<<
[junit4:junit4]    > Throwable #1: java.security.AccessControlException: access 
denied (java.io.FilePermission C:\Users\Uwe 
Schindler\Projects\lucene\trunk-lusolr3\solr\build\contrib\solr-dataimporthandler\test-files\dih\solr\collection1\conf\dataimport.properties
 delete)
[junit4:junit4]    >    at 
__randomizedtesting.SeedInfo.seed([5B0E701C943CAA2D:ED06EDD3E83314F8]:0)
[junit4:junit4]    >    at 
java.security.AccessControlContext.checkPermission(AccessControlContext.java:374)
[junit4:junit4]    >    at 
java.security.AccessController.checkPermission(AccessController.java:546)
[junit4:junit4]    >    at 
java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
[junit4:junit4]    >    at 
java.lang.SecurityManager.checkDelete(SecurityManager.java:990)
[junit4:junit4]    >    at java.io.File.delete(File.java:902)
[junit4:junit4]    >    at 
org.apache.solr.handler.dataimport.TestNonWritablePersistFile.testNonWritablePersistFile(TestNonWritablePersistFile.java:89)
[junit4:junit4]    >    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native 
Method)
[junit4:junit4]    >    at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[junit4:junit4]    >    at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[junit4:junit4]    >    at java.lang.reflect.Method.invoke(Method.java:597)
[junit4:junit4]    >    at 
com.carrotsearch.randomizedtesting.RandomizedRunner.invoke(RandomizedRunner.java:1559)
[junit4:junit4]    >    at 
com.carrotsearch.randomizedtesting.RandomizedRunner.access$600(RandomizedRunner.java:79)
[junit4:junit4]    >    at 
com.carrotsearch.randomizedtesting.RandomizedRunner$6.evaluate(RandomizedRunner.java:737)
[junit4:junit4]    >    at 
com.carrotsearch.randomizedtesting.RandomizedRunner$7.evaluate(RandomizedRunner.java:773)
[junit4:junit4]    >    at 
com.carrotsearch.randomizedtesting.RandomizedRunner$8.evaluate(RandomizedRunner.java:787)
[junit4:junit4]    >    at 
com.carrotsearch.randomizedtesting.rules.SystemPropertiesRestoreRule$1.evaluate(SystemPropertiesRestoreRule.java:53)
[junit4:junit4]    >    at 
org.apache.lucene.util.TestRuleSetupTeardownChained$1.evaluate(TestRuleSetupTeardownChained.java:50)
[junit4:junit4]    >    at 
org.apache.lucene.util.TestRuleFieldCacheSanity$1.evaluate(TestRuleFieldCacheSanity.java:51)
[junit4:junit4]    >    at 
org.apache.lucene.util.AbstractBeforeAfterRule$1.evaluate(AbstractBeforeAfterRule.java:46)
[junit4:junit4]    >    at 
com.carrotsearch.randomizedtesting.rules.SystemPropertiesInvariantRule$1.evaluate(SystemPropertiesInvariantRule.java:55)
[junit4:junit4]    >    at 
org.apache.lucene.util.TestRuleThreadAndTestName$1.evaluate(TestRuleThreadAndTestName.java:49)
[junit4:junit4]    >    at 
org.apache.lucene.util.TestRuleIgnoreAfterMaxFailures$1.evaluate(TestRuleIgnoreAfterMaxFailures.java:70)
[junit4:junit4]    >    at 
org.apache.lucene.util.TestRuleMarkFailure$1.evaluate(TestRuleMarkFailure.java:48)
[junit4:junit4]    >    at 
com.carrotsearch.randomizedtesting.rules.StatementAdapter.evaluate(StatementAdapter.java:36)
[junit4:junit4]    >    at 
com.carrotsearch.randomizedtesting.ThreadLeakControl$StatementRunner.run(ThreadLeakControl.java:358)
[junit4:junit4]    >    at 
com.carrotsearch.randomizedtesting.ThreadLeakControl.forkTimeoutingTask(ThreadLeakControl.java:782)
[junit4:junit4]    >    at 
com.carrotsearch.randomizedtesting.ThreadLeakControl$3.evaluate(ThreadLeakControl.java:442)
[junit4:junit4]    >    at 
com.carrotsearch.randomizedtesting.RandomizedRunner.runSingleTest(RandomizedRunner.java:746)
[junit4:junit4]    >    at 
com.carrotsearch.randomizedtesting.RandomizedRunner$3.evaluate(RandomizedRunner.java:648)
[junit4:junit4]    >    at 
com.carrotsearch.randomizedtesting.RandomizedRunner$4.evaluate(RandomizedRunner.java:682)
[junit4:junit4]    >    at 
com.carrotsearch.randomizedtesting.RandomizedRunner$5.evaluate(RandomizedRunner.java:693)
[junit4:junit4]    >    at 
com.carrotsearch.randomizedtesting.rules.StatementAdapter.evaluate(StatementAdapter.java:36)
[junit4:junit4]    >    at 
com.carrotsearch.randomizedtesting.rules.SystemPropertiesRestoreRule$1.evaluate(SystemPropertiesRestoreRule.java:53)
[junit4:junit4]    >    at 
org.apache.lucene.util.AbstractBeforeAfterRule$1.evaluate(AbstractBeforeAfterRule.java:46)
[junit4:junit4]    >    at 
org.apache.lucene.util.TestRuleStoreClassName$1.evaluate(TestRuleStoreClassName.java:42)
[junit4:junit4]    >    at 
com.carrotsearch.randomizedtesting.rules.SystemPropertiesInvariantRule$1.evaluate(SystemPropertiesInvariantRule.java:55)
[junit4:junit4]    >    at 
com.carrotsearch.randomizedtesting.rules.NoShadowingOrOverridesOnMethodsRule$1.evaluate(NoShadowingOrOverridesOnMethodsRule.java:39)
[junit4:junit4]    >    at 
com.carrotsearch.randomizedtesting.rules.NoShadowingOrOverridesOnMethodsRule$1.evaluate(NoShadowingOrOverridesOnMethodsRule.java:39)
[junit4:junit4]    >    at 
com.carrotsearch.randomizedtesting.rules.StatementAdapter.evaluate(StatementAdapter.java:36)
[junit4:junit4]    >    at 
org.apache.lucene.util.TestRuleAssertionsRequired$1.evaluate(TestRuleAssertionsRequired.java:43)
[junit4:junit4]    >    at 
org.apache.lucene.util.TestRuleMarkFailure$1.evaluate(TestRuleMarkFailure.java:48)
[junit4:junit4]    >    at 
org.apache.lucene.util.TestRuleIgnoreAfterMaxFailures$1.evaluate(TestRuleIgnoreAfterMaxFailures.java:70)
[junit4:junit4]    >    at 
org.apache.lucene.util.TestRuleIgnoreTestSuites$1.evaluate(TestRuleIgnoreTestSuites.java:55)
[junit4:junit4]    >    at 
com.carrotsearch.randomizedtesting.rules.StatementAdapter.evaluate(StatementAdapter.java:36)
[junit4:junit4]    >    at 
com.carrotsearch.randomizedtesting.ThreadLeakControl$StatementRunner.run(ThreadLeakControl.java:358)
[junit4:junit4]    >    at java.lang.Thread.run(Thread.java:662)
{noformat}
                
> chmod a-x build/**/test-files when running tests
> ------------------------------------------------
>
>                 Key: SOLR-4195
>                 URL: https://issues.apache.org/jira/browse/SOLR-4195
>             Project: Solr
>          Issue Type: Improvement
>            Reporter: Hoss Man
>         Attachments: SOLR-4195.patch, SOLR-4195.patch
>
>
> Until recently, I thought the solr test framework was setup such that every 
> test got it's own copy of the "test-files/solr" directory to use as it's Solr 
> Home Dir -- then mark committed r1421543, to fix a problem where that test 
> was writing a file (that would later be removed) to the solr conf dir, which 
> would confuse another currently running test and cause it to fail.
> This made me realize that what i was remembering is that the ant build files 
> copy the src/test-files directories into build/ prior to running the tests -- 
> but all tests (in that module) still share the same copy.
> Subsequent discussions with folks on IRC lead me to the following 
> realizations..
>  * making a copy of the test-files dir for each test would help eliminate 
> confusing by reducing non-reproducible failures if tests collide -- but might 
> be slow
>  * making a copy of the test-files dir for each test would not help identify 
> situations were code was mistakenly/unexpectedly writing to the solr home dir
>  * what would probably make the most sense, would be to make the 
> build/test-files directory "read only".  that way by default tests would get 
> a read only solr home dir -- triggering failures if the code is broken and 
> tries to write to that dir.  tests that want/need to write to the solr home 
> dir would have to go out of their way to clone the read only test-files/solr 
> directory and use it as their solr home.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org

Reply via email to