Skip to content

Commit 9d59cd3

Browse files
Merge branch 'master' into master
2 parents 6d62a5a + decf811 commit 9d59cd3

File tree

6 files changed

+100
-73
lines changed

6 files changed

+100
-73
lines changed

.github/FUNDING.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# These are supported funding model platforms
2+
3+
github: [delirius325]
4+
patreon: # Replace with a single Patreon username
5+
open_collective: # Replace with a single Open Collective username
6+
ko_fi: # Replace with a single Ko-fi username
7+
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8+
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9+
liberapay: # Replace with a single Liberapay username
10+
issuehunt: # Replace with a single IssueHunt username
11+
otechie: # Replace with a single Otechie username
12+
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']

.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+
- oraclejdk9

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ JMeter ElasticSearch Backend Listener is a JMeter plugin enabling you to send te
4646
* __quiet__ : Only sends the response time, bytes, and other metrics
4747
* __error__ : Only sends the failing samplers to the ElasticSearch engine (Along with their headers and body information).
4848
* Use either Kibana or Grafana to vizualize your results!
49-
* [Click here to get a sample Grafana dashboard!](https://github.com/delirius325/jmeter-elasticsearch-backend-listener/wiki/JMeter-Generic-Dashboard) - All you need to do is import it into Grafana and change de data source!
49+
* [Click here to get a sample Grafana dashboard!](https://github.com/delirius325/jmeter-elasticsearch-backend-listener/wiki/JMeter-Generic-Dashboard) - All you need to do is import it into Grafana and change the data source!
5050
* Continuous Integration support - [Build comparison!](https://github.com/delirius325/jmeter-elasticsearch-backend-listener/wiki/Continuous-Integration---Build-Comparison)
5151
* Send JMeter variables to ElasticSearch! [Refer to this for more info!](https://github.com/delirius325/jmeter-elasticsearch-backend-listener/wiki/Sending-JMeter-variables)
5252
* New AWS ES parameters introducted in 2.6.0 version which leverage Role based authentication to access Elastic Search managed hosting on AWS
@@ -56,7 +56,8 @@ JMeter ElasticSearch Backend Listener is a JMeter plugin enabling you to send te
5656
<dependency>
5757
<groupId>io.github.delirius325</groupId>
5858
<artifactId>jmeter.backendlistener.elasticsearch</artifactId>
59-
<version>2.6.7</version>
59+
<version>2.6.9</version>
60+
</dependency>
6061
```
6162

6263
## Contributing

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<modelVersion>4.0.0</modelVersion>
66
<groupId>io.github.delirius325</groupId>
77
<artifactId>jmeter.backendlistener.elasticsearch</artifactId>
8-
<version>2.6.7</version>
8+
<version>2.6.9</version>
99
<packaging>jar</packaging>
1010

1111
<name>jmeter.backendlistener.elasticsearch</name>

src/main/java/io/github/delirius325/jmeter/backendlistener/elasticsearch/ElasticSearchMetric.java

Lines changed: 49 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public class ElasticSearchMetric {
3232
private boolean allResHeaders;
3333

3434
public ElasticSearchMetric(SampleResult sr, String testMode, String timeStamp, int buildNumber,
35-
boolean parseReqHeaders, boolean parseResHeaders, Set<String> fields) {
35+
boolean parseReqHeaders, boolean parseResHeaders, Set<String> fields) {
3636
this.sampleResult = sr;
3737
this.esTestMode = testMode.trim();
3838
this.esTimestamp = timeStamp.trim();
@@ -45,9 +45,8 @@ public ElasticSearchMetric(SampleResult sr, String testMode, String timeStamp, i
4545

4646
/**
4747
* This method returns the current metric as a Map(String, Object) for the provided sampleResult
48-
*
49-
* @param context
50-
* BackendListenerContext
48+
*
49+
* @param context BackendListenerContext
5150
* @return a JSON Object as Map(String, Object)
5251
*/
5352
public Map<String, Object> getMetric(BackendListenerContext context) throws Exception {
@@ -74,27 +73,27 @@ public Map<String, Object> getMetric(BackendListenerContext context) throws Exce
7473
addFilteredJSON("TestStartTime", JMeterContextService.getTestStartTime());
7574
addFilteredJSON("SampleStartTime", sdf.format(new Date(this.sampleResult.getStartTime())));
7675
addFilteredJSON("SampleEndTime", sdf.format(new Date(this.sampleResult.getEndTime())));
77-
addFilteredJSON("Timestamp", sdf.format(new Date(this.sampleResult.getTimeStamp())));
76+
addFilteredJSON("Timestamp", this.sampleResult.getTimeStamp());
7877
addFilteredJSON("InjectorHostname", InetAddress.getLocalHost().getHostName());
7978

8079
// Add the details according to the mode that is set
8180
switch (this.esTestMode) {
82-
case "debug":
83-
addDetails();
84-
break;
85-
case "error":
86-
addDetails();
87-
break;
88-
case "info":
89-
if (!this.sampleResult.isSuccessful())
81+
case "debug":
82+
addDetails();
83+
break;
84+
case "error":
9085
addDetails();
91-
break;
92-
default:
93-
break;
86+
break;
87+
case "info":
88+
if (!this.sampleResult.isSuccessful())
89+
addDetails();
90+
break;
91+
default:
92+
break;
9493
}
9594

9695
addAssertions();
97-
addElapsedTime(sdf);
96+
addElapsedTime();
9897
addCustomFields(context);
9998
parseHeadersAsJsonProps(this.allReqHeaders, this.allResHeaders);
10099

@@ -103,7 +102,6 @@ public Map<String, Object> getMetric(BackendListenerContext context) throws Exce
103102

104103
/**
105104
* This method adds all the assertions for the current sampleResult
106-
*
107105
*/
108106
private void addAssertions() {
109107
AssertionResult[] assertionResults = this.sampleResult.getAssertionResults();
@@ -133,31 +131,27 @@ private void addAssertions() {
133131
* This method adds the ElapsedTime as a key:value pair in the JSON object. Also, depending on whether or not the
134132
* tests were launched from a CI tool (i.e Jenkins), it will add a hard-coded version of the ElapsedTime for results
135133
* comparison purposes
136-
*
137-
* @param sdf
138-
* SimpleDateFormat
139134
*/
140-
private void addElapsedTime(SimpleDateFormat sdf) {
135+
private void addElapsedTime() {
141136
Date elapsedTime;
142137

143138
if (this.ciBuildNumber != 0) {
144139
elapsedTime = getElapsedTime(true);
145140
addFilteredJSON("BuildNumber", this.ciBuildNumber);
146141

147142
if (elapsedTime != null)
148-
addFilteredJSON("ElapsedTimeComparison", sdf.format(elapsedTime));
143+
addFilteredJSON("ElapsedTimeComparison", elapsedTime.getTime());
149144
}
150145

151146
elapsedTime = getElapsedTime(false);
152147
if (elapsedTime != null)
153-
addFilteredJSON("ElapsedTime", sdf.format(elapsedTime));
148+
addFilteredJSON("ElapsedTime", elapsedTime.getTime());
154149
}
155150

156151
/**
157152
* Methods that add all custom fields added by the user in the Backend Listener's GUI panel
158153
*
159-
* @param context
160-
* BackendListenerContext
154+
* @param context BackendListenerContext
161155
*/
162156
private void addCustomFields(BackendListenerContext context) {
163157
Iterator<String> pluginParameters = context.getParameterNamesIterator();
@@ -180,7 +174,6 @@ private void addCustomFields(BackendListenerContext context) {
180174

181175
/**
182176
* Method that adds the request and response's body/headers
183-
*
184177
*/
185178
private void addDetails() {
186179
addFilteredJSON("RequestHeaders", this.sampleResult.getRequestHeaders());
@@ -195,52 +188,50 @@ private void addDetails() {
195188
* all headers into different ElasticSearch document properties by passing "true" This is a work-around the native
196189
* behaviour of JMeter where variables are not accessible within the backend listener.
197190
*
198-
* @param allReqHeaders
199-
* boolean to determine if the user wants to separate ALL request headers into different ES JSON
200-
* properties.
201-
* @param allResHeaders
202-
* boolean to determine if the user wants to separate ALL response headers into different ES JSON
203-
* properties.
204-
*
205-
* NOTE: This will be fixed as soon as a patch comes in for JMeter to change the behaviour.
191+
* @param allReqHeaders boolean to determine if the user wants to separate ALL request headers into different ES JSON
192+
* properties.
193+
* @param allResHeaders boolean to determine if the user wants to separate ALL response headers into different ES JSON
194+
* properties.
195+
* <p>
196+
* NOTE: This will be fixed as soon as a patch comes in for JMeter to change the behaviour.
206197
*/
207198
private void parseHeadersAsJsonProps(boolean allReqHeaders, boolean allResHeaders) {
208199
LinkedList<String[]> headersArrayList = new LinkedList<String[]>();
209-
210-
if (allReqHeaders) {
211-
headersArrayList.add(this.sampleResult.getRequestHeaders().split("\n"));
212-
}
213200

214-
if (allResHeaders) {
215-
headersArrayList.add(this.sampleResult.getResponseHeaders().split("\n"));
216-
}
217-
218-
if (!allReqHeaders && !allResHeaders) {
219-
headersArrayList.add(this.sampleResult.getRequestHeaders().split("\n"));
220-
headersArrayList.add(this.sampleResult.getResponseHeaders().split("\n"));
221-
}
201+
if (allReqHeaders) {
202+
headersArrayList.add(this.sampleResult.getRequestHeaders().split("\n"));
203+
}
204+
205+
if (allResHeaders) {
206+
headersArrayList.add(this.sampleResult.getResponseHeaders().split("\n"));
207+
}
208+
209+
if (!allReqHeaders && !allResHeaders) {
210+
headersArrayList.add(this.sampleResult.getRequestHeaders().split("\n"));
211+
headersArrayList.add(this.sampleResult.getResponseHeaders().split("\n"));
212+
}
222213

223-
for(String[] lines : headersArrayList) {
224-
for(int i=0; i < lines.length; i++) {
225-
String[] header = lines[i].split(":",2);
214+
for (String[] lines : headersArrayList) {
215+
for (int i = 0; i < lines.length; i++) {
216+
String[] header = lines[i].split(":", 2);
226217

227218
// if not all res/req headers and header contains special X-tag
228219
if (!allReqHeaders && !allResHeaders && header.length > 1) {
229220
if (header[0].startsWith("X-es-backend")) {
230221
this.json.put(header[0].replaceAll("X-es-backend-", "").trim(), header[1].trim());
231-
}
232-
}
233-
222+
}
223+
}
224+
234225
if ((allReqHeaders || allResHeaders) && header.length > 1) {
235-
this.json.put(header[0].trim(), header[1].trim());
236-
}
237-
}
226+
this.json.put(header[0].trim(), header[1].trim());
227+
}
228+
}
238229
}
239230
}
240231

241232
/**
242233
* Adds a given key-value pair to JSON if the key is contained in the field filter or in case of empty field filter
243-
*
234+
*
244235
* @param key
245236
* @param value
246237
*/
@@ -255,8 +246,7 @@ private void addFilteredJSON(String key, Object value) {
255246
* build comparison in Kibana. By doing this, the user is able to set the X-axis of his graph to this date and split
256247
* the series by build numbers. It allows him to overlap test results and see if there is regression or not.
257248
*
258-
* @param forBuildComparison
259-
* boolean to determine if there is CI (continuous integration) or not
249+
* @param forBuildComparison boolean to determine if there is CI (continuous integration) or not
260250
* @return The elapsed time in YYYY-MM-dd HH:mm:ss format
261251
*/
262252
public Date getElapsedTime(boolean forBuildComparison) {

src/main/java/io/github/delirius325/jmeter/backendlistener/elasticsearch/ElasticsearchBackendClient.java

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -169,17 +169,41 @@ private void convertParameterToSet(BackendListenerContext context, String parame
169169
* @param context
170170
*/
171171
private void setSSLConfiguration(BackendListenerContext context) {
172-
System.setProperty("javax.net.ssl.keyStore", context.getParameter(ES_SSL_KEYSTORE_PATH));
173-
System.setProperty("javax.net.ssl.keyStorePassword", context.getParameter(ES_SSL_KEYSTORE_PW));
174-
System.setProperty("javax.net.ssl.keyStoreType",
175-
FilenameUtils.getExtension(context.getParameter(ES_SSL_KEYSTORE_PATH)).equals("jks") ? "jks" : "pkcs12");
176-
//jks (.jks) or pkcs12 (.p12)
172+
String keyStorePath = context.getParameter(ES_SSL_KEYSTORE_PATH);
173+
if (!keyStorePath.equalsIgnoreCase("")) {
174+
logger.warn("KeyStore system properties overwritten by ES SSL configuration.");
175+
System.setProperty("javax.net.ssl.keyStore", keyStorePath);
176+
System.setProperty("javax.net.ssl.keyStorePassword", context.getParameter(ES_SSL_KEYSTORE_PW));
177+
switch (FilenameUtils.getExtension(keyStorePath)) {
178+
case "jks":
179+
System.setProperty("javax.net.ssl.keyStoreType", "jks");
180+
break;
181+
case "p12":
182+
System.setProperty("javax.net.ssl.keyStoreType", "pkcs12");
183+
break;
184+
default:
185+
System.setProperty("javax.net.ssl.keyStoreType", "");
186+
break;
187+
}
188+
}
177189

178-
System.setProperty("javax.net.ssl.trustStore", context.getParameter(ES_SSL_TRUSTSTORE_PATH));
179-
System.setProperty("javax.net.ssl.trustStorePassword", context.getParameter(ES_SSL_TRUSTSTORE_PW));
180-
System.setProperty("javax.net.ssl.trustStoreType",
181-
FilenameUtils.getExtension(context.getParameter(ES_SSL_TRUSTSTORE_PATH)).equals("jks") ? "jks"
182-
: "pkcs12");
190+
String trustStorePath = context.getParameter(ES_SSL_TRUSTSTORE_PATH);
191+
if (!trustStorePath.equalsIgnoreCase("")) {
192+
logger.warn("TrustStore system properties overwritten by ES SSL configuration.");
193+
System.setProperty("javax.net.ssl.trustStore", trustStorePath);
194+
System.setProperty("javax.net.ssl.trustStorePassword", context.getParameter(ES_SSL_TRUSTSTORE_PW));
195+
switch (FilenameUtils.getExtension(trustStorePath)) {
196+
case "jks":
197+
System.setProperty("javax.net.ssl.trustStoreType", "jks");
198+
break;
199+
case "p12":
200+
System.setProperty("javax.net.ssl.trustStoreType", "pkcs12");
201+
break;
202+
default:
203+
System.setProperty("javax.net.ssl.trustStoreType", "");
204+
break;
205+
}
206+
}
183207

184208
}
185209

0 commit comments

Comments
 (0)