From 93415c91af3d06504593a87c8b8d7e5d2d65b1ac Mon Sep 17 00:00:00 2001 From: Caleb Rackliffe Date: Tue, 13 Aug 2024 21:12:14 -0500 Subject: [PATCH] Use default commitlog settings in test YAMLs patch by Caleb Rackliffe; reviewed by David Capwell for CASSANDRA-19830 --- CHANGES.txt | 1 + test/conf/cassandra-murmur.yaml | 4 ++-- test/conf/cassandra-seeds.yaml | 4 ++-- test/conf/cassandra.yaml | 4 ++-- test/conf/unit-test-conf/test-native-port.yaml | 4 ++-- .../cassandra/distributed/impl/InstanceConfig.java | 7 +++---- .../distributed/test/RepairBoundaryTest.java | 1 - .../cassandra/distributed/test/RepairTest.java | 1 - .../test/ReplicaFilteringProtectionTest.java | 4 ++-- test/unit/org/apache/cassandra/cql3/CQLTester.java | 13 ++++++++++--- .../cassandra/db/commitlog/CommitLogReaderTest.java | 9 ++++++++- 11 files changed, 32 insertions(+), 20 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index e8dd62d65d..b2424f106f 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,4 +1,5 @@ 4.0.14 + * Use default commitlog settings in test YAMLs (CASSANDRA-19830) * Do not spam log with SSLExceptions (CASSANDRA-18839) * Fix schema.cql created by a snapshot after dropping more than one column (CASSANDRA-19747) * UnsupportedOperationException when reducing scope for LCS compactions (CASSANDRA-19704) diff --git a/test/conf/cassandra-murmur.yaml b/test/conf/cassandra-murmur.yaml index 3c263a5af1..b64f6683c8 100644 --- a/test/conf/cassandra-murmur.yaml +++ b/test/conf/cassandra-murmur.yaml @@ -4,8 +4,8 @@ # cluster_name: Test Cluster memtable_allocation_type: heap_buffers -commitlog_sync: batch -commitlog_sync_batch_window_in_ms: 1.0 +commitlog_sync: periodic +commitlog_sync_period_in_ms: 10000 commitlog_segment_size_in_mb: 5 commitlog_directory: build/test/cassandra/commitlog cdc_raw_directory: build/test/cassandra/cdc_raw diff --git a/test/conf/cassandra-seeds.yaml b/test/conf/cassandra-seeds.yaml index f3279aeb12..675ac2bf51 100644 --- a/test/conf/cassandra-seeds.yaml +++ b/test/conf/cassandra-seeds.yaml @@ -5,8 +5,8 @@ cluster_name: Test Cluster # memtable_allocation_type: heap_buffers memtable_allocation_type: offheap_objects -commitlog_sync: batch -commitlog_sync_batch_window_in_ms: 1.0 +commitlog_sync: periodic +commitlog_sync_period_in_ms: 10000 commitlog_segment_size_in_mb: 5 commitlog_directory: build/test/cassandra/commitlog cdc_raw_directory: build/test/cassandra/cdc_raw diff --git a/test/conf/cassandra.yaml b/test/conf/cassandra.yaml index 7d4886d916..96946709f0 100644 --- a/test/conf/cassandra.yaml +++ b/test/conf/cassandra.yaml @@ -5,8 +5,8 @@ cluster_name: Test Cluster memtable_allocation_type: heap_buffers # memtable_allocation_type: offheap_objects -commitlog_sync: batch -commitlog_sync_batch_window_in_ms: 1.0 +commitlog_sync: periodic +commitlog_sync_period_in_ms: 10000 commitlog_segment_size_in_mb: 5 commitlog_directory: build/test/cassandra/commitlog # commitlog_compression: diff --git a/test/conf/unit-test-conf/test-native-port.yaml b/test/conf/unit-test-conf/test-native-port.yaml index b46525fa29..26cd518564 100644 --- a/test/conf/unit-test-conf/test-native-port.yaml +++ b/test/conf/unit-test-conf/test-native-port.yaml @@ -5,8 +5,8 @@ cluster_name: Test Cluster # memtable_allocation_type: heap_buffers memtable_allocation_type: offheap_objects -commitlog_sync: batch -commitlog_sync_batch_window_in_ms: 1.0 +commitlog_sync: periodic +commitlog_sync_period_in_ms: 10000 commitlog_segment_size_in_mb: 5 commitlog_directory: build/test/cassandra/commitlog # commitlog_compression: diff --git a/test/distributed/org/apache/cassandra/distributed/impl/InstanceConfig.java b/test/distributed/org/apache/cassandra/distributed/impl/InstanceConfig.java index d1714a33bf..5e4b0a24b3 100644 --- a/test/distributed/org/apache/cassandra/distributed/impl/InstanceConfig.java +++ b/test/distributed/org/apache/cassandra/distributed/impl/InstanceConfig.java @@ -105,7 +105,8 @@ public class InstanceConfig implements IInstanceConfig .set("memtable_flush_writers", 1) .set("concurrent_compactors", 1) .set("memtable_heap_space_in_mb", 10) - .set("commitlog_sync", "batch") + .set("commitlog_sync", "periodic") + .set("commitlog_sync_period_in_ms", 10000) .set("storage_port", storage_port) .set("native_transport_port", native_transport_port) .set("endpoint_snitch", DistributedTestSnitch.class.getName()) @@ -117,9 +118,7 @@ public class InstanceConfig implements IInstanceConfig // capacities that are based on `totalMemory` that should be fixed size .set("index_summary_capacity_in_mb", 50l) .set("counter_cache_size_in_mb", 50l) - .set("key_cache_size_in_mb", 50l) - // legacy parameters - .forceSet("commitlog_sync_batch_window_in_ms", 1.0); + .set("key_cache_size_in_mb", 50l); this.featureFlags = EnumSet.noneOf(Feature.class); this.jmxPort = jmx_port; } diff --git a/test/distributed/org/apache/cassandra/distributed/test/RepairBoundaryTest.java b/test/distributed/org/apache/cassandra/distributed/test/RepairBoundaryTest.java index d269bef64d..d21a0750ea 100644 --- a/test/distributed/org/apache/cassandra/distributed/test/RepairBoundaryTest.java +++ b/test/distributed/org/apache/cassandra/distributed/test/RepairBoundaryTest.java @@ -163,7 +163,6 @@ public class RepairBoundaryTest extends TestBaseImpl { cluster = Cluster.build(3) .withConfig(config -> config.set("hinted_handoff_enabled", false) - .set("commitlog_sync_batch_window_in_ms", 5) .set("num_tokens", 1) .set("initial_token", Long.toString(config.num() * 1000)) .with(NETWORK) diff --git a/test/distributed/org/apache/cassandra/distributed/test/RepairTest.java b/test/distributed/org/apache/cassandra/distributed/test/RepairTest.java index b127a74d21..2a9227f184 100644 --- a/test/distributed/org/apache/cassandra/distributed/test/RepairTest.java +++ b/test/distributed/org/apache/cassandra/distributed/test/RepairTest.java @@ -84,7 +84,6 @@ public class RepairTest extends TestBaseImpl { configModifier = configModifier.andThen( config -> config.set("hinted_handoff_enabled", false) - .set("commitlog_sync_batch_window_in_ms", 5) .with(NETWORK) .with(GOSSIP) ); diff --git a/test/distributed/org/apache/cassandra/distributed/test/ReplicaFilteringProtectionTest.java b/test/distributed/org/apache/cassandra/distributed/test/ReplicaFilteringProtectionTest.java index f891dfee5c..e919e77e54 100644 --- a/test/distributed/org/apache/cassandra/distributed/test/ReplicaFilteringProtectionTest.java +++ b/test/distributed/org/apache/cassandra/distributed/test/ReplicaFilteringProtectionTest.java @@ -57,7 +57,6 @@ public class ReplicaFilteringProtectionTest extends TestBaseImpl cluster = init(Cluster.build() .withNodes(REPLICAS) .withConfig(config -> config.set("hinted_handoff_enabled", false) - .set("commitlog_sync", "batch") .set("num_tokens", 1)).start()); // Make sure we start w/ the correct defaults: @@ -68,7 +67,8 @@ public class ReplicaFilteringProtectionTest extends TestBaseImpl @AfterClass public static void teardown() { - cluster.close(); + if (cluster != null) + cluster.close(); } @Test diff --git a/test/unit/org/apache/cassandra/cql3/CQLTester.java b/test/unit/org/apache/cassandra/cql3/CQLTester.java index dc2f334c08..48fddec68a 100644 --- a/test/unit/org/apache/cassandra/cql3/CQLTester.java +++ b/test/unit/org/apache/cassandra/cql3/CQLTester.java @@ -268,14 +268,21 @@ public abstract class CQLTester @BeforeClass public static void setUpClass() { - if (ROW_CACHE_SIZE_IN_MB > 0) - DatabaseDescriptor.setRowCacheSizeInMB(ROW_CACHE_SIZE_IN_MB); - StorageService.instance.setPartitionerUnsafe(Murmur3Partitioner.instance); + prePrepareServer(); // Once per-JVM is enough prepareServer(); } + protected static void prePrepareServer() + { + System.setProperty("cassandra.superuser_setup_delay_ms", "0"); + + if (ROW_CACHE_SIZE_IN_MB > 0) + DatabaseDescriptor.setRowCacheSizeInMB(ROW_CACHE_SIZE_IN_MB); + StorageService.instance.setPartitionerUnsafe(Murmur3Partitioner.instance); + } + @AfterClass public static void tearDownClass() { diff --git a/test/unit/org/apache/cassandra/db/commitlog/CommitLogReaderTest.java b/test/unit/org/apache/cassandra/db/commitlog/CommitLogReaderTest.java index 794f99f47b..45b1dd6644 100644 --- a/test/unit/org/apache/cassandra/db/commitlog/CommitLogReaderTest.java +++ b/test/unit/org/apache/cassandra/db/commitlog/CommitLogReaderTest.java @@ -43,10 +43,17 @@ import org.apache.cassandra.utils.KillerForTests; public class CommitLogReaderTest extends CQLTester { @BeforeClass - public static void beforeClass() + public static void setUpClass() { + prePrepareServer(); + DatabaseDescriptor.setCommitFailurePolicy(Config.CommitFailurePolicy.ignore); JVMStabilityInspector.replaceKiller(new KillerForTests(false)); + + DatabaseDescriptor.setCommitLogSync(Config.CommitLogSync.batch); + + // Once per-JVM is enough + prepareServer(); } @Before