This is an automated email from the ASF dual-hosted git repository.
dcapwell pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cassandra-easy-stress.git
The following commit(s) were added to refs/heads/main by this push:
new 43aacab Default protocol compression to lz4 in cassandra-easy-stress
(#108)
43aacab is described below
commit 43aacab4bf600562acf21f783186375c731dbc75
Author: Aparna Naik <[email protected]>
AuthorDate: Mon Oct 19 13:22:30 2026 -0700
Default protocol compression to lz4 in cassandra-easy-stress (#108)
---
build.gradle.kts | 1 +
gradle/libs.versions.toml | 2 ++
.../apache/cassandra/easystress/commands/Run.kt | 12 +++++++
.../cassandra/easystress/CommandLineParserTest.kt | 37 ++++++++++++++++++++++
4 files changed, 52 insertions(+)
diff --git a/build.gradle.kts b/build.gradle.kts
index e6f806d..2d38a58 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -69,6 +69,7 @@ dependencies {
// Java driver v4
implementation(libs.cassandra.driver.core)
+ implementation(libs.lz4.java)
implementation(libs.jackson.module.kotlin)
implementation(libs.reflections)
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
index 949d613..74c653f 100644
--- a/gradle/libs.versions.toml
+++ b/gradle/libs.versions.toml
@@ -11,6 +11,7 @@ jcommander = "1.82"
commons-text = "1.3"
commons-math3 = "3.6.1"
cassandra-driver = "4.19.0"
+lz4 = "1.12.0"
jackson = "2.17.1"
jackson-kotlin = "2.13.4"
jackson-yaml = "2.13.4"
@@ -42,6 +43,7 @@ commons-text = { module = "org.apache.commons:commons-text",
version.ref = "comm
commons-math3 = { module = "org.apache.commons:commons-math3", version.ref =
"commons-math3" }
cassandra-driver-core = { module = "org.apache.cassandra:java-driver-core",
version.ref = "cassandra-driver" }
+lz4-java = { module = "at.yawk.lz4:lz4-java", version.ref = "lz4" }
jackson-databind = { module = "com.fasterxml.jackson.core:jackson-databind",
version.ref = "jackson" }
jackson-module-kotlin = { module =
"com.fasterxml.jackson.module:jackson-module-kotlin", version.ref =
"jackson-kotlin" }
diff --git a/src/main/kotlin/org/apache/cassandra/easystress/commands/Run.kt
b/src/main/kotlin/org/apache/cassandra/easystress/commands/Run.kt
index b856788..bd37eae 100644
--- a/src/main/kotlin/org/apache/cassandra/easystress/commands/Run.kt
+++ b/src/main/kotlin/org/apache/cassandra/easystress/commands/Run.kt
@@ -135,6 +135,12 @@ class Run(
@Parameter(names = ["--compression"], description = "Compression option to
pass to CREATE TABLE. Example: {'class':'ZstdCompressor'}")
var compression = ""
+ @Parameter(
+ names = ["--protocol-compression"],
+ description = "Protocol compression algorithm ('lz4' or 'none').
Default is 'lz4'.",
+ )
+ var protocolCompression: String = "lz4"
+
/**
* Keyspace to use for stress testing.
*
@@ -351,6 +357,7 @@ class Run(
var configLoaderBuilder =
DriverConfigLoader
.programmaticBuilder()
+ .withString(DefaultDriverOption.PROTOCOL_COMPRESSION,
protocolCompression.trim().lowercase())
// Default consistency levels
.withString(DefaultDriverOption.REQUEST_CONSISTENCY,
consistencyLevel.toString())
.withString(DefaultDriverOption.REQUEST_SERIAL_CONSISTENCY,
serialConsistencyLevel.toString())
@@ -422,6 +429,11 @@ class Run(
"Partition generator Supports random, normal, and sequence.",
)
+ Preconditions.checkArgument(
+ protocolCompression.trim().lowercase() in setOf("lz4", "none"),
+ "Protocol compression must be either 'lz4' or 'none'.",
+ )
+
val workload = Workload.getWorkloads().get([email protected]) ?:
error("${[email protected]} profile does not exist")
// Check the workload parameters exist in the workload before we start
testing.
diff --git
a/src/test/kotlin/org/apache/cassandra/easystress/CommandLineParserTest.kt
b/src/test/kotlin/org/apache/cassandra/easystress/CommandLineParserTest.kt
index ca3be5e..e3d4287 100644
--- a/src/test/kotlin/org/apache/cassandra/easystress/CommandLineParserTest.kt
+++ b/src/test/kotlin/org/apache/cassandra/easystress/CommandLineParserTest.kt
@@ -21,6 +21,9 @@ import com.datastax.oss.driver.api.core.ConsistencyLevel
import org.apache.cassandra.easystress.commands.Run
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test
+import org.junit.jupiter.api.assertThrows
+import org.junit.jupiter.params.ParameterizedTest
+import org.junit.jupiter.params.provider.CsvSource
internal class CommandLineParserTest {
@Test
@@ -43,4 +46,38 @@ internal class CommandLineParserTest {
assertThat(runCommand.consistencyLevel).isEqualTo(ConsistencyLevel.QUORUM)
assertThat(runCommand.serialConsistencyLevel).isEqualTo(ConsistencyLevel.SERIAL)
}
+
+ @Test
+ fun testDefaultProtocolCompression() {
+ val args = arrayOf("run", "BasicTimeSeries")
+ val result = CommandLineParser.parse(args)
+ val runCommand = result.getCommandInstance() as Run
+ assertThat(runCommand.protocolCompression).isEqualTo("lz4")
+ }
+
+ @ParameterizedTest
+ @CsvSource(
+ "--protocol-compression, lz4, lz4",
+ "--protocol-compression, none, none",
+ )
+ fun testProtocolCompressionParsing(
+ flag: String,
+ value: String,
+ expected: String,
+ ) {
+ val args = arrayOf("run", "BasicTimeSeries", flag, value)
+ val result = CommandLineParser.parse(args)
+ val runCommand = result.getCommandInstance() as Run
+ assertThat(runCommand.protocolCompression).isEqualTo(expected)
+ }
+
+ @Test
+ fun testInvalidProtocolCompressionFails() {
+ val args = arrayOf("run", "BasicTimeSeries", "--protocol-compression",
"snappy")
+ val result = CommandLineParser.parse(args)
+ val runCommand = result.getCommandInstance() as Run
+ assertThrows<IllegalArgumentException> {
+ runCommand.execute()
+ }
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]