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
...@@ -309,7 +309,10 @@ public class CommitLogSegmentManagerCDC extends AbstractCommitLogSegmentManager ...@@ -309,7 +309,10 @@ public class CommitLogSegmentManagerCDC extends AbstractCommitLogSegmentManager
public void shutdown() public void shutdown()
{ {
cdcSizeCalculationExecutor.shutdown(); if (cdcSizeCalculationExecutor != null && !cdcSizeCalculationExecutor.isShutdown())
{
cdcSizeCalculationExecutor.shutdown();
}
} }
private void addSize(long toAdd) private void addSize(long toAdd)
......
...@@ -37,6 +37,7 @@ import org.apache.cassandra.cql3.*; ...@@ -37,6 +37,7 @@ import org.apache.cassandra.cql3.*;
import org.apache.cassandra.cql3.functions.UDHelper; import org.apache.cassandra.cql3.functions.UDHelper;
import org.apache.cassandra.cql3.functions.types.*; import org.apache.cassandra.cql3.functions.types.*;
import org.apache.cassandra.db.Keyspace; import org.apache.cassandra.db.Keyspace;
import org.apache.cassandra.db.commitlog.CommitLog;
import org.apache.cassandra.dht.*; import org.apache.cassandra.dht.*;
import org.apache.cassandra.exceptions.*; import org.apache.cassandra.exceptions.*;
import org.apache.cassandra.schema.Schema; import org.apache.cassandra.schema.Schema;
...@@ -59,6 +60,7 @@ public class CQLSSTableWriterTest ...@@ -59,6 +60,7 @@ public class CQLSSTableWriterTest
@BeforeClass @BeforeClass
public static void setup() throws Exception public static void setup() throws Exception
{ {
CommitLog.instance.start();
SchemaLoader.cleanupAndLeaveDirs(); SchemaLoader.cleanupAndLeaveDirs();
Keyspace.setInitialized(); Keyspace.setInitialized();
StorageService.instance.initServer(); StorageService.instance.initServer();
......
...@@ -26,6 +26,7 @@ import org.junit.Test; ...@@ -26,6 +26,7 @@ import org.junit.Test;
import org.apache.cassandra.SchemaLoader; import org.apache.cassandra.SchemaLoader;
import org.apache.cassandra.config.DatabaseDescriptor; import org.apache.cassandra.config.DatabaseDescriptor;
import org.apache.cassandra.db.Keyspace; import org.apache.cassandra.db.Keyspace;
import org.apache.cassandra.db.commitlog.CommitLog;
import org.apache.cassandra.gms.Gossiper; import org.apache.cassandra.gms.Gossiper;
import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotNull;
...@@ -43,6 +44,7 @@ public class SchemaTest ...@@ -43,6 +44,7 @@ public class SchemaTest
@Test @Test
public void testTransKsMigration() throws IOException public void testTransKsMigration() throws IOException
{ {
CommitLog.instance.start();
SchemaLoader.cleanupAndLeaveDirs(); SchemaLoader.cleanupAndLeaveDirs();
Schema.instance.loadFromDisk(); Schema.instance.loadFromDisk();
assertEquals(0, Schema.instance.getNonSystemKeyspaces().size()); 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