Merge pull request 'feat(Gatlin): Setup' (#1) from feat/NCS-57 into main

Reviewed-on: #1
This commit was merged in pull request #1.
This commit is contained in:
2026-05-03 13:00:32 +02:00
24 changed files with 619 additions and 2 deletions
+8 -2
View File
@@ -1,7 +1,13 @@
# ---> Scala
# Scala
*.class
*.log
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
# JVM crash logs
hs_err_pid*
# Gradle
build/
.gradle/
# Gatling results
results/
+8
View File
@@ -0,0 +1,8 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
Generated
+1
View File
@@ -0,0 +1 @@
gatlin
+13
View File
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/gatling/scala" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/gatling/resources" type="scala-resource" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="scala-sdk-3.5.1" level="application" />
</component>
</module>
+5
View File
@@ -0,0 +1,5 @@
<component name="ProjectCodeStyleConfiguration">
<state>
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
</state>
</component>
+6
View File
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<bytecodeTargetLevel target="26" />
</component>
</project>
+16
View File
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleMigrationSettings" migrationVersion="1" />
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
</set>
</option>
</GradleProjectSettings>
</option>
</component>
</project>
+19
View File
@@ -0,0 +1,19 @@
<component name="libraryTable">
<library name="Gradle: scala-sdk-2.13.16" type="Scala">
<properties>
<compiler-classpath>
<root url="file://$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.scala-lang/scala-compiler/2.13.16/341e484680c23a379e9935a7343a28969ff113a/scala-compiler-2.13.16.jar" />
<root url="file://$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.scala-sbt/compiler-bridge_2.13/1.12.0/adefab54da046304c612e5c8155e15128487bd91/compiler-bridge_2.13-1.12.0-sources.jar" />
<root url="file://$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.scala-sbt/compiler-interface/1.12.0/8c684a52535bd2d7cd436a9f5769364a839a5bc3/compiler-interface-1.12.0.jar" />
<root url="file://$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.scala-lang/scala-reflect/2.13.16/4958d4e43faf2d6d66f18ce2aa9a3e5ba141f87b/scala-reflect-2.13.16.jar" />
<root url="file://$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.scala-lang/scala-library/2.13.16/9e064d9304904fd7b6bd2b55a9e601b8c1c9006e/scala-library-2.13.16.jar" />
<root url="file://$USER_HOME$/.gradle/caches/modules-2/files-2.1/io.github.java-diff-utils/java-diff-utils/4.15/a8b782ac93bf6c714526ac880adef7c52a87dad7/java-diff-utils-4.15.jar" />
<root url="file://$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jline/jline/3.27.1/cf514b38110b670f7ecd965a1c4521d8b703bf47/jline-3.27.1-jdk8.jar" />
<root url="file://$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.scala-sbt/util-interface/1.11.5/e691fff26e8814e5773084bec55639b1e7e30fed/util-interface-1.11.5.jar" />
</compiler-classpath>
</properties>
<CLASSES />
<JAVADOC />
<SOURCES />
</library>
</component>
+10
View File
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="FrameworkDetectionExcludesConfiguration">
<file type="web" url="file://$PROJECT_DIR$" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_X" default="true" project-jdk-name="openjdk-26" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>
+9
View File
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ScalaCompilerConfiguration">
<profile name="Gradle 1" modules="gatlin.gatling,gatlin.main,gatlin.test">
<option name="deprecationWarnings" value="true" />
<option name="uncheckedWarnings" value="true" />
</profile>
</component>
</project>
+6
View File
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ScalaProjectSettings">
<option name="scala3DisclaimerShown" value="true" />
</component>
</project>
Generated
+12
View File
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CommitMessageInspectionProfile">
<profile version="1.0">
<inspection_tool class="CommitFormat" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="CommitNamingConvention" enabled="true" level="WARNING" enabled_by_default="true" />
</profile>
</component>
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>
+74
View File
@@ -1,2 +1,76 @@
# Gatlin
Load and integration tests for the Kubernetes cluster, built with [Gatling](https://gatling.io/) (Scala DSL).
## Prerequisites
- A JVM (21+) — required to run the Gradle wrapper
- No local Gradle or Scala installation required — the wrapper downloads both automatically
## Running simulations
```bash
./gradlew gatlingRun \
-PbaseUrl=http://<cluster-service> \
-PauthToken=<bearer-token>
```
On Windows:
```bat
gradlew.bat gatlingRun -PbaseUrl=http://<cluster-service> -PauthToken=<bearer-token>
```
The bearer token can also be supplied via the environment variable `GATLING_AUTH_TOKEN` instead of `-PauthToken`.
## Running a specific simulation
```bash
./gradlew gatlingRun --simulation simulations.SmokeTestSimulation \
-PbaseUrl=http://<cluster-service> \
-PauthToken=<bearer-token>
```
## Reports
HTML reports are generated under `build/reports/gatling/` after each run.
## Adding a new simulation
1. Create a class in `src/gatling/scala/simulations/` that extends `BaseSimulation`.
2. Define your scenario and call `setUp(...).protocols(httpProtocol)` — the bearer token and base URL are inherited automatically.
```scala
package simulations
import base.BaseSimulation
import io.gatling.core.Predef._
import io.gatling.http.Predef._
class MyServiceSimulation extends BaseSimulation {
private val scn = scenario("My Service")
.exec(
http("GET /api/resource")
.get("/api/resource")
.check(status.is(200))
)
setUp(
scn.inject(rampUsers(10).during(30))
).protocols(httpProtocol)
}
```
## Project structure
```
src/
gatling/
scala/
base/ - BaseSimulation (shared protocol, auth)
simulations/ - one class per scenario group
resources/
gatling.conf - Gatling configuration overrides
data/ - CSV feeders
bodies/ - request body templates
```
+32
View File
@@ -0,0 +1,32 @@
plugins {
id 'scala'
id 'io.gatling.gradle' version '3.15.0.1'
}
gatling {
enterprise {
// Enterprise Cloud configuration reference: https://docs.gatling.io/reference/integrations/build-tools/gradle-plugin/#running-your-simulations-on-gatling-enterprise-cloud
}
}
tasks.withType(ScalaCompile) {
scalaCompileOptions.forkOptions.with {
jvmArgs = ['-Xss100m'] // Scala compiler may require a larger stack size when compiling Gatling simulations
}
}
tasks.withType(io.gatling.gradle.GatlingRunTask) {
jvmArgs = [
'--add-opens=java.base/java.lang=ALL-UNNAMED',
"-Dtarget.baseUrl=${findProperty('baseUrl') ?: 'http://localhost:8080'}",
"-Dgatling.authToken=${findProperty('authToken') ?: System.getenv('GATLING_AUTH_TOKEN') ?: ''}"
]
}
repositories {
mavenCentral()
}
dependencies {
implementation 'org.scala-lang:scala-library:2.13.16'
}
+1
View File
@@ -0,0 +1 @@
org.gradle.configuration-cache=true
Binary file not shown.
+7
View File
@@ -0,0 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Vendored
+213
View File
@@ -0,0 +1,213 @@
#!/bin/sh
#
# Copyright © 2015-2021 the original authors.
#
# Licensed 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
#
# https://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.
#
##############################################################################
#
# Gradle start up script for POSIX generated by "Gradle".
#
# Important for running:
#
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
# noncompliant, but you have some other POSIX-compliant shell such as ksh or
# bash, then to run this script, type that shell name before the normally
# positional parameters. For example:
#
# ksh Gradle
#
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:
# * functions;
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit».
#
# Important for users:
#
# (2) This script is auto-generated by the Gradle build system.
# It is not intended to be modified by users. Run ./gradlew --version to
# verify the Gradle version of the wrapper.
#
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
app_path=$0
# Need this for daisy-chained symlinks.
while
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
[ -h "$app_path" ]
do
ls=$( ls -ld "$app_path" )
link=${ls#*' -> '}
case $link in #(
/*) app_path=$link ;; #( absolute
*) app_path=$APP_HOME$link ;; #( relative
esac
done
# This is reliable for symlinks on Linux and macOS.
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
APP_NAME="Gradle"
APP_BASE_NAME=${0##*/}
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
warn () {
echo "$*"
}
die () {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "$( uname )" in #(
CYGWIN* ) cygwin=true ;; #(
Darwin* ) darwin=true ;; #(
MSYS* | MINGW* ) msys=true ;; #(
NONSTOP* ) nonstop=true ;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD=$JAVA_HOME/jre/sh/java
else
JAVACMD=$JAVA_HOME/bin/java
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
;;
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
fi
# Collect all arguments for the java command, stacking in reverse order:
# * args from the command line
# * the main class name
# * -classpath
# * -D...appname settings
# * --module-path (only if needed)
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
# For Cygwin or MSYS, switch paths to Windows format before running java
if "$cygwin" || "$msys" ; then
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
JAVACMD=$( cygpath --unix "$JAVACMD" )
# Now convert the arguments - kludge to limit ourselves to /bin/sh
for arg do
if
case $arg in #(
-*) false ;; # don't mess with options #(
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
[ -e "$t" ] ;; #(
*) false ;;
esac
then
arg=$( cygpath --path --ignore --mixed "$arg" )
fi
# Roll the args list around exactly as many times as the number of
# temporary variables. (e.g., single temporary variable) to print
# something that can later be joined together to form a single variable.
set -- "$@" "$arg"
shift
done
fi
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \
"$@"
# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi
# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
#
# In Bash we could simply go:
#
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
# set -- "${ARGS[@]}" "$@"
#
# but POSIX shell has neither arrays nor command substitution, so instead we
# post-process each arg (as a line of input to sed) to backslash-escape any
# temporary variable character.
eval "set -- $(
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
xargs -n1 |
sed ' s~[^a-zA-Z0-9/=@_-]~\\&~g; ' |
tr '\n' ' '
) $@"
exec "$JAVACMD" "$@"
Vendored
+92
View File
@@ -0,0 +1,92 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
goto fail
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell
if %ERRORLEVEL% equ 0 goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
+1
View File
@@ -0,0 +1 @@
rootProject.name = 'gatlin'
+6
View File
@@ -0,0 +1,6 @@
gatling {
http {
# Disable Google Analytics telemetry
enableGA = false
}
}
+19
View File
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%-5level] %logger{15} - %msg%n%rEx</pattern>
</encoder>
<immediateFlush>false</immediateFlush>
</appender>
<!-- uncomment and set to DEBUG to log all failing HTTP requests -->
<!-- uncomment and set to TRACE to log all HTTP requests -->
<!--<logger name="io.gatling.http.engine.response" level="TRACE" />-->
<root level="WARN">
<appender-ref ref="CONSOLE" />
</root>
</configuration>
@@ -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)
}