Skip to content

Commit bb3e595

Browse files
matteoroxismaibin
authored andcommitted
Add Jenkinsfile & update gatling version (eugenp#8198)
1 parent 148e421 commit bb3e595

File tree

6 files changed

+140
-140
lines changed

6 files changed

+140
-140
lines changed

testing-modules/gatling/Jenkinsfile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
pipeline {
2+
agent any
3+
stages {
4+
stage("Build Maven") {
5+
steps {
6+
sh 'mvn -B clean package'
7+
}
8+
}
9+
stage("Run Gatling") {
10+
steps {
11+
sh 'mvn gatling:test'
12+
}
13+
post {
14+
always {
15+
gatlingArchive()
16+
}
17+
}
18+
}
19+
}
20+
}

testing-modules/gatling/pom.xml

Lines changed: 107 additions & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -1,136 +1,120 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<project xmlns="http://maven.apache.org/POM/4.0.0"
3-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5-
<modelVersion>4.0.0</modelVersion>
6-
<groupId>org.baeldung</groupId>
7-
<artifactId>gatling</artifactId>
8-
<version>1.0-SNAPSHOT</version>
9-
<name>gatling</name>
10-
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
<groupId>org.baeldung</groupId>
7+
<artifactId>gatling</artifactId>
8+
<version>1.0-SNAPSHOT</version>
9+
<name>gatling</name>
10+
1111
<parent>
1212
<groupId>com.baeldung</groupId>
1313
<artifactId>parent-modules</artifactId>
1414
<version>1.0.0-SNAPSHOT</version>
1515
<relativePath>../../</relativePath>
1616
</parent>
1717

18-
<dependencyManagement>
19-
<dependencies>
20-
<dependency>
21-
<groupId>io.gatling</groupId>
22-
<artifactId>gatling-app</artifactId>
23-
<version>${gatling.version}</version>
24-
</dependency>
25-
<dependency>
26-
<groupId>io.gatling</groupId>
27-
<artifactId>gatling-recorder</artifactId>
28-
<version>${gatling.version}</version>
29-
</dependency>
30-
<dependency>
31-
<groupId>io.gatling.highcharts</groupId>
32-
<artifactId>gatling-charts-highcharts</artifactId>
33-
<version>${gatling.version}</version>
34-
</dependency>
35-
<dependency>
36-
<groupId>org.scala-lang</groupId>
37-
<artifactId>scala-library</artifactId>
38-
<version>${scala.version}</version>
39-
</dependency>
40-
</dependencies>
41-
</dependencyManagement>
42-
43-
<dependencies>
44-
<dependency>
45-
<groupId>io.gatling.highcharts</groupId>
46-
<artifactId>gatling-charts-highcharts</artifactId>
47-
</dependency>
48-
<dependency>
49-
<groupId>io.gatling</groupId>
50-
<artifactId>gatling-app</artifactId>
51-
</dependency>
52-
<dependency>
53-
<groupId>io.gatling</groupId>
54-
<artifactId>gatling-recorder</artifactId>
55-
</dependency>
56-
<dependency>
57-
<groupId>org.scala-lang</groupId>
58-
<artifactId>scala-library</artifactId>
59-
</dependency>
60-
</dependencies>
6118

62-
<build>
63-
<testSourceDirectory>src/test/scala</testSourceDirectory>
64-
<pluginManagement>
65-
<plugins>
66-
<plugin>
67-
<groupId>net.alchim31.maven</groupId>
68-
<artifactId>scala-maven-plugin</artifactId>
69-
<version>${scala-maven-plugin.version}</version>
70-
</plugin>
71-
</plugins>
72-
</pluginManagement>
73-
<plugins>
74-
<plugin>
75-
<groupId>net.alchim31.maven</groupId>
76-
<artifactId>scala-maven-plugin</artifactId>
77-
<executions>
78-
<execution>
79-
<goals>
80-
<goal>testCompile</goal>
81-
</goals>
82-
<configuration>
83-
<args>
84-
<!--<arg>-Ybackend:GenBCode</arg> -->
85-
<arg>-Ydelambdafy:method</arg>
86-
<arg>-target:jvm-1.8</arg>
87-
<arg>-deprecation</arg>
88-
<arg>-feature</arg>
89-
<arg>-unchecked</arg>
90-
<arg>-language:implicitConversions</arg>
91-
<arg>-language:postfixOps</arg>
92-
</args>
93-
</configuration>
94-
</execution>
95-
</executions>
96-
</plugin>
97-
</plugins>
98-
</build>
99-
100-
<profiles>
101-
<profile>
102-
<id>simulation</id>
103-
<build>
104-
<plugins>
105-
<plugin>
106-
<groupId>io.gatling</groupId>
107-
<artifactId>gatling-maven-plugin</artifactId>
108-
<version>${gatling-maven-plugin.version}</version>
109-
<executions>
110-
<execution>
111-
<phase>test</phase>
112-
<goals>
113-
<goal>execute</goal>
114-
</goals>
115-
<configuration>
116-
<disableCompiler>true</disableCompiler>
117-
</configuration>
118-
</execution>
119-
</executions>
120-
</plugin>
121-
</plugins>
122-
</build>
123-
</profile>
124-
</profiles>
19+
<dependencyManagement>
20+
<dependencies>
21+
<dependency>
22+
<groupId>io.gatling</groupId>
23+
<artifactId>gatling-app</artifactId>
24+
<version>${gatling.version}</version>
25+
</dependency>
26+
<dependency>
27+
<groupId>io.gatling</groupId>
28+
<artifactId>gatling-recorder</artifactId>
29+
<version>${gatling.version}</version>
30+
</dependency>
31+
<dependency>
32+
<groupId>io.gatling.highcharts</groupId>
33+
<artifactId>gatling-charts-highcharts</artifactId>
34+
<version>${gatling.version}</version>
35+
</dependency>
36+
<dependency>
37+
<groupId>org.scala-lang</groupId>
38+
<artifactId>scala-library</artifactId>
39+
<version>${scala.version}</version>
40+
</dependency>
41+
</dependencies>
42+
</dependencyManagement>
43+
44+
<dependencies>
45+
<dependency>
46+
<groupId>io.gatling.highcharts</groupId>
47+
<artifactId>gatling-charts-highcharts</artifactId>
48+
</dependency>
49+
<dependency>
50+
<groupId>io.gatling</groupId>
51+
<artifactId>gatling-app</artifactId>
52+
</dependency>
53+
<dependency>
54+
<groupId>io.gatling</groupId>
55+
<artifactId>gatling-recorder</artifactId>
56+
</dependency>
57+
<dependency>
58+
<groupId>org.scala-lang</groupId>
59+
<artifactId>scala-library</artifactId>
60+
</dependency>
61+
</dependencies>
62+
63+
<build>
64+
<testSourceDirectory>src/test/scala</testSourceDirectory>
65+
<pluginManagement>
66+
<plugins>
67+
<plugin>
68+
<groupId>net.alchim31.maven</groupId>
69+
<artifactId>scala-maven-plugin</artifactId>
70+
<version>${scala-maven-plugin.version}</version>
71+
</plugin>
72+
</plugins>
73+
</pluginManagement>
74+
<plugins>
75+
<plugin>
76+
<groupId>net.alchim31.maven</groupId>
77+
<artifactId>scala-maven-plugin</artifactId>
78+
<executions>
79+
<execution>
80+
<goals>
81+
<goal>testCompile</goal>
82+
</goals>
83+
<configuration>
84+
<args>
85+
<!--<arg>-Ybackend:GenBCode</arg> -->
86+
<arg>-Ydelambdafy:method</arg>
87+
<arg>-target:jvm-1.8</arg>
88+
<arg>-deprecation</arg>
89+
<arg>-feature</arg>
90+
<arg>-unchecked</arg>
91+
<arg>-language:implicitConversions</arg>
92+
<arg>-language:postfixOps</arg>
93+
</args>
94+
</configuration>
95+
</execution>
96+
</executions>
97+
</plugin>
98+
<plugin>
99+
<groupId>io.gatling</groupId>
100+
<artifactId>gatling-maven-plugin</artifactId>
101+
<version>${gatling-maven-plugin.version}</version>
102+
<configuration>
103+
<simulationClass>org.baeldung.RecordedSimulation</simulationClass>
104+
</configuration>
105+
</plugin>
106+
</plugins>
107+
</build>
108+
125109

126-
<properties>
127-
<maven.compiler.source>1.8</maven.compiler.source>
128-
<maven.compiler.target>1.8</maven.compiler.target>
129-
<encoding>UTF-8</encoding>
130-
<scala.version>2.12.6</scala.version> <!--2.11.12 --> <!--2.12.6 -->
131-
<gatling.version>2.3.1</gatling.version> <!--2.2.5 --> <!--2.3.1 -->
132-
<scala-maven-plugin.version>3.2.2</scala-maven-plugin.version> <!--3.2.2 --> <!--3.3.2 -->
133-
<gatling-maven-plugin.version>2.2.4</gatling-maven-plugin.version> <!--2.2.1 --> <!--2.2.4 -->
134-
</properties>
110+
<properties>
111+
<maven.compiler.source>1.8</maven.compiler.source>
112+
<maven.compiler.target>1.8</maven.compiler.target>
113+
<encoding>UTF-8</encoding>
114+
<scala.version>2.12.6</scala.version> <!--2.11.12 --> <!--2.12.6 -->
115+
<gatling.version>3.3.1</gatling.version> <!--2.2.5 --> <!--2.3.1 -->
116+
<scala-maven-plugin.version>4.3.0</scala-maven-plugin.version> <!--3.2.2 --> <!--3.3.2 -->
117+
<gatling-maven-plugin.version>3.0.4</gatling-maven-plugin.version> <!--2.2.1 --> <!--2.2.4 -->
118+
</properties>
135119

136120
</project>

testing-modules/gatling/src/test/scala/Engine.scala

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@ import io.gatling.core.config.GatlingPropertiesBuilder
33

44
object Engine extends App {
55

6-
val props = new GatlingPropertiesBuilder
7-
props.dataDirectory(IDEPathHelper.dataDirectory.toString)
8-
props.resultsDirectory(IDEPathHelper.resultsDirectory.toString)
9-
props.bodiesDirectory(IDEPathHelper.bodiesDirectory.toString)
10-
props.binariesDirectory(IDEPathHelper.mavenBinariesDirectory.toString)
6+
val props = new GatlingPropertiesBuilder()
7+
.resourcesDirectory(IDEPathHelper.resourcesDirectory.toString)
8+
.resultsDirectory(IDEPathHelper.resultsDirectory.toString)
9+
.binariesDirectory(IDEPathHelper.mavenBinariesDirectory.toString)
1110

12-
Gatling.fromMap(props.build)
11+
Gatling.fromMap(props.build)
1312
}

testing-modules/gatling/src/test/scala/IDEPathHelper.scala

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,16 @@ import io.gatling.commons.util.PathHelper._
44

55
object IDEPathHelper {
66

7-
val gatlingConfUrl: Path = getClass.getClassLoader.getResource("gatling.conf").toURI
7+
val gatlingConfUrl: Path = getClass.getClassLoader.getResource("gatling.conf")
88
val projectRootDir = gatlingConfUrl.ancestor(3)
99

1010
val mavenSourcesDirectory = projectRootDir / "src" / "test" / "scala"
1111
val mavenResourcesDirectory = projectRootDir / "src" / "test" / "resources"
1212
val mavenTargetDirectory = projectRootDir / "target"
1313
val mavenBinariesDirectory = mavenTargetDirectory / "test-classes"
1414

15-
val dataDirectory = mavenResourcesDirectory / "data"
16-
val bodiesDirectory = mavenResourcesDirectory / "bodies"
17-
18-
val recorderOutputDirectory = mavenSourcesDirectory
15+
val resourcesDirectory = mavenResourcesDirectory
16+
val recorderSimulationsDirectory = mavenSourcesDirectory
1917
val resultsDirectory = mavenTargetDirectory / "gatling"
20-
2118
val recorderConfigFile = mavenResourcesDirectory / "recorder.conf"
2219
}

testing-modules/gatling/src/test/scala/Recorder.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ import io.gatling.recorder.config.RecorderPropertiesBuilder
33

44
object Recorder extends App {
55

6-
val props = new RecorderPropertiesBuilder
7-
props.simulationOutputFolder(IDEPathHelper.recorderOutputDirectory.toString)
8-
props.simulationPackage("org.baeldung")
9-
props.bodiesFolder(IDEPathHelper.bodiesDirectory.toString)
6+
val props = new RecorderPropertiesBuilder()
7+
.simulationsFolder(IDEPathHelper.recorderSimulationsDirectory.toString)
8+
.simulationPackage("org.baeldung")
9+
.resourcesFolder(IDEPathHelper.resourcesDirectory.toString)
1010

1111
GatlingRecorder.fromMap(props.build, Some(IDEPathHelper.recorderConfigFile))
1212
}

testing-modules/gatling/src/test/scala/org/baeldung/RecordedSimulation.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import io.gatling.jdbc.Predef._
99
class RecordedSimulation extends Simulation {
1010

1111
val httpProtocol = http
12-
.baseURL("http://computer-database.gatling.io")
12+
.baseUrl("http://computer-database.gatling.io")
1313
.inferHtmlResources(BlackList(""".*\.css""", """.*\.js""", """.*\.ico"""), WhiteList())
1414
.acceptHeader("text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8")
1515
.acceptEncodingHeader("gzip, deflate")

0 commit comments

Comments
 (0)