[ 
https://issues.apache.org/jira/browse/LUCENE-8999?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16944394#comment-16944394
 ] 

Lucene/Solr QA commented on LUCENE-8999:
----------------------------------------

| (/) *{color:green}+1 overall{color}* |
\\
\\
|| Vote || Subsystem || Runtime || Comment ||
|| || || || {color:brown} Prechecks {color} ||
| {color:green}+1{color} | {color:green} test4tests {color} | {color:green}  0m 
 0s{color} | {color:green} The patch appears to include 1 new or modified test 
files. {color} |
|| || || || {color:brown} master Compile Tests {color} ||
| {color:green}+1{color} | {color:green} compile {color} | {color:green}  0m 
22s{color} | {color:green} master passed {color} |
|| || || || {color:brown} Patch Compile Tests {color} ||
| {color:green}+1{color} | {color:green} compile {color} | {color:green}  0m 
30s{color} | {color:green} the patch passed {color} |
| {color:green}+1{color} | {color:green} javac {color} | {color:green}  0m 
30s{color} | {color:green} the patch passed {color} |
| {color:green}+1{color} | {color:green} Release audit (RAT) {color} | 
{color:green}  0m 30s{color} | {color:green} the patch passed {color} |
| {color:green}+1{color} | {color:green} Check forbidden APIs {color} | 
{color:green}  0m 30s{color} | {color:green} the patch passed {color} |
| {color:green}+1{color} | {color:green} Validate source patterns {color} | 
{color:green}  0m 30s{color} | {color:green} the patch passed {color} |
|| || || || {color:brown} Other Tests {color} ||
| {color:green}+1{color} | {color:green} unit {color} | {color:green}  4m 
53s{color} | {color:green} test-framework in the patch passed. {color} |
| {color:black}{color} | {color:black} {color} | {color:black} 10m 28s{color} | 
{color:black} {color} |
\\
\\
|| Subsystem || Report/Notes ||
| JIRA Issue | LUCENE-8999 |
| JIRA Patch URL | 
https://issues.apache.org/jira/secure/attachment/12982179/LUCENE-8999.patch |
| Optional Tests |  compile  javac  unit  ratsources  checkforbiddenapis  
validatesourcepatterns  |
| uname | Linux lucene2-us-west.apache.org 4.4.0-112-generic #135-Ubuntu SMP 
Fri Jan 19 11:48:36 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux |
| Build tool | ant |
| Personality | 
/home/jenkins/jenkins-slave/workspace/PreCommit-LUCENE-Build/sourcedir/dev-tools/test-patch/lucene-solr-yetus-personality.sh
 |
| git revision | master / b51013a |
| ant | version: Apache Ant(TM) version 1.9.6 compiled on July 20 2018 |
| Default Java | LTS |
|  Test Results | 
https://builds.apache.org/job/PreCommit-LUCENE-Build/209/testReport/ |
| modules | C: lucene/test-framework U: lucene/test-framework |
| Console output | 
https://builds.apache.org/job/PreCommit-LUCENE-Build/209/console |
| Powered by | Apache Yetus 0.7.0   http://yetus.apache.org |


This message was automatically generated.



