Skip to content

Commit

Permalink
Fixed merge
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonygauthier committed Jun 1, 2018
2 parents b7513c9 + 17baadf commit 622170a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 129 deletions.
119 changes: 5 additions & 114 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ JMeter ElasticSearch Backend Listener is a JMeter plugin enabling you to send te
<dependency>
<groupId>io.github.delirius325</groupId>
<artifactId>jmeter.backendlistener.elasticsearch</artifactId>
<version>2.2.4</version>
<version>2.2.5</version>
</dependency>
```

Expand All @@ -31,119 +31,10 @@ Feel free to contribute by branching and making pull requests, or simply by sugg

## Screenshots
### Configuration
![screnshot1](https://image.ibb.co/kPMn2x/Screen_Shot_2018_03_21_at_9_58_25_AM.png "Screenshot of configuration")
![screnshot1](https://cdn-images-1.medium.com/max/2000/1*iVb7mIp2dPg7zE4Ph3PrGQ.png "Screenshot of configuration")

### Sample Grafana dashboard
![screnshot1](https://image.ibb.co/jW6LNx/Screen_Shot_2018_03_21_at_10_21_18_AM.png "Sample Grafana Dashboard")

## Sample ElasticSearch Index

```javascript
{
"template": "jmeter",
"mappings": {
"SampleResult": {
"properties": {
"AllThreads": {
"type": "long"
},
"Assertions": {
"properties": {
"Failure": {
"type": "boolean"
},
"FailureMessage": {
"type": "text",
"index": false
},
"Name": {
"type": "text",
"index": false
}
}
},
"BodySize": {
"type": "long"
},
"Bytes": {
"type": "long"
},
"ConnectTime": {
"type": "long",
"index": false
},
"ContentType": {
"type": "text",
"index": false
},
"DataType": {
"type": "text",
"index": false
},
"EndTime": {
"type": "date",
"format": "dateOptionalTime"
},
"ErrorCount": {
"type": "long"
},
"GrpThreads": {
"type": "long",
"index": false
},
"IdleTime": {
"type": "long"
},
"Latency": {
"type": "long"
},
"ResponseCode": {
"type": "text"
},
"ResponseMessage": {
"type": "text",
"index": false
},
"ResponseTime": {
"type": "long"
},
"SampleCount": {
"type": "long"
},
"SampleLabel": {
"type": "keyword"
},
"StartTime": {
"type": "date",
"format": "dateOptionalTime"
},
"Success": {
"type": "text",
"index": false
},
"ThreadName": {
"type": "keyword",
"index": false
},
"URL": {
"type": "keyword"
},
"Timestamp": {
"type": "date",
"format": "dateOptionalTime"
},
"NormalizedTimestamp": {
"type": "date",
"format": "dateOptionalTime",
"index": false
},
"BuildNumber": {
"type": "long"
},
"ElapsedTime": {
"type": "date"
}
}
}
}
}
```
### For more info
For more information, here's a little [documentation](https://github.com/delirius325/jmeter-elasticsearch-backend-listener/wiki).
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,18 @@ public Arguments getDefaultParameters() {
@Override
public void setupTest(BackendListenerContext context) throws Exception {
try {
String host = context.getParameter(ES_HOST);
this.filters = new LinkedList<String>();
int port = Integer.parseInt(context.getParameter(ES_PORT));
this.index = context.getParameter(ES_INDEX).toLowerCase();
this.bulkSize = Integer.parseInt(context.getParameter(ES_BULK_SIZE));
this.timeoutMs = JMeterUtils.getPropDefault(ES_TIMEOUT_MS, DEFAULT_TIMEOUT_MS);
this.buildNumber = (JMeterUtils.getProperty(ElasticsearchBackend.BUILD_NUMBER) != null && JMeterUtils.getProperty(ElasticsearchBackend.BUILD_NUMBER).trim() != "")
? Integer.parseInt(JMeterUtils.getProperty(ElasticsearchBackend.BUILD_NUMBER)) : 0;
String host = context.getParameter(ES_HOST);
int port = Integer.parseInt(context.getParameter(ES_PORT));

this.filters = new LinkedList<String>();
this.bulkRequestList = new LinkedList<String>();
this.index = context.getParameter(ES_INDEX).toLowerCase();
this.bulkSize = Integer.parseInt(context.getParameter(ES_BULK_SIZE));
this.timeoutMs = JMeterUtils.getPropDefault(ES_TIMEOUT_MS, DEFAULT_TIMEOUT_MS);
this.buildNumber = (JMeterUtils.getProperty(ElasticsearchBackend.BUILD_NUMBER) != null && JMeterUtils.getProperty(ElasticsearchBackend.BUILD_NUMBER).trim() != "") ? Integer.parseInt(JMeterUtils.getProperty(ElasticsearchBackend.BUILD_NUMBER)) : 0;
this.client = RestClient.builder(new HttpHost(context.getParameter(ES_HOST), port, context.getParameter(ES_SCHEME)))
.setRequestConfigCallback(requestConfigBuilder -> requestConfigBuilder.setConnectTimeout(5000)
.setSocketTimeout((int) timeoutMs))
.setSocketTimeout((int) timeoutMs))
.setFailureListener(new RestClient.FailureListener() {
@Override
public void onFailure(HttpHost host) {
Expand All @@ -86,7 +87,7 @@ public void onFailure(HttpHost host) {
})
.setMaxRetryTimeoutMillis(60000)
.build();
this.bulkRequestList = new LinkedList<String>();

String[] filterArray = (context.getParameter(ES_SAMPLE_FILTER).contains(";")) ? context.getParameter(ES_SAMPLE_FILTER).split(";") : new String[] {context.getParameter(ES_SAMPLE_FILTER)};
if(filterArray.length >= 1 && filterArray[0].trim() != "") {
for (String filter : filterArray) {
Expand Down Expand Up @@ -125,11 +126,8 @@ public void handleSampleResults(List<SampleResult> results, BackendListenerConte

validSample = (context.getParameter(ES_TEST_MODE).trim().equals("error") && sr.isSuccessful()) ? false : true;

if(validSample) {
Gson gson = new Gson();
String json = gson.toJson(this.getElasticData(sr, context));
this.bulkRequestList.add(json);
}
if(validSample)
this.bulkRequestList.add(new Gson().toJson(this.getElasticData(sr, context)));
}

if(this.bulkRequestList.size() >= this.bulkSize) {
Expand Down

0 comments on commit 622170a

Please sign in to comment.