sentry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sravya Tirukkovalur (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (SENTRY-367) Add end to end tests for audit log
Date Thu, 14 Aug 2014 21:50:22 GMT

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

Sravya Tirukkovalur commented on SENTRY-367:
--------------------------------------------

Hi Colin, yeah although I think the components(there may be more than one) depending on this
feature can have exhaustive tests at their end, I think we should have atleast basic e2e tests
in Sentry. So we could do something like having a dummy appender which appends log events
and our tests can verify from this list?

{noformat}
public class TestDbDDLAuditLog extends AbstractTestWithStaticConfiguration {

 public static class TestAppender extends AppenderSkeleton {
    public static List<LoggingEvent> events = new ArrayList<LoggingEvent>();
    public void close() {}
    public boolean requiresLayout() {return false;}
    @Override
    protected void append(LoggingEvent event) {
      events.add(event);
    }
    static String getLastLogEvent() {
      return events.get(events.size() - 1).getMessage().toString();
    }
    static Level getLastLogLevel() {
      return events.get(events.size() - 1).getLevel();
    }
  }
  @BeforeClass
  public static void setupTestStaticConfiguration() throws Exception {
    useSentryService = true;
    AbstractTestWithStaticConfiguration.setupTestStaticConfiguration();
    Logger logger = Logger.getLogger("sentry.hive.authorization.ddl.logger");
    TestAppender testAppender = new TestAppender();
    logger.addAppender(testAppender);
    logger.setLevel(Level.INFO);
  }

@Test
  public void testBasic() throws Exception {
    statement.execute("CREATE ROLE " + roleName);
    assertThat(TestAppender.getLastLogLevel(), is(Level.INFO));
    JSONObject jsonObject= new JSONObject(TestAppender.getLastLogEvent());
    assertThat(jsonObject.get("operation").toString(), equalToIgnoringCase("CREATE_ROLE"));
 
  }
{noformat}

What do you think?

Thanks!

> Add end to end tests for audit log
> ----------------------------------
>
>                 Key: SENTRY-367
>                 URL: https://issues.apache.org/jira/browse/SENTRY-367
>             Project: Sentry
>          Issue Type: Sub-task
>            Reporter: Colin Ma
>            Assignee: Colin Ma
>            Priority: Minor
>         Attachments: sentry-367.v1.patch
>
>
> Add end to end test for audit log



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

Mime
View raw message