> expectThrows doesn't play nicely with "assume" failures
> -------------------------------------------------------
>
>                 Key: LUCENE-8999
>                 URL: https://issues.apache.org/jira/browse/LUCENE-8999
>             Project: Lucene - Core
>          Issue Type: Test
>            Reporter: Chris M. Hostetter
>            Priority: Major
>         Attachments: LUCENE-8999.patch
>
>
> Once upon a time, {{TestRunWithRestrictedPermissions}} use to have test 
> methods that looked like this...
> {code:java}
> try {
>   runWithRestrictedPermissions(this::doSomeForbiddenStuff);
>   fail("this should not pass!");
> } catch (SecurityException se) {
>   // pass
> }
> {code}
> LUCENE-8938 changed this code to look like this...
> {code:java}
> expectThrows(SecurityException.class, () -> 
> runWithRestrictedPermissions(this::doSomeForbiddenStuff));
> {code}
> But a nuance of the existing code that isn't captured in the new code is that 
> {{runWithRestrictedPermissions(...)}} explicitly uses {{assumeTrue(..., 
> System.getSecurityManager() != null)}} to ensure that if a security manager 
> is not in use, the test should be {{SKIPed}} and not considered a pass or a 
> fail.
> The key issue being that {{assumeTrue(...)}} (and other 'assume' related 
> methods like it) throws an {{AssumptionViolatedException}} when the condition 
> isn't met, expecting this to propagate up to the Test Runner.
> With the _old_ code this worked as expected - the 
> {{AssumptionViolatedException}} would abort execution before the 
> {{fail(...)}} but not be caught by the {{catch}} and bubble up all the way to 
> the test runner so the test would be recorded as a SKIP.
> With the new code, {{expectThrows()}} is catching the 
> {{AssumptionViolatedException}} and since it doesn't match the expected 
> {{SecurityException.class}} is generating a test failure instead...
> {noformat}
>    [junit4] Suite: org.apache.lucene.util.TestRunWithRestrictedPermissions
>    [junit4]   2> NOTE: download the large Jenkins line-docs file by running 
> 'ant get-jenkins-line-docs' in the lucene directory.
>    [junit4]   2> NOTE: reproduce with: ant test  
> -Dtestcase=TestRunWithRestrictedPermissions 
> -Dtests.method=testCompletelyForbidden2 -Dtests.seed=4181E5FE9E84DBC4 
> -Dtests.multiplier=2 -Dtests.nightly=true -Dtests.slow=true 
> -Dtests.linedocsfile=/home/jenkins/lucene-data/enwiki.random.lines.txt 
> -Dtests.locale=luy -Dtests.timezone=Etc/GMT-7 -Dtests.asserts=true 
> -Dtests.file.encoding=US-ASCII
>    [junit4] FAILURE 0.10s J7  | 
> TestRunWithRestrictedPermissions.testCompletelyForbidden2 <<<
>    [junit4]    > Throwable #1: junit.framework.AssertionFailedError: 
> Unexpected exception type, expected SecurityException but got 
> org.junit.AssumptionViolatedException: runWithRestrictedPermissions requires 
> a SecurityManager enabled
>    [junit4]    >        at 
> __randomizedtesting.SeedInfo.seed([4181E5FE9E84DBC4:16509163A0E04B41]:0)
>    [junit4]    >        at 
> org.apache.lucene.util.LuceneTestCase.expectThrows(LuceneTestCase.java:2729)
>    [junit4]    >        at 
> org.apache.lucene.util.LuceneTestCase.expectThrows(LuceneTestCase.java:2718)
>    [junit4]    >        at 
> org.apache.lucene.util.TestRunWithRestrictedPermissions.testCompletelyForbidden2(TestRunWithRestrictedPermissions.java:39)
>    [junit4]    >        at 
> java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>    [junit4]    >        at 
> java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>    [junit4]    >        at 
> java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>    [junit4]    >        at 
> java.base/java.lang.reflect.Method.invoke(Method.java:566)
>    [junit4]    >        at java.base/java.lang.Thread.run(Thread.java:834)
>    [junit4]    > Caused by: org.junit.AssumptionViolatedException: 
> runWithRestrictedPermissions requires a SecurityManager enabled
>    [junit4]    >        at 
> com.carrotsearch.randomizedtesting.RandomizedTest.assumeTrue(RandomizedTest.java:725)
>    [junit4]    >        at 
> org.apache.lucene.util.LuceneTestCase.assumeTrue(LuceneTestCase.java:873)
>    [junit4]    >        at 
> org.apache.lucene.util.LuceneTestCase.runWithRestrictedPermissions(LuceneTestCase.java:2917)
>    [junit4]    >        at 
> org.apache.lucene.util.TestRunWithRestrictedPermissions.lambda$testCompletelyForbidden2$2(TestRunWithRestrictedPermissions.java:40)
>    [junit4]    >        at 
> org.apache.lucene.util.LuceneTestCase.expectThrows(LuceneTestCase.java:2724)
>    [junit4]    >        ... 37 more
> {noformat}
> ----
> While there might be easy fixes that could be made explicitly to 
> {{TestRunWithRestrictedPermissions}} to deal with this particular problem, it 
> seems like perhaps we should consider changes to better deal with this _type_ 
> of problem that might exist elsewhere or occur in the future?



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

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

Reply via email to