Skip to content

Commit 9ee083b

Browse files
Merge pull request #17 from delirius325/0.0.3
0.0.3
2 parents 72046f8 + c7a1f8f commit 9ee083b

File tree

15 files changed

+199
-262
lines changed

15 files changed

+199
-262
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
language: java
22
jdk:
3-
- oraclejdk8
3+
- oraclejdk13

CHANGELOG.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
## Version 0.0.3
2+
3+
* Fixed #7
4+
* `GET /api/threads` now correctly returns the thread groups' information
5+
* Fixed #15
6+
* TravisCI was giving an error since the `openjdk8` agent is no longer available. Now using `openjdk13` as it's the java version used to develop the plugin.
7+
* Fixed #10
8+
* Completely reworked the `GET /api/test/summary` endpoint, most computations now use the `Calculator` class from the JMeter core.
9+
* The `*.properties` files are now correctly included in the `pom.xml`, text is now correctly shown in JMeter
10+
* Fixed #13 and #14
11+
* Side-fixes of the whole refactoring that was done in 0.0.3
12+
113
## Version 0.0.2
214

315
* Changed web server to Jetty + JAX-RS (from webbit-server + webbit-rest)
@@ -13,7 +25,6 @@
1325

1426

1527
Note: All endpoints require the test to be running to be consumed.
16-
1728
## Version 0.0.1
1829

1930
* Temporary API documentation in README

README.md

Lines changed: 39 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# JMeter Live Changes Config
22

33
## Overview
4-
This plugin, which is still in an early development stage __(v 0.0.2)__, allows the user to communicate with a RESTful API to change JMeter tests to change values such as:
4+
This plugin, which is still in an early development stage __(v 0.0.3)__, allows the user to communicate with a RESTful API to change JMeter tests to change values such as:
55

66
* Throughput
77
* Number of active threads
@@ -43,8 +43,10 @@ Here are some scenarios where this kind of tool becomes very handy:
4343
As of right now, I am aware of a few limitations;
4444

