Skip to content

Commit 385e3f0

Browse files
Add example to run test with distributed engine using docker-compose
1 parent 9d19526 commit 385e3f0

File tree

8 files changed

+108
-0
lines changed

8 files changed

+108
-0
lines changed

.github/fix-docs-version.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ update_file_versions() {
1616
update_file_versions ${VERSION} README.md
1717
update_file_versions ${VERSION} docs/index.md
1818
update_file_versions ${VERSION} docs/guide/README.md
19+
update_file_versions ${VERSION} docs/guide/distributed/test/pom.xml
1920

2021
git add README.md docs/index.md docs/guide/README.md
2122
git config --local user.email "$(git log --format='%ae' HEAD^!)"

docs/guide/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,10 @@ To be able to run the test you require the `rmi_keystore.jks` file in working di
417417
In general, prefer using BlazeMeter or OctoPerf options which avoid all the setup and maintenance costs of the infrastructure required by JMeter remote testing, in addition to additional useful features (like reporting capabilities).
418418
:::
419419

420+
::: tip
421+
[Here](../../docs/guide/distributed) is an example project using `docker-compose` that starts a jmeter server/slave and executes a test with it. If you want to do a similar setup generate your own keystore and properly tune RMI remote server in server/slave.
422+
:::
423+
420424
Check [DistributedJmeterEngine](../../jmeter-java-dsl/src/main/java/us/abstracta/jmeter/javadsl/core/engines/DistributedJmeterEngine.java) and [JMeter documentation](http://jmeter.apache.org/usermanual/remote-test.html) for proper setup and additional options.
421425

422426
## Advanced threads configuration
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
version: '3'
2+
services:
3+
test:
4+
image: maven:3.8
5+
working_dir: /usr/src/test
6+
volumes:
7+
- ./test:/usr/src/test
8+
- ./rmi_keystore.jks:/usr/src/test/rmi_keystore.jks
9+
- ~/.m2:/root/.m2
10+
command: mvn clean test
11+
server:
12+
build: jmeter
13+
volumes:
14+
- ./rmi_keystore.jks:/opt/jmeter/rmi_keystore.jks
15+
command: jmeter-server -Dserver.rmi.localport=2020 -Djava.rmi.server.hostname=server
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM eclipse-temurin:8
2+
3+
ENV JMETER_VERSION=5.5
4+
ENV JMETER_HOME=/opt/jmeter
5+
ENV JMETER_TGZ_PATH=/tmp/jmeter.tgz
6+
7+
WORKDIR ${JMETER_HOME}
8+
9+
RUN curl -L -s -o ${JMETER_TGZ_PATH} https://archive.apache.org/dist/jmeter/binaries/apache-jmeter-${JMETER_VERSION}.tgz \
10+
&& tar -xzf ${JMETER_TGZ_PATH} \
11+
&& mv apache-jmeter-${JMETER_VERSION}/* . \
12+
&& rm -r apache-jmeter-${JMETER_VERSION} \
13+
&& rm ${JMETER_TGZ_PATH}
14+
15+
ENV PATH $PATH:$JMETER_HOME/bin
2.53 KB
Binary file not shown.
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<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+
7+
<groupId>us.abstracta.jmeter</groupId>
8+
<artifactId>sample-distributed-test</artifactId>
9+
<version>0.1-SNAPSHOT</version>
10+
11+
<properties>
12+
<!-- using Java 11 instead of 17 since is the latest LTS JMeter has support for -->
13+
<maven.compiler.release>11</maven.compiler.release>
14+
</properties>
15+
16+
<build>
17+
<pluginManagement>
18+
<plugins>
19+
<plugin>
20+
<groupId>org.apache.maven.plugins</groupId>
21+
<artifactId>maven-compiler-plugin</artifactId>
22+
<version>3.10.1</version>
23+
</plugin>
24+
<plugin>
25+
<groupId>org.apache.maven.plugins</groupId>
26+
<artifactId>maven-surefire-plugin</artifactId>
27+
<version>3.0.0-M7</version>
28+
</plugin>
29+
</plugins>
30+
</pluginManagement>
31+
</build>
32+
33+
<dependencies>
34+
<dependency>
35+
<groupId>us.abstracta.jmeter</groupId>
36+
<artifactId>jmeter-java-dsl</artifactId>
37+
<version>0.63</version>
38+
<scope>test</scope>
39+
</dependency>
40+
<dependency>
41+
<groupId>org.junit.jupiter</groupId>
42+
<artifactId>junit-jupiter-engine</artifactId>
43+
<version>5.8.2</version>
44+
<scope>test</scope>
45+
</dependency>
46+
<dependency>
47+
<groupId>org.assertj</groupId>
48+
<artifactId>assertj-core</artifactId>
49+
<version>3.22.0</version>
50+
<scope>test</scope>
51+
</dependency>
52+
</dependencies>
53+
</project>

docs/guide/distributed/test/rmi_keystore.jks

Whitespace-only changes.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import static org.assertj.core.api.Assertions.assertThat;
2+
import static us.abstracta.jmeter.javadsl.JmeterDsl.*;
3+
4+
import org.junit.jupiter.api.Test;
5+
import us.abstracta.jmeter.javadsl.core.TestPlanStats;
6+
import us.abstracta.jmeter.javadsl.core.engines.DistributedJmeterEngine;
7+
8+
public class PerformanceTest {
9+
10+
@Test
11+
public void shouldGetExpectedCountWhenRunTestInRemoteEngine() throws Exception {
12+
TestPlanStats stats = testPlan(
13+
threadGroup(1, 1,
14+
httpSampler("https://myservice")
15+
)
16+
).runIn(new DistributedJmeterEngine("server:1099"));
17+
assertThat(stats.overall().samplesCount()).isEqualTo(1);
18+
}
19+
20+
}

0 commit comments

Comments
 (0)