Skip to content

Commit 118c52a

Browse files
committed
CC5 fix CQLSSTableWriterTest
CQLSSTableWriterDaemonTest SAI tests only work with Murmur3Partitioner, but other tests only work with the default ByteOrderedPartitioner; Use JUnit assumeTrue along with new CQLSSTableWriterDaemonMurmur3Test class to cover variations: clientInitialization, daemonInitialization with (default) ByteOrderedPartitioner, and daemonInitialization with Murmur3Partitioner.
1 parent 4d4e599 commit 118c52a

File tree

2 files changed

+74
-0
lines changed

2 files changed

+74
-0
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
package org.apache.cassandra.io.sstable;
19+
20+
21+
import org.junit.BeforeClass;
22+
23+
import org.apache.cassandra.SchemaLoader;
24+
import org.apache.cassandra.config.Config;
25+
import org.apache.cassandra.config.DatabaseDescriptor;
26+
import org.apache.cassandra.db.Keyspace;
27+
import org.apache.cassandra.db.commitlog.CommitLog;
28+
import org.apache.cassandra.dht.Murmur3Partitioner;
29+
import org.apache.cassandra.service.StorageService;
30+
31+
public class CQLSSTableWriterDaemonMurmur3Test extends CQLSSTableWriterTest
32+
{
33+
@BeforeClass
34+
public static void setup() throws Exception
35+
{
36+
DatabaseDescriptor.daemonInitialization(() -> {
37+
Config config = DatabaseDescriptor.loadConfig();
38+
config.partitioner = Murmur3Partitioner.class.getName();
39+
return config;
40+
});
41+
CommitLog.instance.start();
42+
SchemaLoader.cleanupAndLeaveDirs();
43+
Keyspace.setInitialized();
44+
StorageService.instance.initServer();
45+
}
46+
}

test/unit/org/apache/cassandra/io/sstable/CQLSSTableWriterTest.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838

3939
import com.google.common.collect.ImmutableList;
4040
import com.google.common.collect.ImmutableMap;
41+
import org.junit.Assume;
4142
import org.junit.Before;
4243
import org.junit.Ignore;
4344
import org.junit.Rule;
@@ -569,6 +570,10 @@ public void testConcurrentWriters() throws Exception
569570
@SuppressWarnings("unchecked")
570571
public void testWritesWithUdts() throws Exception
571572
{
573+
Assume.assumeTrue("Skip test when using DaemonInitialization with Murmur3Partitioner",
574+
!DatabaseDescriptor.isDaemonInitialized()
575+
|| !(DatabaseDescriptor.getPartitioner() instanceof Murmur3Partitioner));
576+
572577
final String schema = "CREATE TABLE " + qualifiedTable + " ("
573578
+ " k int,"
574579
+ " v1 list<frozen<tuple2>>,"
@@ -639,6 +644,10 @@ public void testWritesWithUdts() throws Exception
639644
@SuppressWarnings("unchecked")
640645
public void testWritesWithDependentUdts() throws Exception
641646
{
647+
Assume.assumeTrue("Skip test when using DaemonInitialization with Murmur3Partitioner",
648+
!DatabaseDescriptor.isDaemonInitialized()
649+
|| !(DatabaseDescriptor.getPartitioner() instanceof Murmur3Partitioner));
650+
642651
final String schema = "CREATE TABLE " + qualifiedTable + " ("
643652
+ " k int,"
644653
+ " v1 frozen<nested_tuple>,"
@@ -699,6 +708,10 @@ public void testWritesWithDependentUdts() throws Exception
699708
@Test
700709
public void testUnsetValues() throws Exception
701710
{
711+
Assume.assumeTrue("Skip test when using DaemonInitialization with Murmur3Partitioner",
712+
!DatabaseDescriptor.isDaemonInitialized()
713+
|| !(DatabaseDescriptor.getPartitioner() instanceof Murmur3Partitioner));
714+
702715
final String schema = "CREATE TABLE " + qualifiedTable + " ("
703716
+ " k int,"
704717
+ " c1 int,"
@@ -1238,6 +1251,10 @@ public void testWriteWithTimestampsAndTtl() throws Exception
12381251
@Test
12391252
public void testWriteWithSorted() throws Exception
12401253
{
1254+
Assume.assumeTrue("Skip test when using DaemonInitialization with Murmur3Partitioner",
1255+
!DatabaseDescriptor.isDaemonInitialized()
1256+
|| !(DatabaseDescriptor.getPartitioner() instanceof Murmur3Partitioner));
1257+
12411258
String schema = "CREATE TABLE " + qualifiedTable + " ("
12421259
+ " k int PRIMARY KEY,"
12431260
+ " v blob )";
@@ -1269,6 +1286,10 @@ public void testWriteWithSorted() throws Exception
12691286
@Test
12701287
public void testWriteWithSortedAndMaxSize() throws Exception
12711288
{
1289+
Assume.assumeTrue("Skip test when using DaemonInitialization with Murmur3Partitioner",
1290+
!DatabaseDescriptor.isDaemonInitialized()
1291+
|| !(DatabaseDescriptor.getPartitioner() instanceof Murmur3Partitioner));
1292+
12721293
String schema = "CREATE TABLE " + qualifiedTable + " ("
12731294
+ " k int PRIMARY KEY,"
12741295
+ " v blob )";
@@ -1359,6 +1380,9 @@ private void testWriters(String table1, String table2) throws IOException, Inval
13591380
@Test
13601381
public void testWriteWithSAI() throws Exception
13611382
{
1383+
Assume.assumeTrue("Skip test when using DaemonInitialization without Murmur3Partitioner",
1384+
!DatabaseDescriptor.isDaemonInitialized()
1385+
|| DatabaseDescriptor.getPartitioner() instanceof Murmur3Partitioner);
13621386
writeWithSaiInternal();
13631387
writeWithSaiInternal();
13641388
}
@@ -1410,6 +1434,10 @@ private void writeWithSaiInternal() throws Exception
14101434
@Test
14111435
public void testSkipBuildingIndexesWithSAI() throws Exception
14121436
{
1437+
Assume.assumeTrue("Skip test when using DaemonInitialization without Murmur3Partitioner",
1438+
!DatabaseDescriptor.isDaemonInitialized()
1439+
|| DatabaseDescriptor.getPartitioner() instanceof Murmur3Partitioner);
1440+
14131441
String schema = "CREATE TABLE " + qualifiedTable + " ("
14141442
+ " k int PRIMARY KEY,"
14151443
+ " v1 text,"

0 commit comments

Comments
 (0)