dcapwell commented on code in PR #101: URL: https://github.com/apache/cassandra-easy-stress/pull/101#discussion_r3785913644
########## build.gradle.kts: ########## @@ -0,0 +1,336 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import com.netflix.gradle.plugins.deb.Deb +import com.netflix.gradle.plugins.rpm.Rpm +import io.gitlab.arturbosch.detekt.Detekt +import io.gitlab.arturbosch.detekt.DetektCreateBaselineTask +import org.jetbrains.kotlin.gradle.dsl.JvmTarget +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile +import org.redline_rpm.header.Os + +plugins { + idea + java + application + alias(libs.plugins.jib) + alias(libs.plugins.kotlin.jvm) + alias(libs.plugins.kotlin.serialization) + alias(libs.plugins.nebula.ospackage) + alias(libs.plugins.nebula.ospackage.application) + alias(libs.plugins.ktlint) + alias(libs.plugins.detekt) + alias(libs.plugins.shadow) + alias(libs.plugins.kover) +} + +apply(plugin = "kotlin") + +group = "org.apache.cassandra" + +java { + sourceCompatibility = JavaVersion.VERSION_21 + targetCompatibility = JavaVersion.VERSION_21 +} + +application { + applicationName = "cassandra-easy-stress" + mainClass = "org.apache.cassandra.easystress.MainKt" +} + +repositories { + mavenCentral() +} + +dependencies { + implementation(libs.jcommander) + implementation(libs.commons.text) + implementation(libs.commons.math3) + + // Java driver v4 + implementation(libs.cassandra.driver.core) + implementation(libs.jackson.module.kotlin) + + implementation(libs.reflections) + + // Logging + implementation(libs.log4j.api) + implementation(libs.log4j.core) + implementation(libs.log4j.api.kotlin) + implementation(libs.kotlin.reflect) + // maps the datastax driver slf4j calls to log4j + implementation(libs.log4j.slf4j18.impl) + + // needed for yaml logging configurations + implementation(libs.jackson.databind) + implementation(libs.jackson.dataformat.yaml) + + // Metrics + implementation(libs.dropwizard.metrics.core) + implementation(libs.prometheus.simpleclient) + implementation(libs.prometheus.simpleclient.dropwizard) + implementation(libs.prometheus.simpleclient.httpserver) + + implementation(libs.guava) + implementation(libs.mordant) + implementation(libs.progressbar) + implementation(libs.hdrhistogram) + implementation(libs.agrona) // can't use the 2.x or 1.23+ line as it requires JDK 17 + + // Parquet support + implementation(libs.parquet.hadoop) + implementation(libs.hadoop.common) + implementation(libs.hadoop.mapreduce.client.common) + + // MCP Server dependencies + implementation(libs.mcp.sdk) { + exclude(group = "org.slf4j", module = "slf4j-api") + } + implementation(libs.ktor.server.core) { + exclude(group = "org.slf4j", module = "slf4j-api") + } + implementation(libs.ktor.server.cio) { + exclude(group = "org.slf4j", module = "slf4j-api") + } + implementation(libs.ktor.server.content.negotiation) { + exclude(group = "org.slf4j", module = "slf4j-api") + } + implementation(libs.ktor.serialization.kotlinx.json) { + exclude(group = "org.slf4j", module = "slf4j-api") + } + implementation(libs.ktor.server.sse) { + exclude(group = "org.slf4j", module = "slf4j-api") + } + + // Test dependencies + testImplementation(libs.junit.jupiter.engine) + testImplementation(libs.junit.jupiter.params) + testRuntimeOnly(libs.junit.platform.launcher) + testImplementation(libs.assertj.core) + testImplementation(libs.kotlin.test.junit) + testImplementation(libs.mockk) + testImplementation(libs.kotlinx.coroutines.test) + testImplementation(platform(libs.testcontainers.bom)) + testImplementation(libs.testcontainers.core) + testImplementation(libs.testcontainers.cassandra) +} + +tasks.named<KotlinCompile>("compileKotlin") { + compilerOptions.jvmTarget.set(JvmTarget.JVM_21) +} +tasks.named<KotlinCompile>("compileTestKotlin") { + compilerOptions.jvmTarget.set(JvmTarget.JVM_21) +} + +sourceSets { + main { + java.srcDirs("src/main/kotlin") + } + test { + java.srcDirs("src/test/kotlin") + } +} + +tasks.test { + useJUnitPlatform() + + // Make Gradle aware of CASSANDRA_VERSION environment variable + // This ensures tests rerun when the version changes + val cassandraVersion = System.getenv("CASSANDRA_VERSION") ?: "5.0" + inputs.property("cassandraVersion", cassandraVersion) + + // Pass environment variable to test JVM + environment("CASSANDRA_VERSION", cassandraVersion) +} + +// Create individual test tasks for each Cassandra version +listOf("4.0", "4.1", "5.0").forEach { version -> + val versionName = version.replace(".", "") + tasks.register<Test>("test$versionName") { + group = "Verification" + description = "Run tests against Cassandra $version" + + useJUnitPlatform() + + // Set the Cassandra version for this test task + environment("CASSANDRA_VERSION", version) + inputs.property("cassandraVersion", version) + + // Use same test sources and classpath as main test task + testClassesDirs = + sourceSets.test + .get() + .output.classesDirs + classpath = sourceSets.test.get().runtimeClasspath + + doFirst { + println() + println("=".repeat(80)) + println("Testing Cassandra $version") + println("=".repeat(80)) + } + + doLast { + println() + println("✅ Cassandra $version tests PASSED") + } + } +} + +tasks.register("testAllVersions") { + group = "Verification" + description = "Run tests against all Cassandra versions (4.0, 4.1, 5.0)" + + // Depend on all version-specific test tasks + dependsOn(tasks.named("test40"), tasks.named("test41"), tasks.named("test50")) + + // Ensure sequential execution + tasks.named("test41") { mustRunAfter(tasks.named("test40")) } + tasks.named("test50") { mustRunAfter(tasks.named("test41")) } + + doFirst { + println() + println("=".repeat(80)) + println("Running tests against all Cassandra versions: 4.0, 4.1, 5.0") + println("=".repeat(80)) + } + + doLast { + println() + println("=".repeat(80)) + println("Test Summary") + println("=".repeat(80)) + println("✅ Cassandra 4.0: PASSED") + println("✅ Cassandra 4.1: PASSED") + println("✅ Cassandra 5.0: PASSED") + println("=".repeat(80)) + println() + } +} + +tasks.register<Exec>("docs") { + dependsOn("shadowJar") + dependsOn("generateExamples") + + environment("CASSANDRA_EASY_STRESS_VERSION", project.version.toString()) + commandLine("docker-compose", "up", "docs") + group = "Documentation" + description = "Build website documentation" +} + +tasks.register<Exec>("generateExamples") { + dependsOn("shadowJar") + commandLine("manual/generate_examples.sh") + group = "Documentation" + description = "Generate examples for documentation" +} + +jib { + to { + image = "ghcr.io/${System.getenv("GITHUB_REPOSITORY") ?: "apache/cassandra-easy-stress"}" + tags = setOf("latest") + } + from { + image = "eclipse-temurin:21-jre" + } + container { + // Generational ZGC by default; override at "docker run" time with + // -e JAVA_TOOL_OPTIONS="..." to select a different collector. + environment = + mapOf( + "JAVA_TOOL_OPTIONS" to "-XX:+UseZGC -XX:+ZGenerational", Review Comment: `bin/cassandra-easy-stress` explicitly avoids `-XX:+ZGenerational` once we are jdk 23+ -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
