You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@aurora.apache.org by "Bill Farner (JIRA)" <ji...@apache.org> on 2014/04/25 09:02:14 UTC

[jira] [Commented] (AURORA-242) Install a SecurityManager to require unit test diligence

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

Bill Farner commented on AURORA-242:
------------------------------------

Tried using LessIOSecurityManager, but hit a hurdle that may apply to other approaches using a SecurityManager.  Take for example {{RecoveryTest}}:

RecoveryTest.java
{code}
@AllowLocalFileAccess(paths = {"*"})
public class RecoveryTest extends EasyMockTest {
...
  @Before
  public void setUp() {
    final File backupDir = FileUtils.createTempDir();
    addTearDown(new TearDown() {
      @Override
      public void tearDown() throws Exception {
        org.apache.commons.io.FileUtils.deleteDirectory(backupDir);
      }
    });
...
}
{code}

The {{TearDown}} closure cleans up after the test by deleting the temporary directory used.  When {{LessIOSecurityManager}} checks the thread stack, it can't see a {{AllowLocalFileAccess}} annotation since it is not present on any classes in the stack.  Of course, this could be worked around.

A more tricky case presents in {{SchedulerIT}}:

SchedulerIT.java
{code}
@AllowDNSResolution
public class SchedulerIT extends BaseZooKeeperTest {
...
}
{code}

BaseZooKeeperTest.java (third-party):
{code}
public abstract class BaseZooKeeperTest extends TearDownTestCase {...
  @Before
  public final void setUp() throws Exception {
   ...
    zkTestServer = new ZooKeeperTestServer(0, shutdownRegistry, defaultSessionTimeout);
    zkTestServer.startNetwork();
  }
}
{code}

In this case, {{setUp}} requires DNS resolution permission.  However, since {{setUp}} is not {{SchedulerIT}}, {{LessIOSecurityManager}} does not see a class on the call stack containing the {{AllowDNSResolution}} annotation.

These could both be worked around, but I'm not keen on adding hoop-jumping in code to satisfy a security manager.

> Install a SecurityManager to require unit test diligence
> --------------------------------------------------------
>
>                 Key: AURORA-242
>                 URL: https://issues.apache.org/jira/browse/AURORA-242
>             Project: Aurora
>          Issue Type: Story
>          Components: Scheduler, Testing
>            Reporter: Bill Farner
>            Assignee: Bill Farner
>            Priority: Trivial
>
> http://docs.codehaus.org/display/ASH/Home
> Ashcroft runs unit tests under a security manager to ensure that unit tests are pure.



--
This message was sent by Atlassian JIRA
(v6.2#6252)