Skip to content

Commit 505d6e1

Browse files
mderevyankoaqaMikhail.Derevyanko
andauthored
Mvnrepository support (#45)
* Added the maven publish task in the Gradle build.gradle, package renaming to inherit groupId, fix of the warnings. * Fixed static code analysis warnings and java docs. * Updated deployment. Co-authored-by: Mikhail.Derevyanko <[email protected]>
1 parent 1263061 commit 505d6e1

15 files changed

+207
-63
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@
55
.settings/
66
.classpath
77
.idea
8+
secret-key.gpg
9+
gradle.properties

README.md

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,28 @@
11
# JMeter InfluxDB v2.0 listener plugin
2+
<img src="https://badges.frapsoft.com/os/v3/open-source.svg?v=103" width="300">
3+
4+
<p align="left">
5+
<img src="https://img.shields.io/github/issues/mderevyankoaqa/jmeter-influxdb2-listener-plugin?style=plastic&color=white">
6+
<img src="https://img.shields.io/github/forks/mderevyankoaqa/jmeter-influxdb2-listener-plugin?style=plastic">
7+
<img src="https://img.shields.io/github/stars/mderevyankoaqa/jmeter-influxdb2-listener-plugin?style=plastic&color=gold">
8+
<img src="https://img.shields.io/github/license/mderevyankoaqa/jmeter-influxdb2-listener-plugin?style=plastic">
9+
<img src="https://img.shields.io/github/repo-size/mderevyankoaqa/jmeter-influxdb2-listener-plugin?style=plastic">
10+
<img src="https://img.shields.io/github/issues/detail/age/mderevyankoaqa/jmeter-influxdb2-listener-plugin/1?style=plastic&color=purple">
11+
<img src="https://img.shields.io/github/commit-activity/m/mderevyankoaqa/jmeter-influxdb2-listener-plugin?style=plastic&color=red">
12+
<img src="https://img.shields.io/github/contributors/mderevyankoaqa/jmeter-influxdb2-listener-plugin?style=plastic">
13+
<img src="https://img.shields.io/github/last-commit/mderevyankoaqa/jmeter-influxdb2-listener-plugin?style=plastic">
14+
<img src="https://badgen.net/github/closed-issues/mderevyankoaqa/jmeter-influxdb2-listener-plugin">
15+
</p>
16+
17+
<h3>
18+
<details>
19+
<summary>Support my Ukrainian Family
20+
</summary>
21+
<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=H8L62WL5HVD32">
22+
<img src="https://raw.githubusercontent.com/stefan-niedermann/paypal-donate-button/master/paypal-donate-button.png" alt="Donate with PayPal" />
23+
</a>
24+
</details>
25+
</h3>
226

327
## Description
428
The goal of the project is to make a quite similar online dashboard in the same way as JMeter generates. Supported the latest InfluxDB v2.0 and created appropriate dashboard ("Flux" language has been used to create the queries - now there are a lot fo capacities to build amazing charts, tables with a lot of math function).
@@ -22,13 +46,18 @@ Counter will be refreshed at least you have 4 fails. This is protection to avoid
2246
Pleas monitor the elapsed time of the data importing (see logs) to avoid issues with requests sending from JMeter.
2347
Pay attention on "Sending metrics performance tuning" chapter, see below.
2448

49+
50+
2551
## Compatibility
2652
The supported versions:
2753
* Java 11 - make sure that you have it (its minimum version).
2854
* InfluxDB v2.0, see release notes: https://docs.influxdata.com/influxdb/v2.0/reference/release-notes/influxdb/ (1.8 is not supported)
2955
* JMeter 5.4.3 only.
3056
* The current board and plugin were tested on Grafana 8.2.3 and InfluxDB 2.0.9, JAVA 15.
3157

58+
## Maven Support
59+
Please see the latest release here https://s01.oss.sonatype.org/content/repositories/releases/io/github/mderevyankoaqa/jmeter-plugin-influxdb2-listener/maven-metadata.xml
60+
3261
## Deployment
3362
* Put '`jmeter-plugin-influxdb2-listener-<version>.jar`' file from [Releases](https://github.com/mderevyankoaqa/jmeter-influxdb2-listener-plugin/releases) to `~<JmeterPath<\lib\ext`;
3463

@@ -40,10 +69,22 @@ Note: "fatJar" gradle task should be used to create the package for the JMeter.
4069

4170
![](img/deploy2.png)
4271

43-
* Select from the dropdown item with the name '`org.md.jmeter.influxdb2.visualizer.JMeterInfluxDBBackendListenerClient`'.
72+
* Select from the dropdown item with the name '`io.github.mderevyankoaqa.influxdb2.visualizer.JMeterInfluxDBBackendListenerClient`'.
4473

4574
![](img/deploy3.png)
4675

76+
## Upgrade
77+
* Close JMeter if its started.
78+
* Remove old jar.
79+
* Put '`jmeter-plugin-influxdb2-listener-<version>.jar`' file from [Releases](https://github.com/mderevyankoaqa/jmeter-influxdb2-listener-plugin/releases) to `~<JmeterPath<\lib\ext`;
80+
* Run JMeter again and got Listener.
81+
* Select from the dropdown item with the name '`io.github.mderevyankoaqa.influxdb2.visualizer.JMeterInfluxDBBackendListenerClient`'.
82+
![](img/deploy3.png)
83+
* Click 'Clear all' button
84+
85+
![](img/deploy6.png)
86+
* Set right settings (update all properties).
87+
4788
## InfluxDB configuration
4889
* Create Bucket to store the further testing results.
4990

build.gradle

Lines changed: 81 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
plugins {
22
id 'com.github.johnrengelman.shadow' version "7.1.2"
33
id 'java'
4+
id 'java-library'
45
id 'project-report'
6+
id 'maven-publish'
57
id 'idea'
8+
id 'signing'
9+
}
10+
11+
java {
12+
withJavadocJar()
13+
withSourcesJar()
614
}
715

816
repositories {
@@ -14,8 +22,9 @@ repositories {
1422
}
1523

1624
sourceCompatibility = 11
17-
version = '1.6'
18-
def title = 'JMeterInfluxDBListener'
25+
group = 'io.github.mderevyankoaqa'
26+
version = '2.0'
27+
def title = 'JMeterInfluxDB2Listener'
1928
def archiveName = 'jmeter-plugin-influxdb2-listener'
2029

2130

@@ -38,7 +47,6 @@ def archiveName = 'jmeter-plugin-influxdb2-listener'
3847
implementation group: 'com.influxdb', name: 'influxdb-client-java', version: '6.1.0'
3948
implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.12.0'
4049

41-
4250
components {
4351
withModule("org.apache.jmeter:ApacheJMeter_core", JMeterRule)
4452
withModule("org.apache.jmeter:ApacheJMeter_java", JMeterRule)
@@ -53,7 +61,7 @@ jar {
5361
manifest {
5462
attributes 'Implementation-Title': title,
5563
'Implementation-Version': archiveVersion,
56-
'Main-Class': 'org.md.jmeter.influxdb.visualizer.JMeterInfluxDBBackendListenerClient'
64+
'Main-Class': 'io.github.mderevyankoaqa.influxdb2.visualizer.JMeterInfluxDBBackendListenerClient'
5765
}
5866
}
5967

@@ -63,3 +71,72 @@ shadowJar {
6371
inheritFrom project.tasks.jar.manifest
6472
}
6573
}
74+
75+
publishing {
76+
publications {
77+
mavenJava(MavenPublication) {
78+
groupId = 'io.github.mderevyankoaqa'
79+
artifactId = archiveName
80+
version = version
81+
82+
from components.java
83+
versionMapping {
84+
usage('java-api') {
85+
fromResolutionOf('runtimeClasspath')
86+
}
87+
usage('java-runtime') {
88+
fromResolutionResult()
89+
}
90+
}
91+
pom {
92+
name = archiveName
93+
description = 'Influx DB v2.0 listener plugin for Apache JMeter. Provides the possibility to see the online dashboard (aggregation table, errors, the response body of failures).'
94+
url = 'https://github.com/mderevyankoaqa/jmeter-influxdb2-listener-plugin'
95+
96+
licenses {
97+
license {
98+
name = 'The Apache License, Version 2.0'
99+
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
100+
}
101+
}
102+
developers {
103+
developer {
104+
id = 'mderevyanko'
105+
name = 'Mike Derevianko'
106+
107+
}
108+
}
109+
scm {
110+
connection = 'scm:git:git:github.com/mderevyankoaqa/jmeter-influxdb2-listener-plugin.git'
111+
developerConnection = 'scm:git:ssh://github.com/mderevyankoaqa/jmeter-influxdb2-listener-plugin.git'
112+
url = 'https://github.com/mderevyankoaqa/jmeter-influxdb2-listener-plugin'
113+
}
114+
}
115+
}
116+
}
117+
118+
119+
repositories {
120+
maven {
121+
name = "OSSRH"
122+
123+
url = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
124+
125+
credentials {
126+
username = project.properties["ossrhUsername"]
127+
password = project.properties["ossrhPassword"]
128+
}
129+
}
130+
}
131+
}
132+
133+
signing {
134+
sign publishing.publications.mavenJava
135+
}
136+
137+
138+
javadoc {
139+
if(JavaVersion.current().isJava9Compatible()) {
140+
options.addBooleanOption('html5', true)
141+
}
142+
}

img/deploy3.png

-15.8 KB
Loading

img/deploy6.png

5.27 KB
Loading

src/main/java/org/md/jmeter/influxdb2/visualizer/InfluxDatabaseBackendListenerClient.java renamed to src/main/java/io/github/mderevyankoaqa/influxdb2/visualizer/InfluxDatabaseBackendListenerClient.java

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,28 @@
1-
package org.md.jmeter.influxdb2.visualizer;
1+
package io.github.mderevyankoaqa.influxdb2.visualizer;
22

3+
import java.security.SecureRandom;
4+
import java.time.LocalDate;
35
import java.util.*;
4-
import java.util.concurrent.Executors;
5-
import java.util.concurrent.ScheduledThreadPoolExecutor;
6-
import java.util.concurrent.TimeUnit;
6+
import java.util.concurrent.*;
77

88
import com.influxdb.client.domain.WritePrecision;
99
import com.influxdb.client.write.Point;
10-
import org.md.jmeter.influxdb2.visualizer.influxdb.client.InfluxDatabaseClient;
11-
import org.md.jmeter.influxdb2.visualizer.config.InfluxDBConfig;
12-
import org.md.jmeter.influxdb2.visualizer.config.TestStartEndMeasurement;
13-
import org.md.jmeter.influxdb2.visualizer.config.VirtualUsersMeasurement;
10+
import io.github.mderevyankoaqa.influxdb2.visualizer.influxdb.client.InfluxDatabaseClient;
11+
import io.github.mderevyankoaqa.influxdb2.visualizer.config.InfluxDBConfig;
12+
import io.github.mderevyankoaqa.influxdb2.visualizer.config.TestStartEndMeasurement;
13+
import io.github.mderevyankoaqa.influxdb2.visualizer.config.VirtualUsersMeasurement;
1414
import org.apache.jmeter.config.Arguments;
1515
import org.apache.jmeter.samplers.SampleResult;
1616
import org.apache.jmeter.threads.JMeterContextService;
1717
import org.apache.jmeter.threads.JMeterContextService.ThreadCounts;
1818
import org.apache.jmeter.visualizers.backend.AbstractBackendListenerClient;
1919
import org.apache.jmeter.visualizers.backend.BackendListenerContext;
2020

21-
import org.md.jmeter.influxdb2.visualizer.result.SampleResultPointContext;
22-
import org.md.jmeter.influxdb2.visualizer.result.SampleResultPointProvider;
21+
import io.github.mderevyankoaqa.influxdb2.visualizer.result.SampleResultPointContext;
22+
import io.github.mderevyankoaqa.influxdb2.visualizer.result.SampleResultPointProvider;
2323
import org.slf4j.Logger;
2424
import org.slf4j.LoggerFactory;
2525

26-
import static org.md.jmeter.influxdb2.visualizer.influxdb.client.InfluxDatabaseClient.getInstance;
27-
2826

2927
/**
3028
* Backend listener that writes JMeter metrics to influxDB directly.
@@ -92,18 +90,22 @@ public class InfluxDatabaseBackendListenerClient extends AbstractBackendListener
9290
/**
9391
* Random number generator.
9492
*/
95-
private Random randomNumberGenerator;
93+
private SecureRandom randomNumberGenerator;
9694

9795
/**
9896
* Indicates whether to record Sub samples.
9997
*/
10098
private boolean recordSubSamples;
10199

102-
100+
/**
101+
* The Influx DB Config.
102+
*/
103103
private InfluxDBConfig influxDBConfig;
104104

105105
private Timer timer;
106106

107+
private ScheduledFuture<?> scheduledFuture;
108+
107109
/**
108110
* Processes sampler results.
109111
*/
@@ -135,7 +137,7 @@ public void handleSampleResults(List<SampleResult> sampleResults, BackendListene
135137
var sampleResultPointProvider = new SampleResultPointProvider(sampleResultContext);
136138

137139
Point resultPoint = sampleResultPointProvider.getPoint();
138-
getInstance(this.influxDBConfig, LOGGER).collectData(resultPoint);
140+
InfluxDatabaseClient.getInstance(this.influxDBConfig, LOGGER).collectData(resultPoint);
139141

140142
}
141143
}
@@ -167,7 +169,7 @@ public Arguments getDefaultParameters() {
167169
public void setupTest(BackendListenerContext context) {
168170
this.testName = context.getParameter(KEY_TEST_NAME, "Test");
169171
this.runId = context.getParameter(KEY_RUN_ID, "R001"); //Will be used to compare performance of R001, R002, etc of 'Test'
170-
this.randomNumberGenerator = new Random();
172+
this.randomNumberGenerator = new SecureRandom ();
171173
this.nodeName = context.getParameter(KEY_NODE_NAME, "Test-Node");
172174

173175
this.setupInfluxClient(context);
@@ -179,13 +181,13 @@ public void setupTest(BackendListenerContext context) {
179181
.addTag(TestStartEndMeasurement.Tags.TEST_NAME, this.testName)
180182
.addField(TestStartEndMeasurement.Fields.PLACEHOLDER, "1");
181183

182-
getInstance(influxDBConfig, LOGGER).collectData(setupPoint);
184+
InfluxDatabaseClient.getInstance(influxDBConfig, LOGGER).collectData(setupPoint);
183185

184186
this.parseSamplers(context);
185187
this.scheduler = (ScheduledThreadPoolExecutor) Executors.newScheduledThreadPool(2);
186188
this.scheduler.setRemoveOnCancelPolicy(true);
187189

188-
this.scheduler.scheduleAtFixedRate(this, 1, 1, TimeUnit.SECONDS);
190+
this.scheduledFuture = this.scheduler.scheduleAtFixedRate(this, 1, 1, TimeUnit.SECONDS);
189191

190192
// Indicates whether to write sub sample records to the database
191193
this.recordSubSamples = Boolean.parseBoolean(context.getParameter(KEY_RECORD_SUB_SAMPLES, "false"));
@@ -195,8 +197,10 @@ public void setupTest(BackendListenerContext context) {
195197
public void teardownTest(BackendListenerContext context) throws Exception {
196198
LOGGER.info("Shutting down influxDB scheduler...");
197199

198-
200+
// Stop importing data by timer.
199201
this.timer.cancel();
202+
203+
this.scheduledFuture.cancel(false);
200204
this.scheduler.shutdown();
201205

202206
this.addVirtualUsersMetrics(0, 0, 0, 0, JMeterContextService.getThreadCounts().finishedThreads);
@@ -208,16 +212,18 @@ public void teardownTest(BackendListenerContext context) throws Exception {
208212
.addTag(TestStartEndMeasurement.Tags.TEST_NAME, this.testName)
209213
.addField(TestStartEndMeasurement.Fields.PLACEHOLDER, "1");
210214

211-
getInstance(this.influxDBConfig, LOGGER).collectData(teardownPoint);
215+
InfluxDatabaseClient.getInstance(this.influxDBConfig, LOGGER).collectData(teardownPoint);
212216

213217
try {
214-
this.scheduler.awaitTermination(30, TimeUnit.SECONDS);
215218
LOGGER.info("influxDB scheduler terminated!");
219+
if(!this.scheduler.awaitTermination(30, TimeUnit.SECONDS)) {
220+
LOGGER.info("Threads didn't finish in 30 seconds!");
221+
}
216222
} catch (InterruptedException e) {
217223
LOGGER.error("Error waiting for end of scheduler " + e);
218224
}
219225

220-
getInstance(influxDBConfig, LOGGER).close();
226+
InfluxDatabaseClient.getInstance(influxDBConfig, LOGGER).close();
221227
this.samplersToFilter.clear();
222228
super.teardownTest(context);
223229
}
@@ -245,7 +251,7 @@ private void setupInfluxClient(BackendListenerContext context) {
245251
this.influxDBConfig = new InfluxDBConfig(context);
246252

247253

248-
getInstance(this.influxDBConfig, LOGGER).setupInfluxClient();
254+
InfluxDatabaseClient.getInstance(this.influxDBConfig, LOGGER).setupInfluxClient();
249255

250256
this.importDataByTimer(this.influxDBConfig, LOGGER);
251257

@@ -287,7 +293,7 @@ private void addVirtualUsersMetrics(int minActiveThreads, int meanActiveThreads,
287293
.addTag(VirtualUsersMeasurement.Tags.TEST_NAME, this.testName)
288294
.addTag(VirtualUsersMeasurement.Tags.RUN_ID, this.runId);
289295

290-
getInstance(this.influxDBConfig, LOGGER).collectData(virtualUsersMetricsPoint);
296+
InfluxDatabaseClient.getInstance(this.influxDBConfig, LOGGER).collectData(virtualUsersMetricsPoint);
291297
}
292298

293299
/**
@@ -309,7 +315,7 @@ public void importDataByTimer(InfluxDBConfig conf, Logger logger) {
309315
@Override
310316
public void run() {
311317

312-
LOGGER.debug("Running the timer: " + new java.util.Date());
318+
LOGGER.debug("Running the timer: " + LocalDate.now());
313319
InfluxDatabaseClient.getInstance(conf, logger).importData();
314320

315321
}

src/main/java/org/md/jmeter/influxdb2/visualizer/config/ArgsValidator.java renamed to src/main/java/io/github/mderevyankoaqa/influxdb2/visualizer/config/ArgsValidator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.md.jmeter.influxdb2.visualizer.config;
1+
package io.github.mderevyankoaqa.influxdb2.visualizer.config;
22

33
/**
44
* Arguments validation.

0 commit comments

Comments
 (0)