A Gatling load test demo
This commit is contained in:
parent
ed72ff42e8
commit
ce7c395417
166
gatling-loadtest-demo/.cache-tests
Normal file
166
gatling-loadtest-demo/.cache-tests
Normal file
File diff suppressed because one or more lines are too long
32
gatling-loadtest-demo/.classpath
Normal file
32
gatling-loadtest-demo/.classpath
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<classpath>
|
||||||
|
<classpathentry kind="src" output="target/classes" path="src/main/java">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="optional" value="true"/>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry kind="src" output="target/test-classes" path="src/test/scala">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="optional" value="true"/>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry kind="con" path="org.scala-ide.sdt.launching.SCALA_CONTAINER"/>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry kind="output" path="target/classes"/>
|
||||||
|
</classpath>
|
24
gatling-loadtest-demo/.project
Normal file
24
gatling-loadtest-demo/.project
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>gatling-loadtest-demo</name>
|
||||||
|
<comment></comment>
|
||||||
|
<projects>
|
||||||
|
</projects>
|
||||||
|
<buildSpec>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.scala-ide.sdt.core.scalabuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
</buildSpec>
|
||||||
|
<natures>
|
||||||
|
<nature>org.scala-ide.sdt.core.scalanature</nature>
|
||||||
|
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||||
|
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||||
|
</natures>
|
||||||
|
</projectDescription>
|
113
gatling-loadtest-demo/pom.xml
Normal file
113
gatling-loadtest-demo/pom.xml
Normal file
@ -0,0 +1,113 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<groupId>org.baeldung</groupId>
|
||||||
|
<artifactId>gatling-loadtest-demo</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.source>1.8</maven.compiler.source>
|
||||||
|
<maven.compiler.target>1.8</maven.compiler.target>
|
||||||
|
<scala.version>2.11.7</scala.version>
|
||||||
|
<encoding>UTF-8</encoding>
|
||||||
|
|
||||||
|
<gatling.version>2.2.0</gatling.version>
|
||||||
|
|
||||||
|
<scala-maven-plugin.version>3.2.2</scala-maven-plugin.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencyManagement>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.gatling</groupId>
|
||||||
|
<artifactId>gatling-app</artifactId>
|
||||||
|
<version>${gatling.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.gatling</groupId>
|
||||||
|
<artifactId>gatling-recorder</artifactId>
|
||||||
|
<version>${gatling.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.gatling.highcharts</groupId>
|
||||||
|
<artifactId>gatling-charts-highcharts</artifactId>
|
||||||
|
<version>${gatling.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.scala-lang</groupId>
|
||||||
|
<artifactId>scala-library</artifactId>
|
||||||
|
<version>${scala.version}</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</dependencyManagement>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.gatling.highcharts</groupId>
|
||||||
|
<artifactId>gatling-charts-highcharts</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.gatling</groupId>
|
||||||
|
<artifactId>gatling-app</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.gatling</groupId>
|
||||||
|
<artifactId>gatling-recorder</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.scala-lang</groupId>
|
||||||
|
<artifactId>scala-library</artifactId>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<testSourceDirectory>src/test/scala</testSourceDirectory>
|
||||||
|
<pluginManagement>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>net.alchim31.maven</groupId>
|
||||||
|
<artifactId>scala-maven-plugin</artifactId>
|
||||||
|
<version>${scala-maven-plugin.version}</version>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</pluginManagement>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>net.alchim31.maven</groupId>
|
||||||
|
<artifactId>scala-maven-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<goals>
|
||||||
|
<goal>testCompile</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<args>
|
||||||
|
<arg>-Ybackend:GenBCode</arg>
|
||||||
|
<arg>-Ydelambdafy:method</arg>
|
||||||
|
<arg>-target:jvm-1.8</arg>
|
||||||
|
<arg>-deprecation</arg>
|
||||||
|
<arg>-feature</arg>
|
||||||
|
<arg>-unchecked</arg>
|
||||||
|
<arg>-language:implicitConversions</arg>
|
||||||
|
<arg>-language:postfixOps</arg>
|
||||||
|
</args>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
|
<plugin>
|
||||||
|
<groupId>io.gatling</groupId>
|
||||||
|
<artifactId>gatling-maven-plugin</artifactId>
|
||||||
|
<version>${gatling.version}</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>test</phase>
|
||||||
|
<goals><goal>execute</goal></goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
127
gatling-loadtest-demo/src/test/resources/gatling.conf
Normal file
127
gatling-loadtest-demo/src/test/resources/gatling.conf
Normal file
@ -0,0 +1,127 @@
|
|||||||
|
#########################
|
||||||
|
# Gatling Configuration #
|
||||||
|
#########################
|
||||||
|
|
||||||
|
# This file contains all the settings configurable for Gatling with their default values
|
||||||
|
|
||||||
|
gatling {
|
||||||
|
core {
|
||||||
|
#outputDirectoryBaseName = "" # The prefix for each simulation result folder (then suffixed by the report generation timestamp)
|
||||||
|
#runDescription = "" # The description for this simulation run, displayed in each report
|
||||||
|
#encoding = "utf-8" # Encoding to use throughout Gatling for file and string manipulation
|
||||||
|
#simulationClass = "" # The FQCN of the simulation to run (when used in conjunction with noReports, the simulation for which assertions will be validated)
|
||||||
|
#mute = false # When set to true, don't ask for simulation name nor run description (currently only used by Gatling SBT plugin)
|
||||||
|
#elFileBodiesCacheMaxCapacity = 200 # Cache size for request body EL templates, set to 0 to disable
|
||||||
|
#rawFileBodiesCacheMaxCapacity = 200 # Cache size for request body Raw templates, set to 0 to disable
|
||||||
|
#rawFileBodiesInMemoryMaxSize = 1000 # Below this limit, raw file bodies will be cached in memory
|
||||||
|
|
||||||
|
extract {
|
||||||
|
regex {
|
||||||
|
#cacheMaxCapacity = 200 # Cache size for the compiled regexes, set to 0 to disable caching
|
||||||
|
}
|
||||||
|
xpath {
|
||||||
|
#cacheMaxCapacity = 200 # Cache size for the compiled XPath queries, set to 0 to disable caching
|
||||||
|
}
|
||||||
|
jsonPath {
|
||||||
|
#cacheMaxCapacity = 200 # Cache size for the compiled jsonPath queries, set to 0 to disable caching
|
||||||
|
#preferJackson = false # When set to true, prefer Jackson over Boon for JSON-related operations
|
||||||
|
}
|
||||||
|
css {
|
||||||
|
#cacheMaxCapacity = 200 # Cache size for the compiled CSS selectors queries, set to 0 to disable caching
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
directory {
|
||||||
|
#data = user-files/data # Folder where user's data (e.g. files used by Feeders) is located
|
||||||
|
#bodies = user-files/bodies # Folder where bodies are located
|
||||||
|
#simulations = user-files/simulations # Folder where the bundle's simulations are located
|
||||||
|
#reportsOnly = "" # If set, name of report folder to look for in order to generate its report
|
||||||
|
#binaries = "" # If set, name of the folder where compiles classes are located: Defaults to GATLING_HOME/target.
|
||||||
|
#results = results # Name of the folder where all reports folder are located
|
||||||
|
}
|
||||||
|
}
|
||||||
|
charting {
|
||||||
|
#noReports = false # When set to true, don't generate HTML reports
|
||||||
|
#maxPlotPerSeries = 1000 # Number of points per graph in Gatling reports
|
||||||
|
#useGroupDurationMetric = false # Switch group timings from cumulated response time to group duration.
|
||||||
|
indicators {
|
||||||
|
#lowerBound = 800 # Lower bound for the requests' response time to track in the reports and the console summary
|
||||||
|
#higherBound = 1200 # Higher bound for the requests' response time to track in the reports and the console summary
|
||||||
|
#percentile1 = 50 # Value for the 1st percentile to track in the reports, the console summary and Graphite
|
||||||
|
#percentile2 = 75 # Value for the 2nd percentile to track in the reports, the console summary and Graphite
|
||||||
|
#percentile3 = 95 # Value for the 3rd percentile to track in the reports, the console summary and Graphite
|
||||||
|
#percentile4 = 99 # Value for the 4th percentile to track in the reports, the console summary and Graphite
|
||||||
|
}
|
||||||
|
}
|
||||||
|
http {
|
||||||
|
#fetchedCssCacheMaxCapacity = 200 # Cache size for CSS parsed content, set to 0 to disable
|
||||||
|
#fetchedHtmlCacheMaxCapacity = 200 # Cache size for HTML parsed content, set to 0 to disable
|
||||||
|
#perUserCacheMaxCapacity = 200 # Per virtual user cache size, set to 0 to disable
|
||||||
|
#warmUpUrl = "http://gatling.io" # The URL to use to warm-up the HTTP stack (blank means disabled)
|
||||||
|
#enableGA = true # Very light Google Analytics, please support
|
||||||
|
ssl {
|
||||||
|
keyStore {
|
||||||
|
#type = "" # Type of SSLContext's KeyManagers store
|
||||||
|
#file = "" # Location of SSLContext's KeyManagers store
|
||||||
|
#password = "" # Password for SSLContext's KeyManagers store
|
||||||
|
#algorithm = "" # Algorithm used SSLContext's KeyManagers store
|
||||||
|
}
|
||||||
|
trustStore {
|
||||||
|
#type = "" # Type of SSLContext's TrustManagers store
|
||||||
|
#file = "" # Location of SSLContext's TrustManagers store
|
||||||
|
#password = "" # Password for SSLContext's TrustManagers store
|
||||||
|
#algorithm = "" # Algorithm used by SSLContext's TrustManagers store
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ahc {
|
||||||
|
#keepAlive = true # Allow pooling HTTP connections (keep-alive header automatically added)
|
||||||
|
#connectTimeout = 60000 # Timeout when establishing a connection
|
||||||
|
#pooledConnectionIdleTimeout = 60000 # Timeout when a connection stays unused in the pool
|
||||||
|
#readTimeout = 60000 # Timeout when a used connection stays idle
|
||||||
|
#maxRetry = 2 # Number of times that a request should be tried again
|
||||||
|
#requestTimeout = 60000 # Timeout of the requests
|
||||||
|
#acceptAnyCertificate = true # When set to true, doesn't validate SSL certificates
|
||||||
|
#httpClientCodecMaxInitialLineLength = 4096 # Maximum length of the initial line of the response (e.g. "HTTP/1.0 200 OK")
|
||||||
|
#httpClientCodecMaxHeaderSize = 8192 # Maximum size, in bytes, of each request's headers
|
||||||
|
#httpClientCodecMaxChunkSize = 8192 # Maximum length of the content or each chunk
|
||||||
|
#webSocketMaxFrameSize = 10240000 # Maximum frame payload size
|
||||||
|
#sslEnabledProtocols = [TLSv1.2, TLSv1.1, TLSv1] # Array of enabled protocols for HTTPS, if empty use the JDK defaults
|
||||||
|
#sslEnabledCipherSuites = [] # Array of enabled cipher suites for HTTPS, if empty use the JDK defaults
|
||||||
|
#sslSessionCacheSize = 0 # SSLSession cache size, set to 0 to use JDK's default
|
||||||
|
#sslSessionTimeout = 0 # SSLSession timeout in seconds, set to 0 to use JDK's default (24h)
|
||||||
|
#useOpenSsl = false # if OpenSSL should be used instead of JSSE (requires tcnative jar)
|
||||||
|
#useNativeTransport = false # if native transport should be used instead of Java NIO (requires netty-transport-native-epoll, currently Linux only)
|
||||||
|
#usePooledMemory = true # if Gatling should use pooled memory
|
||||||
|
#tcpNoDelay = true
|
||||||
|
#soReuseAddress = false
|
||||||
|
#soLinger = -1
|
||||||
|
#soSndBuf = -1
|
||||||
|
#soRcvBuf = -1
|
||||||
|
}
|
||||||
|
dns {
|
||||||
|
#queryTimeout = 5000 # Timeout of each DNS query in millis
|
||||||
|
#maxQueriesPerResolve = 3 # Maximum allowed number of DNS queries for a given name resolution
|
||||||
|
}
|
||||||
|
}
|
||||||
|
data {
|
||||||
|
#writers = [console, file] # The list of DataWriters to which Gatling write simulation data (currently supported : console, file, graphite, jdbc)
|
||||||
|
console {
|
||||||
|
#light = false # When set to true, displays a light version without detailed request stats
|
||||||
|
}
|
||||||
|
file {
|
||||||
|
#bufferSize = 8192 # FileDataWriter's internal data buffer size, in bytes
|
||||||
|
}
|
||||||
|
leak {
|
||||||
|
#noActivityTimeout = 30 # Period, in seconds, for which Gatling may have no activity before considering a leak may be happening
|
||||||
|
}
|
||||||
|
graphite {
|
||||||
|
#light = false # only send the all* stats
|
||||||
|
#host = "localhost" # The host where the Carbon server is located
|
||||||
|
#port = 2003 # The port to which the Carbon server listens to (2003 is default for plaintext, 2004 is default for pickle)
|
||||||
|
#protocol = "tcp" # The protocol used to send data to Carbon (currently supported : "tcp", "udp")
|
||||||
|
#rootPathPrefix = "gatling" # The common prefix of all metrics sent to Graphite
|
||||||
|
#bufferSize = 8192 # GraphiteDataWriter's internal data buffer size, in bytes
|
||||||
|
#writeInterval = 1 # GraphiteDataWriter's write interval, in seconds
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
22
gatling-loadtest-demo/src/test/resources/logback.xml
Normal file
22
gatling-loadtest-demo/src/test/resources/logback.xml
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
<?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>
|
||||||
|
<immediateFlush>false</immediateFlush>
|
||||||
|
</encoder>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<!-- Uncomment for logging ALL HTTP request and responses -->
|
||||||
|
<!-- <logger name="io.gatling.http.ahc" level="TRACE" /> -->
|
||||||
|
<!-- <logger name="io.gatling.http.response" level="TRACE" /> -->
|
||||||
|
<!-- Uncomment for logging ONLY FAILED HTTP request and responses -->
|
||||||
|
<!-- <logger name="io.gatling.http.ahc" level="DEBUG" /> -->
|
||||||
|
<!-- <logger name="io.gatling.http.response" level="DEBUG" /> -->
|
||||||
|
|
||||||
|
<root level="WARN">
|
||||||
|
<appender-ref ref="CONSOLE" />
|
||||||
|
</root>
|
||||||
|
|
||||||
|
</configuration>
|
57
gatling-loadtest-demo/src/test/resources/recorder.conf
Normal file
57
gatling-loadtest-demo/src/test/resources/recorder.conf
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
recorder {
|
||||||
|
core {
|
||||||
|
className=RecordedSimulation
|
||||||
|
encoding=utf-8
|
||||||
|
harFilePath=""
|
||||||
|
headless=false
|
||||||
|
mode=Proxy
|
||||||
|
outputFolder="C:\\develop\\workspaces\\vjportalWorkspace\\gatling-loadtest-demo\\src\\test\\scala"
|
||||||
|
package="org.baeldung"
|
||||||
|
saveConfig=true
|
||||||
|
thresholdForPauseCreation=100
|
||||||
|
}
|
||||||
|
filters {
|
||||||
|
blacklist=[
|
||||||
|
".*\\.css",
|
||||||
|
".*\\.js",
|
||||||
|
".*\\.ico"
|
||||||
|
]
|
||||||
|
filterStrategy=BlacklistFirst
|
||||||
|
whitelist=[]
|
||||||
|
}
|
||||||
|
http {
|
||||||
|
automaticReferer=true
|
||||||
|
checkResponseBodies=false
|
||||||
|
followRedirect=true
|
||||||
|
inferHtmlResources=true
|
||||||
|
removeCacheHeaders=true
|
||||||
|
}
|
||||||
|
netty {
|
||||||
|
maxChunkSize=8192
|
||||||
|
maxContentLength=100000000
|
||||||
|
maxHeaderSize=20000
|
||||||
|
maxInitialLineLength=10000
|
||||||
|
}
|
||||||
|
proxy {
|
||||||
|
https {
|
||||||
|
certificateAuthority {
|
||||||
|
certificatePath=""
|
||||||
|
privateKeyPath=""
|
||||||
|
}
|
||||||
|
keyStore {
|
||||||
|
password=""
|
||||||
|
path=""
|
||||||
|
type=JKS
|
||||||
|
}
|
||||||
|
mode=SelfSignedCertificate
|
||||||
|
}
|
||||||
|
outgoing {
|
||||||
|
host=""
|
||||||
|
password=""
|
||||||
|
port=0
|
||||||
|
sslPort=0
|
||||||
|
username=""
|
||||||
|
}
|
||||||
|
port=8000
|
||||||
|
}
|
||||||
|
}
|
13
gatling-loadtest-demo/src/test/scala/Engine.scala
Normal file
13
gatling-loadtest-demo/src/test/scala/Engine.scala
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
import io.gatling.app.Gatling
|
||||||
|
import io.gatling.core.config.GatlingPropertiesBuilder
|
||||||
|
|
||||||
|
object Engine extends App {
|
||||||
|
|
||||||
|
val props = new GatlingPropertiesBuilder
|
||||||
|
props.dataDirectory(IDEPathHelper.dataDirectory.toString)
|
||||||
|
props.resultsDirectory(IDEPathHelper.resultsDirectory.toString)
|
||||||
|
props.bodiesDirectory(IDEPathHelper.bodiesDirectory.toString)
|
||||||
|
props.binariesDirectory(IDEPathHelper.mavenBinariesDirectory.toString)
|
||||||
|
|
||||||
|
Gatling.fromMap(props.build)
|
||||||
|
}
|
22
gatling-loadtest-demo/src/test/scala/IDEPathHelper.scala
Normal file
22
gatling-loadtest-demo/src/test/scala/IDEPathHelper.scala
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
import java.nio.file.Path
|
||||||
|
|
||||||
|
import io.gatling.commons.util.PathHelper._
|
||||||
|
|
||||||
|
object IDEPathHelper {
|
||||||
|
|
||||||
|
val gatlingConfUrl: Path = getClass.getClassLoader.getResource("gatling.conf").toURI
|
||||||
|
val projectRootDir = gatlingConfUrl.ancestor(3)
|
||||||
|
|
||||||
|
val mavenSourcesDirectory = projectRootDir / "src" / "test" / "scala"
|
||||||
|
val mavenResourcesDirectory = projectRootDir / "src" / "test" / "resources"
|
||||||
|
val mavenTargetDirectory = projectRootDir / "target"
|
||||||
|
val mavenBinariesDirectory = mavenTargetDirectory / "test-classes"
|
||||||
|
|
||||||
|
val dataDirectory = mavenResourcesDirectory / "data"
|
||||||
|
val bodiesDirectory = mavenResourcesDirectory / "bodies"
|
||||||
|
|
||||||
|
val recorderOutputDirectory = mavenSourcesDirectory
|
||||||
|
val resultsDirectory = mavenTargetDirectory / "gatling"
|
||||||
|
|
||||||
|
val recorderConfigFile = mavenResourcesDirectory / "recorder.conf"
|
||||||
|
}
|
12
gatling-loadtest-demo/src/test/scala/Recorder.scala
Normal file
12
gatling-loadtest-demo/src/test/scala/Recorder.scala
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import io.gatling.recorder.GatlingRecorder
|
||||||
|
import io.gatling.recorder.config.RecorderPropertiesBuilder
|
||||||
|
|
||||||
|
object Recorder extends App {
|
||||||
|
|
||||||
|
val props = new RecorderPropertiesBuilder
|
||||||
|
props.simulationOutputFolder(IDEPathHelper.recorderOutputDirectory.toString)
|
||||||
|
props.simulationPackage("org.baeldung")
|
||||||
|
props.bodiesFolder(IDEPathHelper.bodiesDirectory.toString)
|
||||||
|
|
||||||
|
GatlingRecorder.fromMap(props.build, Some(IDEPathHelper.recorderConfigFile))
|
||||||
|
}
|
@ -0,0 +1,46 @@
|
|||||||
|
package org.baeldung
|
||||||
|
|
||||||
|
import scala.concurrent.duration._
|
||||||
|
|
||||||
|
import io.gatling.core.Predef._
|
||||||
|
import io.gatling.http.Predef._
|
||||||
|
import io.gatling.jdbc.Predef._
|
||||||
|
|
||||||
|
class RecordedSimulation extends Simulation {
|
||||||
|
|
||||||
|
val httpProtocol = http
|
||||||
|
.baseURL("http://computer-database.gatling.io")
|
||||||
|
.inferHtmlResources(BlackList(""".*\.css""", """.*\.js""", """.*\.ico"""), WhiteList())
|
||||||
|
.acceptHeader("text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8")
|
||||||
|
.acceptEncodingHeader("gzip, deflate")
|
||||||
|
.acceptLanguageHeader("it-IT,it;q=0.8,en-US;q=0.5,en;q=0.3")
|
||||||
|
.userAgentHeader("Mozilla/5.0 (Windows NT 10.0; WOW64; rv:46.0) Gecko/20100101 Firefox/46.0")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
val scn = scenario("RecordedSimulation")
|
||||||
|
.exec(http("request_0")
|
||||||
|
.get("/"))
|
||||||
|
.pause(5)
|
||||||
|
.exec(http("request_1")
|
||||||
|
.get("/computers?f=amstrad"))
|
||||||
|
.pause(4)
|
||||||
|
.exec(http("request_2")
|
||||||
|
.get("/computers/412"))
|
||||||
|
.pause(2)
|
||||||
|
.exec(http("request_3")
|
||||||
|
.get("/"))
|
||||||
|
.pause(2)
|
||||||
|
.exec(http("request_4")
|
||||||
|
.get("/computers?p=1"))
|
||||||
|
.pause(1)
|
||||||
|
.exec(http("request_5")
|
||||||
|
.get("/computers?p=2"))
|
||||||
|
.pause(2)
|
||||||
|
.exec(http("request_6")
|
||||||
|
.get("/computers?p=3"))
|
||||||
|
|
||||||
|
setUp(scn.inject(atOnceUsers(1))).protocols(httpProtocol)
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user