feat(Gatlin): Setup
Added Gatlin Setup and a test "test".
This commit is contained in:
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"permissions": {
|
||||||
|
"allow": [
|
||||||
|
"Bash(gradle wrapper:*)",
|
||||||
|
"Bash(curl -sL \"https://raw.githubusercontent.com/gradle/gradle/v8.13.0/gradle/wrapper/gradle-wrapper.jar\" -o \"C:\\\\AIN-Festplatte\\\\Softwarearchitekturen\\\\Gatlin\\\\gradle\\\\wrapper\\\\gradle-wrapper.jar\")",
|
||||||
|
"WebFetch(domain:raw.githubusercontent.com)",
|
||||||
|
"WebFetch(domain:api.github.com)",
|
||||||
|
"WebFetch(domain:github.com)",
|
||||||
|
"Bash(xargs grep:*)"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
Generated
+8
@@ -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
@@ -0,0 +1 @@
|
|||||||
|
gatlin
|
||||||
Generated
+13
@@ -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>
|
||||||
Generated
+5
@@ -0,0 +1,5 @@
|
|||||||
|
<component name="ProjectCodeStyleConfiguration">
|
||||||
|
<state>
|
||||||
|
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
|
||||||
|
</state>
|
||||||
|
</component>
|
||||||
Generated
+6
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="CompilerConfiguration">
|
||||||
|
<bytecodeTargetLevel target="26" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
Generated
+16
@@ -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
@@ -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>
|
||||||
Generated
+10
@@ -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>
|
||||||
Generated
+9
@@ -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>
|
||||||
Generated
+6
@@ -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
@@ -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>
|
||||||
@@ -1,2 +1,76 @@
|
|||||||
# Gatlin
|
# 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
|
||||||
|
```
|
||||||
|
|||||||
@@ -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'
|
||||||
|
}
|
||||||
@@ -0,0 +1,145 @@
|
|||||||
|
# Implementation Plan: Gatling Setup for Kubernetes Cluster Testing
|
||||||
|
|
||||||
|
**Date:** 2026-04-30
|
||||||
|
**Branch:** `feat/NCS-57`
|
||||||
|
**Stack:** Scala 3.5.1, Gradle, Gatling 3.x (Scala DSL)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Decisions
|
||||||
|
|
||||||
|
| Concern | Decision |
|
||||||
|
|---|---|
|
||||||
|
| Build tool | Gradle |
|
||||||
|
| Language | Scala 3.5.1 |
|
||||||
|
| Gatling API | Scala DSL (Gatling 3.x) |
|
||||||
|
| Authentication | Bearer token via env var `GATLING_AUTH_TOKEN` |
|
||||||
|
| Target base URL | Injected at runtime via Gradle project property `-PbaseUrl=...` |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Steps
|
||||||
|
|
||||||
|
### Step 1 — `build.gradle` + `settings.gradle`
|
||||||
|
|
||||||
|
Create `settings.gradle`:
|
||||||
|
- Set root project name to `gatlin`
|
||||||
|
|
||||||
|
Create `build.gradle`:
|
||||||
|
- Apply `io.gatling.gradle` plugin (3.x)
|
||||||
|
- Set `scalaVersion = '3.5.1'`
|
||||||
|
- Configure `gatlingRun` task to pass `baseUrl` and `authToken` as JVM system properties so simulations can read them via `sys.props`
|
||||||
|
|
||||||
|
Run command:
|
||||||
|
```bash
|
||||||
|
./gradlew gatlingRun -PbaseUrl=http://<cluster-service> -PauthToken=<token>
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Step 2 — Gradle wrapper
|
||||||
|
|
||||||
|
Generate `gradlew` / `gradlew.bat` and `gradle/wrapper/gradle-wrapper.properties` (Gradle 8.x).
|
||||||
|
This ensures reproducible builds without a local Gradle installation.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Step 3 — Source layout
|
||||||
|
|
||||||
|
Create the standard Gatling + Gradle directory structure:
|
||||||
|
|
||||||
|
```
|
||||||
|
src/
|
||||||
|
gatling/
|
||||||
|
scala/
|
||||||
|
simulations/ ← concrete simulation classes
|
||||||
|
base/ ← BaseSimulation.scala (shared protocol + auth)
|
||||||
|
resources/
|
||||||
|
gatling.conf ← timeout / connection overrides
|
||||||
|
data/ ← CSV feeders (added per test as needed)
|
||||||
|
bodies/ ← request body templates (added per test as needed)
|
||||||
|
```
|
||||||
|
|
||||||
|
Update `.idea/Gatlin.iml` source roots to include `src/gatling/scala`.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Step 4 — `BaseSimulation.scala`
|
||||||
|
|
||||||
|
`src/gatling/scala/base/BaseSimulation.scala`:
|
||||||
|
|
||||||
|
- Reads `target.baseUrl` from `sys.props` (set by Gradle from `-PbaseUrl`)
|
||||||
|
- Reads `gatling.authToken` from `sys.props` (set by Gradle from `-PauthToken` or env `GATLING_AUTH_TOKEN`)
|
||||||
|
- Defines a shared `HttpProtocolBuilder`:
|
||||||
|
- base URL
|
||||||
|
- `Authorization: Bearer <token>` header on every request
|
||||||
|
- `Accept: application/json`
|
||||||
|
- connection keep-alive
|
||||||
|
- Abstract class — concrete simulations extend it and inherit the protocol
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Step 5 — `SmokeTestSimulation.scala`
|
||||||
|
|
||||||
|
`src/gatling/scala/simulations/SmokeTestSimulation.scala`:
|
||||||
|
|
||||||
|
- Extends `BaseSimulation`
|
||||||
|
- Single virtual user, one `GET /healthz` request
|
||||||
|
- Asserts: HTTP 200, response time < 2 000 ms
|
||||||
|
- Purpose: verify end-to-end connectivity and auth before writing heavier tests
|
||||||
|
|
||||||
|
This serves as the reference example for future simulations.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Step 6 — `gatling.conf`
|
||||||
|
|
||||||
|
`src/gatling/resources/gatling.conf`:
|
||||||
|
|
||||||
|
```
|
||||||
|
gatling {
|
||||||
|
http {
|
||||||
|
enableGA = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Keeps telemetry off. Other defaults (timeouts, max connections) are left to Gatling's built-in values and can be overridden per-simulation in code.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Step 7 — `.gitignore` updates
|
||||||
|
|
||||||
|
Add to `.gitignore`:
|
||||||
|
```
|
||||||
|
build/
|
||||||
|
.gradle/
|
||||||
|
results/
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Step 8 — `README.md` update
|
||||||
|
|
||||||
|
Document:
|
||||||
|
1. Prerequisites (Gradle wrapper handles everything — no local installs needed beyond a JVM)
|
||||||
|
2. How to run: `./gradlew gatlingRun -PbaseUrl=... -PauthToken=...`
|
||||||
|
3. How to add a new simulation (extend `BaseSimulation`, place in `simulations/`)
|
||||||
|
4. Where reports are generated (`build/reports/gatling/`)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## File Checklist
|
||||||
|
|
||||||
|
| File | Action |
|
||||||
|
|---|---|
|
||||||
|
| `settings.gradle` | Create |
|
||||||
|
| `build.gradle` | Create |
|
||||||
|
| `gradle/wrapper/gradle-wrapper.properties` | Generate |
|
||||||
|
| `gradlew` / `gradlew.bat` | Generate |
|
||||||
|
| `src/gatling/scala/base/BaseSimulation.scala` | Create |
|
||||||
|
| `src/gatling/scala/simulations/SmokeTestSimulation.scala` | Create |
|
||||||
|
| `src/gatling/resources/gatling.conf` | Create |
|
||||||
|
| `.gitignore` | Update |
|
||||||
|
| `README.md` | Update |
|
||||||
|
| `.idea/Gatlin.iml` | Update source roots |
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
org.gradle.configuration-cache=true
|
||||||
Vendored
BIN
Binary file not shown.
+7
@@ -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
|
||||||
@@ -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
@@ -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
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
rootProject.name = 'gatlin'
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
gatling {
|
||||||
|
http {
|
||||||
|
# Disable Google Analytics telemetry
|
||||||
|
enableGA = false
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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)
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user