Commit 2621e07e authored by Bereng's avatar Bereng Committed by Benjamin Lerer

Fix SchemaTest.testTransKsMigration-cdc and CQLSSTableWriterTest-cdc

patch by Berenguer Blasi; reviewed by Benjamin Lerer for CASSANDRA-15842

The tests were constantly failing for the cdc test run due to the fact
that CDCSizeTracker.shutdown was throwing a NPE if the method was called
while CDCSizeTracker was not started.
The fix ensure that the test start the commitlog and that
CDCSizeTracker.shutdown is a NOOP if the tracker has not been started.
parent 6978307b
......@@ -308,9 +308,12 @@ public class CommitLogSegmentManagerCDC extends AbstractCommitLogSegmentManager
public void shutdown()
{
if (cdcSizeCalculationExecutor != null && !cdcSizeCalculationExecutor.isShutdown())
{
cdcSizeCalculationExecutor.shutdown();
}
}
private void addSize(long toAdd)
{
......
......@@ -37,6 +37,7 @@ import org.apache.cassandra.cql3.*;
import org.apache.cassandra.cql3.functions.UDHelper;
import org.apache.cassandra.cql3.functions.types.*;
import org.apache.cassandra.db.Keyspace;
import org.apache.cassandra.db.commitlog.CommitLog;
import org.apache.cassandra.dht.*;
import org.apache.cassandra.exceptions.*;
import org.apache.cassandra.schema.Schema;
......@@ -59,6 +60,7 @@ public class CQLSSTableWriterTest
@BeforeClass
public static void setup() throws Exception
{
CommitLog.instance.start();
SchemaLoader.cleanupAndLeaveDirs();
Keyspace.setInitialized();
StorageService.instance.initServer();
......
......@@ -26,6 +26,7 @@ import org.junit.Test;
import org.apache.cassandra.SchemaLoader;
import org.apache.cassandra.config.DatabaseDescriptor;
import org.apache.cassandra.db.Keyspace;
import org.apache.cassandra.db.commitlog.CommitLog;
import org.apache.cassandra.gms.Gossiper;
import static org.junit.Assert.assertNotNull;
......@@ -43,6 +44,7 @@ public class SchemaTest
@Test
public void testTransKsMigration() throws IOException
{
CommitLog.instance.start();
SchemaLoader.cleanupAndLeaveDirs();
Schema.instance.loadFromDisk();
assertEquals(0, Schema.instance.getNonSystemKeyspaces().size());
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment