This is an automated email from the ASF dual-hosted git repository. vinaychella pushed a commit to branch trunk in repository https://gitbox.apache.org/repos/asf/cassandra.git
The following commit(s) were added to refs/heads/trunk by this push: new 225fa86 Fix flaky unit test AuditLoggerTest 225fa86 is described below commit 225fa868884bdda1c20e0fcef61628eb6d941fbe Author: Per Otterström <per.otterst...@gmail.com> AuthorDate: Fri Jun 21 17:41:01 2019 -0700 Fix flaky unit test AuditLoggerTest Patch by Per Otterström, Sumanth Pasupuleti; Reviewed by Vinay Chella for CASSANDRA-15105 Co-Authored-By: Per Otterström <per.otterst...@gmail.com> Co-Authored-By: Sumanth Pasupuleti <sumanth.pasupuleti...@gmail.com> --- .../apache/cassandra/audit/AuditLoggerTest.java | 23 +++++++++++++--------- .../service/StorageServiceServerTest.java | 15 ++++++++++++-- 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/test/unit/org/apache/cassandra/audit/AuditLoggerTest.java b/test/unit/org/apache/cassandra/audit/AuditLoggerTest.java index b0299dc..a445547 100644 --- a/test/unit/org/apache/cassandra/audit/AuditLoggerTest.java +++ b/test/unit/org/apache/cassandra/audit/AuditLoggerTest.java @@ -17,6 +17,7 @@ */ package org.apache.cassandra.audit; +import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.BeforeClass; @@ -63,6 +64,12 @@ public class AuditLoggerTest extends CQLTester enableAuditLogOptions(options); } + @After + public void afterTestMethod() + { + disableAuditLogOptions(); + } + private void enableAuditLogOptions(AuditLogOptions options) { String loggerName = "InMemoryAuditLogger"; @@ -89,7 +96,7 @@ public class AuditLoggerTest extends CQLTester execute("INSERT INTO %s (id, v1, v2) VALUES (?, ?, ?)", 2, "trace", "test"); AuditLogOptions options = new AuditLogOptions(); - options.excluded_keyspaces = KEYSPACE; + options.excluded_keyspaces += ',' + KEYSPACE; enableAuditLogOptions(options); String cql = "SELECT id, v1, v2 FROM " + KEYSPACE + '.' + currentTable() + " WHERE id = ?"; @@ -106,7 +113,7 @@ public class AuditLoggerTest extends CQLTester options = new AuditLogOptions(); options.included_keyspaces = KEYSPACE; - options.excluded_keyspaces = KEYSPACE; + options.excluded_keyspaces += ',' + KEYSPACE; enableAuditLogOptions(options); cql = "SELECT id, v1, v2 FROM " + KEYSPACE + '.' + currentTable() + " WHERE id = ?"; @@ -129,7 +136,7 @@ public class AuditLoggerTest extends CQLTester execute("INSERT INTO %s (id, v1, v2) VALUES (?, ?, ?)", 2, "trace", "test"); AuditLogOptions options = new AuditLogOptions(); - options.excluded_keyspaces = KEYSPACE; + options.excluded_keyspaces += ',' + KEYSPACE; enableAuditLogOptions(options); String cql = "SELECT id, v1, v2 FROM " + KEYSPACE + '.' + currentTable() + " WHERE id = ?"; @@ -144,7 +151,7 @@ public class AuditLoggerTest extends CQLTester options = new AuditLogOptions(); options.included_keyspaces = KEYSPACE; - options.excluded_keyspaces = KEYSPACE; + options.excluded_keyspaces += ',' + KEYSPACE; enableAuditLogOptions(options); cql = "SELECT id, v1, v2 FROM " + KEYSPACE + '.' + currentTable() + " WHERE id = ?"; @@ -162,11 +169,9 @@ public class AuditLoggerTest extends CQLTester public void testAuditLogExceptions() { AuditLogOptions options = new AuditLogOptions(); - options.excluded_keyspaces = KEYSPACE; + options.excluded_keyspaces += ',' + KEYSPACE; enableAuditLogOptions(options); Assert.assertTrue(AuditLogManager.getInstance().isAuditingEnabled()); - - disableAuditLogOptions(); } @Test @@ -602,7 +607,7 @@ public class AuditLoggerTest extends CQLTester { AuditLogOptions options = new AuditLogOptions(); options.included_categories = "QUERY,DML,PREPARE"; - options.excluded_keyspaces = "system_schema"; + options.excluded_keyspaces = "system_schema,system_virtual_schema"; enableAuditLogOptions(options); Session session = sessionNet(); @@ -620,7 +625,7 @@ public class AuditLoggerTest extends CQLTester { AuditLogOptions options = new AuditLogOptions(); options.included_categories = "QUERY,DML,PREPARE"; - options.excluded_keyspaces = "system"; + options.excluded_keyspaces = "system,system_schema,system_virtual_schema"; enableAuditLogOptions(options); Session session = sessionNet(); diff --git a/test/unit/org/apache/cassandra/service/StorageServiceServerTest.java b/test/unit/org/apache/cassandra/service/StorageServiceServerTest.java index 2db221b..565d91a 100644 --- a/test/unit/org/apache/cassandra/service/StorageServiceServerTest.java +++ b/test/unit/org/apache/cassandra/service/StorageServiceServerTest.java @@ -28,6 +28,7 @@ import java.util.*; import com.google.common.collect.HashMultimap; import com.google.common.collect.Multimap; +import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; @@ -621,12 +622,20 @@ public class StorageServiceServerTest assertEquals("127.0.0.3:666", StorageService.instance.getNativeaddress(internalAddress, true)); } - @Test(expected = IllegalStateException.class) + @Test public void testAuditLogEnableLoggerNotFound() throws Exception { StorageService.instance.enableAuditLog(null, null, null, null, null, null, null); assertTrue(AuditLogManager.getInstance().isAuditingEnabled()); - StorageService.instance.enableAuditLog("foobar", null, null, null, null, null, null); + try + { + StorageService.instance.enableAuditLog("foobar", null, null, null, null, null, null); + Assert.fail(); + } + catch (IllegalStateException ex) + { + StorageService.instance.disableAuditLog(); + } } @Test @@ -646,5 +655,7 @@ public class StorageServiceServerTest StorageService.instance.enableAuditLog(null, null, null, null, null, null, null); assertTrue(AuditLogManager.getInstance().isAuditingEnabled()); + + StorageService.instance.disableAuditLog(); } } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org For additional commands, e-mail: commits-h...@cassandra.apache.org