feat(Gatlin): Setup

Added Gatlin Setup and a test "test".
This commit is contained in:
LQ63
2026-05-01 00:36:18 +02:00
parent df4f1809a9
commit 0c5b83aa74
25 changed files with 768 additions and 0 deletions
@@ -0,0 +1,26 @@
package base
import io.gatling.core.Predef._
import io.gatling.http.Predef._
import io.gatling.http.protocol.HttpProtocolBuilder
/**
* Base class for all simulations.
*
* Reads runtime configuration from JVM system properties set by Gradle:
* -Dtarget.baseUrl=... (via -PbaseUrl=... on the Gradle command line)
* -Dgatling.authToken=... (via -PauthToken=... or env GATLING_AUTH_TOKEN)
*/
abstract class BaseSimulation extends Simulation {
protected val baseUrl: String =
sys.props.getOrElse("target.baseUrl", "http://localhost:8080")
private val authToken: String =
sys.props.getOrElse("gatling.authToken", "")
protected val httpProtocol: HttpProtocolBuilder = http
.baseUrl(baseUrl)
.header("Authorization", s"Bearer $authToken")
.header("Accept", "application/json")
}
@@ -0,0 +1,35 @@
package simulations
import base.BaseSimulation
import io.gatling.core.Predef._
import io.gatling.http.Predef._
/**
* Smoke test: verifies the cluster is reachable and the bearer token is accepted.
*
* Runs a single virtual user that hits GET /healthz and asserts:
* - HTTP 200
* - Response time under 2 000 ms
*
* Use this as a reference when writing new simulations.
*
* Run:
* ./gradlew gatlingRun -PbaseUrl=http://<cluster-service> -PauthToken=<token>
*/
class SmokeTestSimulation extends BaseSimulation {
private val healthzPath: String =
sys.props.getOrElse("healthz.path", "/healthz")
private val scn = scenario("Smoke Test")
.exec(
http(s"GET $healthzPath")
.get(healthzPath)
.check(status.is(200))
.check(responseTimeInMillis.lte(2000))
)
setUp(
scn.inject(atOnceUsers(1))
).protocols(httpProtocol)
}