9 Commits

Author SHA1 Message Date
lq64 25ecc1e097 feat: NCS-73 Refine Gatlin tests to reflect ordinary user behaviour (#7)
Added realistic user behaviour
Smoke Test

  1 user, runs once.
  Executes the full user journey exactly once. The goal is a fast sanity check — if this passes, the system is up
  and the critical path (register, login, import, move, resign) works end-to-end. Run this before any heavier
  test.

  ---
  Load Test

  Ramps up to maxUsers (default 10) over rampDuration (default 60s).
  Simulates normal growing traffic. Users are added gradually, each completing the full journey. This reveals how
  the system behaves under typical production load and establishes a performance baseline (response times, error
  rates) to compare other tests against.

  ---
  Stress Test

  Starts at startUsers (default 2), adds usersIncrement (default 2) users every stepDuration (default 30s) for
  steps (default 2) steps, with ramps between.
  Deliberately pushes the system beyond normal capacity in controlled steps. Each step holds load steady before
  increasing, so you can pinpoint exactly at which user count the system starts degrading or failing — the
  breaking point.

  ---
  Endurance Test

  Holds concurrentUsers (default 3) constant for duration (default 300s).
  Keeps a steady number of users playing full games repeatedly over a long period. This is the most important test
   for detecting slow degradation — memory leaks, connection pool exhaustion, database lock buildup — things that
  only appear after sustained use rather than under peak load.

  ---
  Spike Test

  Baseline → sudden burst of spikeUsers (default 15) → 5s pause → back to baseline.
  Simulates an unexpected traffic surge (e.g. a news article or viral moment). Tests whether the system can absorb
   a sudden large wave of users registering and starting games simultaneously, and whether it recovers cleanly
  once the spike subsides.

---------

Co-authored-by: LQ63 <lkhermann@web.de>
Reviewed-on: #7
Reviewed-by: Janis <janis-e@gmx.de>
Co-authored-by: Leon Hermann <lq@blackhole.local>
Co-committed-by: Leon Hermann <lq@blackhole.local>
2026-05-05 19:51:12 +02:00
lq64 427ed920d0 feat: NCS-62, NCS-64 Endurance Test, Spike Test (#6)
Added two new types of tests

---------

Co-authored-by: LQ63 <lkhermann@web.de>
Reviewed-on: #6
2026-05-05 17:17:38 +02:00
lq64 99ea686ed5 feat: NCS-60 Stress Test (#3)
Added a stress test and configured the parameters to simulate a smaller load

---------

Co-authored-by: LQ63 <lkhermann@web.de>
Reviewed-on: #3
2026-05-05 17:09:42 +02:00
lq64 0db2bb777f NCS-59 Create Load tests (#2)
Added a load test and and slight change in structure. To execute type:

Run the load test:
  ./gradlew.bat gatlingRun --simulation simulations.LoadTestSimulation -PbaseUrl=https://st.nowchess.janis-eccarius.de
  -PauthToken=<token> -PmaxUsers=20 -PrampDuration=60

  Run smoke test:
  ./gradlew.bat gatlingRun --simulation simulations.SmokeTestSimulation -PbaseUrl=https://st.nowchess.janis-eccarius.de
  -PauthToken=<token>

---------

Co-authored-by: LQ63 <lkhermann@web.de>
Reviewed-on: #2
Reviewed-by: Janis <janis-e@gmx.de>
2026-05-03 22:26:46 +02:00
lq64 3fa39bb4f4 Merge pull request 'feat(Gatlin): Setup' (#1) from feat/NCS-57 into main
Reviewed-on: #1
2026-05-03 13:00:32 +02:00
LQ63 a7937fcef8 fix(Gatlin): Setup
deleted .claude
2026-05-03 12:58:56 +02:00
LQ63 00c2f99415 fix(Gatlin): Setup
gitignore
2026-05-01 01:07:27 +02:00
LQ63 bf771aff65 docs(Gatlin): Setup
Deleted documentation plan
2026-05-01 00:38:45 +02:00
LQ63 0c5b83aa74 feat(Gatlin): Setup
Added Gatlin Setup and a test "test".
2026-05-01 00:36:18 +02:00
31 changed files with 826 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
```
+44
View File
@@ -0,0 +1,44 @@
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') ?: ''}",
"-Dhealthz.path=${findProperty('healthzPath') ?: '/health'}",
"-DmaxUsers=${findProperty('maxUsers') ?: '10'}",
"-DrampDuration=${findProperty('rampDuration') ?: '60'}",
"-DstartUsers=${findProperty('startUsers') ?: '2'}",
"-DusersIncrement=${findProperty('usersIncrement') ?: '2'}",
"-Dsteps=${findProperty('steps') ?: '2'}",
"-DstepDuration=${findProperty('stepDuration') ?: '30'}",
"-DconcurrentUsers=${findProperty('concurrentUsers') ?: '3'}",
"-Dduration=${findProperty('duration') ?: '300'}",
"-DbaselineUsers=${findProperty('baselineUsers') ?: '2'}",
"-DbaselineDuration=${findProperty('baselineDuration') ?: '20'}",
"-DspikeUsers=${findProperty('spikeUsers') ?: '15'}"
]
}
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,37 @@
package base
import io.gatling.core.Predef._
import io.gatling.core.structure.ScenarioBuilder
import io.gatling.http.Predef._
import io.gatling.http.protocol.HttpProtocolBuilder
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")
.header("Content-Type", "application/json")
protected def scenarioFromEndpoint(endpoint: base.Endpoint): ScenarioBuilder = {
val base = endpoint.method.toUpperCase match {
case "GET" => http(endpoint.name).get(endpoint.path)
case "POST" => http(endpoint.name).post(endpoint.path)
case "PUT" => http(endpoint.name).put(endpoint.path)
case "DELETE" => http(endpoint.name).delete(endpoint.path)
case "PATCH" => http(endpoint.name).patch(endpoint.path)
}
val withBody = endpoint.body.fold(base)(b => base.body(StringBody(b)))
scenario(endpoint.name).exec(
withBody
.check(status.is(endpoint.expectedStatus))
.check(responseTimeInMillis.lte(endpoint.maxResponseTimeMs))
)
}
}
+10
View File
@@ -0,0 +1,10 @@
package base
case class Endpoint(
name: String,
method: String,
path: String,
body: Option[String] = None,
expectedStatus: Int = 200,
maxResponseTimeMs: Int = 5000
)
@@ -0,0 +1,15 @@
package endpoints
import base.Endpoint
object BoardEndpoints {
val createGame: Endpoint = Endpoint(
name = "Create Game",
method = "GET",
path = "/api/account/official-bots/",
// expectedStatus = 200
)
val all: List[Endpoint] = List(createGame)
}
@@ -0,0 +1,61 @@
package scenarios
import io.gatling.core.Predef._
import io.gatling.core.structure.ScenarioBuilder
import io.gatling.http.Predef._
import scala.concurrent.duration._
object ChessUserScenario {
private def makeMove(uci: String) =
http(s"Move $uci")
.post(session => s"/api/board/game/${session("gameId").as[String]}/move/$uci")
.header("Authorization", "${jwt}")
.check(status.in(200, 201))
val play: ScenarioBuilder = scenario("Chess User Journey")
.exec(session => session.set("username", s"user_${System.currentTimeMillis()}_${session.userId}_${java.util.UUID.randomUUID().toString.take(8)}"))
.exec(
http("Register")
.post("/api/account")
.body(StringBody(session =>
s"""{"username":"${session("username").as[String]}","email":"${session("username").as[String]}@test.com","password":"Password123!"}"""
))
.check(status.is(200))
)
.exec(
http("Login")
.post("/api/account/login")
.body(StringBody(session =>
s"""{"username":"${session("username").as[String]}","password":"Password123!"}"""
))
.check(status.is(200))
.check(jsonPath("$.token").saveAs("jwt"))
)
.exec(
http("Import Game")
.post("/api/board/game/import/fen")
.header("Authorization", "${jwt}")
.body(StringBody(session => {
val username = session("username").as[String]
s"""{
| "fen": "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1",
| "white": {"id": "$username", "displayName": "$username"},
| "black": {"id": "opponent_${session.userId}", "displayName": "Opponent"},
| "timeControl": {"limitSeconds": 300, "incrementSeconds": 3}
|}""".stripMargin
}))
.check(status.in(200, 201))
.check(jsonPath("$.gameId").saveAs("gameId"))
)
.exec(makeMove("e2e4"))
.exec(makeMove("e7e5"))
.exec(makeMove("g1f3"))
.exec(
http("Resign")
.post(session => s"/api/board/game/${session("gameId").as[String]}/resign")
.header("Authorization", "${jwt}")
.check(status.in(200, 201, 204))
)
}
@@ -0,0 +1,26 @@
package simulations
import base.BaseSimulation
import scenarios.ChessUserScenario
import io.gatling.core.Predef._
import io.gatling.http.Predef._
import scala.concurrent.duration._
class EnduranceTestSimulation extends BaseSimulation {
private val concurrentUsers = sys.props.getOrElse("concurrentUsers", "3").toInt
private val duration = sys.props.getOrElse("duration", "300").toInt
override protected val httpProtocol = http
.baseUrl(baseUrl)
.header("Accept", "application/json")
.header("Content-Type", "application/json")
setUp(
ChessUserScenario.play
.inject(
constantConcurrentUsers(concurrentUsers).during(duration.seconds)
)
).protocols(httpProtocol)
}
@@ -0,0 +1,25 @@
package simulations
import base.BaseSimulation
import scenarios.ChessUserScenario
import io.gatling.core.Predef._
import io.gatling.http.Predef._
import scala.concurrent.duration._
class LoadTestSimulation extends BaseSimulation {
private val maxUsers = sys.props.getOrElse("maxUsers", "5").toInt
private val rampDuration = sys.props.getOrElse("rampDuration", "60").toInt
// Each virtual user authenticates individually, so no global Bearer token
override protected val httpProtocol = http
.baseUrl(baseUrl)
.header("Accept", "application/json")
.header("Content-Type", "application/json")
setUp(
ChessUserScenario.play
.inject(rampUsers(maxUsers).during(rampDuration.seconds))
).protocols(httpProtocol)
}
@@ -0,0 +1,19 @@
package simulations
import base.BaseSimulation
import scenarios.ChessUserScenario
import io.gatling.core.Predef._
import io.gatling.http.Predef._
class SmokeTestSimulation extends BaseSimulation {
override protected val httpProtocol = http
.baseUrl(baseUrl)
.header("Accept", "application/json")
.header("Content-Type", "application/json")
setUp(
ChessUserScenario.play
.inject(atOnceUsers(1))
).protocols(httpProtocol)
}
@@ -0,0 +1,30 @@
package simulations
import base.BaseSimulation
import scenarios.ChessUserScenario
import io.gatling.core.Predef._
import io.gatling.http.Predef._
import scala.concurrent.duration._
class SpikeTestSimulation extends BaseSimulation {
private val baselineUsers = sys.props.getOrElse("baselineUsers", "2").toInt
private val baselineDuration = sys.props.getOrElse("baselineDuration", "20").toInt
private val spikeUsers = sys.props.getOrElse("spikeUsers", "15").toInt
override protected val httpProtocol = http
.baseUrl(baseUrl)
.header("Accept", "application/json")
.header("Content-Type", "application/json")
setUp(
ChessUserScenario.play
.inject(
constantUsersPerSec(baselineUsers).during(baselineDuration.seconds),
atOnceUsers(spikeUsers),
nothingFor(5.seconds),
constantUsersPerSec(baselineUsers).during(baselineDuration.seconds)
)
).protocols(httpProtocol)
}
@@ -0,0 +1,33 @@
package simulations
import base.BaseSimulation
import scenarios.ChessUserScenario
import io.gatling.core.Predef._
import io.gatling.http.Predef._
import scala.concurrent.duration._
class StressTestSimulation extends BaseSimulation {
private val startUsers = sys.props.getOrElse("startUsers", "2").toInt
private val usersIncrement = sys.props.getOrElse("usersIncrement", "2").toInt
private val steps = sys.props.getOrElse("steps", "2").toInt
private val stepDuration = sys.props.getOrElse("stepDuration", "30").toInt
private val rampDuration = sys.props.getOrElse("rampDuration", "10").toInt
override protected val httpProtocol = http
.baseUrl(baseUrl)
.header("Accept", "application/json")
.header("Content-Type", "application/json")
setUp(
ChessUserScenario.play
.inject(
incrementConcurrentUsers(usersIncrement)
.times(steps)
.eachLevelLasting(stepDuration.seconds)
.separatedByRampsLasting(rampDuration.seconds)
.startingFrom(startUsers)
)
).protocols(httpProtocol)
}