4545
### Issues
46-
* Everything that's not checked on the roadmap is not working.
47-
* The `GET /api/threads AND /api/threads/{name}` endpoint seem to be returning 0 active threads (will be fixed in 0.0.3)
46+
* When stopping the test, the API seems to cache sample results. They should be emptied. (#)
47+
48+
++ Everything that's not checked on the roadmap is not working.
49+
4850

4951
### Limitations
5052
* The `Live Changes Config` __must__ be declared at the root of your `Test Plan`
@@ -118,10 +120,10 @@ __Request__ example:
118120
__Response__ example :
119121
```json
120122
{
121-
"startTime": 0,
122-
"runningTime": 0,
123-
"totalActiveThreads": 0,
124-
"totalThreads": 0
123+
"totalThreads": 10,
124+
"startTime": 1590694152358,
125+
"runningTime": 6,
126+
"totalActiveThreads": 10
125127
}
126128
```
127129

@@ -143,43 +145,39 @@ __Response__ example :
143145
```json
144146
[
145147
{
146-
"testSample": {
147-
"averageLatency": 75,
148-
"averageResponseTime": 797,
149-
"minResponseTime": 0,
150-
"maxResponseTime": 417,
151-
"hitsPerSecond": 3,
152-
"sentBytesPerSecond": 0,
153-
"totalErrors": 0,
154-
"errorPercentage": 0,
155-
"receivedBytesPerSecond": 352,
156-
"timeRunning": 4055,
157-
"90thPercentile": 349,
158-
"totalSamples": 12,
159-
"totalBytes": 1368,
160-
"averageBytes": 114,
161-
"totalSentBytes": 0,
162-
"standardDeviation": -554
148+
"Google": {
149+
"averageLatency": "160",
150+
"averageResponseTime": "341",
151+
"minResponseTime": "194",
152+
"maxResponseTime": "865",
153+
"hitsPerSecond": "1.03",
154+
"sentBytesPerSecond": "233.54",
155+
"totalErrors": "0",
156+
"errorPercentage": "0",
157+
"receivedBytesPerSecond": "14690.83",
158+
"90thPercentile": "477",
159+
"totalSamples": "36",
160+
"totalBytes": "511799",
161+
"averageBytes": "14216.64",
162+
"standardDeviation": "156.37"
163163
}
164164
},
165165
{
166-
"testSample - 2": {
167-
"averageLatency": 98,
168-
"averageResponseTime": 955,
169-
"minResponseTime": 0,
170-
"maxResponseTime": 450,
171-
"hitsPerSecond": 3,
172-
"sentBytesPerSecond": 0,
173-
"totalErrors": 0,
174-
"errorPercentage": 0,
175-
"receivedBytesPerSecond": 369,
176-
"timeRunning": 4055,
177-
"90thPercentile": 393,
178-
"totalSamples": 13,
179-
"totalBytes": 1482,
180-
"averageBytes": 114,
181-
"totalSentBytes": 0,
182-
"standardDeviation": -708
166+
"Yahoo": {
167+
"averageLatency": "178",
168+
"averageResponseTime": "947",
169+
"minResponseTime": "492",
170+
"maxResponseTime": "6239",
171+
"hitsPerSecond": "1.2",
172+
"sentBytesPerSecond": "404.12",
173+
"totalErrors": "0",
174+
"errorPercentage": "0",
175+
"receivedBytesPerSecond": "172374.09",
176+
"90thPercentile": "1422",
177+
"totalSamples": "42",
178+
"totalBytes": "6055157",
179+
"averageBytes": "144170.4",
180+
"standardDeviation": "896.6"
183181
}
184182
}
185183
]

pom.xml

Lines changed: 36 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>io.github.delirius325</groupId>
55
<artifactId>jmeter.config.livechanges</artifactId>
6-
<version>0.0.2</version>
6+
<version>0.0.3</version>
77
<packaging>jar</packaging>
88

9-
<name>jmeter.backendlistener.livechanges</name>
9+
<name>jmeter.config.livechanges</name>
1010
<description>This plugin serves as a channel to expose a REST API to change a JMeter Test Plan live while it's being executed.</description>
11-
<url>https://github.com/delirius325/jmeter-livechanges-backend-listener</url>
11+
<url>https://github.com/delirius325/jmeter-live-changes-config</url>
1212

1313
<licenses>
1414
<license>
@@ -19,7 +19,7 @@
1919
</licenses>
2020

2121
<scm>
22-
<url>https://github.com/delirius325/jmeter-livechanges-backend-listener.git</url>
22+
<url>https://github.com/delirius325/jmeter-live-changes-config.git</url>
2323
</scm>
2424

2525
<developers>
@@ -34,19 +34,19 @@
3434

3535
<properties>
3636
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
37-
<maven.compiler.source>1.8</maven.compiler.source>
38-
<maven.compiler.target>1.8</maven.compiler.target>
39-
<java.version>1.8</java.version>
37+
<maven.compiler.source>1.9</maven.compiler.source>
38+
<maven.compiler.target>1.9</maven.compiler.target>
39+
<java.version>1.9</java.version>
4040
<junit.version>4.12</junit.version>
4141
<junit.jupiter.version>5.0.0</junit.jupiter.version>
4242
<junit.vintage.version>${junit.version}.0</junit.vintage.version>
4343
<junit.jupiter.version>5.0.0</junit.jupiter.version>
4444
<junit.platform.version>1.0.0</junit.platform.version>
45-
<org.apache.jmeter.version>4.0</org.apache.jmeter.version>
46-
<org.apache.commons>3.7</org.apache.commons>
45+
<org.apache.jmeter.version>5.3</org.apache.jmeter.version>
46+
<org.apache.commons>3.10</org.apache.commons>
4747
<slf4jVersion>1.7.25</slf4jVersion>
48-
<jerseyVersion>2.28</jerseyVersion>
49-
<jettyVersion>[9.4.11.v20180605,)</jettyVersion>
48+
<jerseyVersion>2.31</jerseyVersion>
49+
<jettyVersion>[9.4.29.v20200521,)</jettyVersion>
5050
</properties>
5151
<dependencies>
5252
<dependency>
@@ -64,6 +64,11 @@
6464
<artifactId>jetty-servlet</artifactId>
6565
<version>${jettyVersion}</version>
6666
</dependency>
67+
<dependency>
68+
<groupId>org.eclipse.jetty</groupId>
69+
<artifactId>jetty-util</artifactId>
70+
<version>${jettyVersion}</version>
71+
</dependency>
6772
<dependency>
6873
<groupId>org.glassfish.jersey.core</groupId>
6974
<artifactId>jersey-server</artifactId>
@@ -155,6 +160,11 @@
155160
<version>${junit.vintage.version}</version>
156161
<scope>test</scope>
157162
</dependency>
163+
<dependency>
164+
<groupId>org.latencyutils</groupId>
165+
<artifactId>LatencyUtils</artifactId>
166+
<version>2.0.3</version>
167+
</dependency>
158168
</dependencies>
159169
<distributionManagement>
160170
<snapshotRepository>
@@ -196,6 +206,14 @@
196206
</profile>
197207
</profiles>
198208
<build>
209+
<resources>
210+
<resource>
211+
<directory>src/main/java</directory>
212+
<includes>
213+
<include>**/*.properties</include>
214+
</includes>
215+
</resource>
216+
</resources>
199217
<plugins>
200218
<plugin>
201219
<groupId>org.apache.maven.plugins</groupId>
@@ -232,13 +250,17 @@
232250
<plugin>
233251
<groupId>org.apache.maven.plugins</groupId>
234252
<artifactId>maven-javadoc-plugin</artifactId>
235-
<version>2.9.1</version>
253+
<version>2.10.4</version>
236254
<executions>
237255
<execution>
238256
<id>attach-javadocs</id>
239257
<goals>
240258
<goal>jar</goal>
241259
</goals>
260+
<configuration> <!-- add this to disable checking -->
261+
<additionalparam>-Xdoclint:none</additionalparam>
262+
<detectJavaApiLink>false</detectJavaApiLink>
263+
</configuration>
242264
</execution>
243265
</executions>
244266
</plugin>
@@ -263,8 +285,8 @@
263285
<artifactId>maven-compiler-plugin</artifactId>
264286
<version>3.7.0</version>
265287
<configuration>
266-
<source>1.8</source>
267-
<target>1.8</target>
288+
<source>1.9</source>
289+
<target>1.9</target>
268290
</configuration>
269291
</plugin>
270292
<plugin>

src/main/java/io/github/delirius325/jmeter/config/livechanges/LiveChanges.java

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
import java.io.File;
2323
import java.io.IOException;
24+
import java.util.HashSet;
2425
import java.util.Properties;
2526

2627
/**
@@ -30,12 +31,16 @@ public class LiveChanges extends ConfigTestElement implements TestBean, LoopIter
3031
private static final String testPlanFile = String.format("%s/%s", FileServer.getFileServer().getBaseDir(), FileServer.getFileServer().getScriptName());
3132
private static final Logger logger = LoggerFactory.getLogger(LiveChanges.class);
3233

34+
// Class attributes
3335
private App app;
34-
private int httpServerPort;
35-
private int calculationRate;
36+
private Integer httpServerPort;
37+
38+
// Static Attributes - available to other classes
39+
private static int staticCalcRate;
3640
private static int activeThreads;
3741
private static JMeterVariables jMeterVariables;
3842
private static Properties jMeterProperties;
43+
private static HashSet<ThreadGroup> testThreadGroups = new HashSet<>();
3944
private static ThreadGroup activeThreadGroup = new ThreadGroup();
4045
private static boolean stopTest;
4146
private static HashTree testPlanTree;
@@ -63,7 +68,7 @@ public void testEnded() {
6368
try {
6469
this.finalizeTest();
6570
} catch (Exception e) {
66-
logger.error("LiveChanges API was unable to gracefully shutdown. More info into JMeter's console.");
71+
logger.error("LiveChanges API was unable to gracefully shutdown. More info in JMeter's console.");
6772
}
6873
}
6974

@@ -76,24 +81,27 @@ public void testEnded(String host) {
7681
try {
7782
this.finalizeTest();
7883
} catch (Exception e) {
79-
logger.error("LiveChanges API was unable to gracefully shutdown. More info into JMeter's console.");
84+
logger.error("LiveChanges API was unable to gracefully shutdown. More info in JMeter's console.");
8085
}
8186
}
8287

8388
/**
8489
* Method that is executed upon every thread iteration of the JMeter script
90+
* This plugin works specifically because of this method that acts as an non-blocking event loop
8591
* @param event LoopIterationEvent
8692
*/
8793
@Override
8894
public void iterationStart(LoopIterationEvent event) {
8995
if(event.getIteration() == 1) {
9096
jMeterEngine = JMeterContextService.getContext().getEngine();
9197
}
98+
9299
ThreadGroup threadGroup = (ThreadGroup) JMeterContextService.getContext().getThreadGroup();
93100
JMeterVariables vars = JMeterContextService.getContext().getVariables();
94101
Properties props = JMeterContextService.getContext().getProperties();
95102
String tmp = JMeterContextService.getContext().getThread().getThreadName();
96103
String threadName = tmp.substring(0, tmp.lastIndexOf("-"));
104+
this.getTestThreadGroups().add(threadGroup);
97105

98106
if(stopTest) {
99107
jMeterEngine.askThreadsToStop();
@@ -180,7 +188,7 @@ private void startServer() {
180188
this.app = new App(this.httpServerPort);
181189
this.app.start();
182190
} catch (IOException e) {
183-
logger.error("An error occured when loading the test plan tree. View JMeter's console for more information.");
191+
logger.error("LiveChanges was unable to load the test plan tree. More info in JMeter's console.");
184192
e.printStackTrace();
185193
}
186194
}
@@ -193,7 +201,7 @@ private void finalizeTest() {
193201
this.app.stop();
194202
logger.info("LiveChanges API was successfully stopped.");
195203
} catch (Exception e) {
196-
logger.error("Unable to correctly shutdown Jetty server", e);
204+
logger.error("LiveChanges was unable to correctly shutdown Jetty server. More info in JMeter's console", e);
197205
}
198206
}
199207

@@ -206,12 +214,6 @@ public int getHttpServerPort() {
206214
public void setHttpServerPort(int port) {
207215
this.httpServerPort = port;
208216
}
209-
public int getCalculationRate() {
210-
return calculationRate;
211-
}
212-
public void setCalculationRate(int rate) {
213-
this.calculationRate = rate;
214-
}
215217
public static int getActiveThreads() {
216218
return activeThreads;
217219
}
@@ -226,4 +228,9 @@ public static int getActiveThreads() {
226228
public static void setjMeterVariables(JMeterVariables vars) { jMeterVariables = vars; }
227229
public static Properties getjMeterProperties() { return jMeterProperties; }
228230
public static HashTree getTestPlanTree() { return testPlanTree; }
231+
public static HashSet<ThreadGroup> getTestThreadGroups() { return testThreadGroups; }
232+
public static void setTestThreadGroups(HashSet<ThreadGroup> threadGroupHashSet) { LiveChanges.testThreadGroups = threadGroupHashSet; }
233+
public static int getStaticCalcRate() { return staticCalcRate; }
234+
public static void setStaticCalcRate(int staticCalcRate) { LiveChanges.staticCalcRate = staticCalcRate; }
235+
229236
}
Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,21 @@
11
package io.github.delirius325.jmeter.config.livechanges;
22

33
import org.apache.jmeter.testbeans.BeanInfoSupport;
4+
45
import java.beans.PropertyDescriptor;
56

67
public class LiveChangesBeanInfo extends BeanInfoSupport {
78
private static final String PORT = "httpServerPort";
8-
private static final String CALCULATION_RATE = "calculationRate";
99

1010
public LiveChangesBeanInfo() {
1111
super(LiveChanges.class);
1212

13-
createPropertyGroup("live_changes", new String[] {
14-
PORT,
15-
CALCULATION_RATE
13+
createPropertyGroup("livechanges", new String[] {
14+
PORT
1615
});
1716

18-
PropertyDescriptor port = property(PORT);
19-
port.setValue(DEFAULT, 7566);
20-
21-
PropertyDescriptor calculationRate = property(CALCULATION_RATE);
22-
calculationRate.setValue(DEFAULT, 10);
17+
PropertyDescriptor p = property(PORT);
18+
p.setValue(NOT_UNDEFINED, Boolean.TRUE);
19+
p.setValue(DEFAULT, 7566);
2320
}
2421
}

0 commit comments

Comments
 (0)