Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replacing the spaces in the thread name with underscores instead of t… #36

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import static com.lazerycode.jmeter.analyzer.config.Environment.ENVIRONMENT;
import static com.lazerycode.jmeter.analyzer.parser.StatusCodes.HTTPCODE_CONNECTIONERROR;
import static com.lazerycode.jmeter.analyzer.parser.StatusCodes.HTTPCODE_ERROR;

import java.io.IOException;
import java.io.Reader;
Expand Down Expand Up @@ -333,14 +332,9 @@ private String getKey(Attributes attributes) {
else {

// use threadgroup name as a key
key = attributes.getValue("tn");

//key is now "threadgroupname int-int"
int threadGroupSeparator = key.indexOf(' ');
if( threadGroupSeparator > -1) {
// cut off trailing threadno
key = key.substring(0, threadGroupSeparator);
}
key = attributes.getValue("tn").trim();
key = key.replaceAll("\\s+", "_");
//key is now "threadgroupname_int-int"
}

return key;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
package com.lazerycode.jmeter.analyzer;

import com.lazerycode.jmeter.analyzer.config.Environment;
import com.lazerycode.jmeter.analyzer.parser.AggregatedResponses;
import com.lazerycode.jmeter.analyzer.parser.JMeterResultParser;

import junit.framework.TestCase;

import org.apache.maven.plugin.logging.SystemStreamLog;
import static com.lazerycode.jmeter.analyzer.config.Environment.ENVIRONMENT;

import java.io.InputStreamReader;
import java.util.ArrayList;
Expand All @@ -15,7 +9,12 @@
import java.util.List;
import java.util.Map;

import static com.lazerycode.jmeter.analyzer.config.Environment.ENVIRONMENT;
import org.apache.maven.plugin.logging.SystemStreamLog;

import com.lazerycode.jmeter.analyzer.config.Environment;
import com.lazerycode.jmeter.analyzer.parser.AggregatedResponses;
import com.lazerycode.jmeter.analyzer.parser.JMeterResultParser;
import junit.framework.TestCase;

/**
* Tests {@link JMeterResultParser}
Expand All @@ -35,9 +34,10 @@ public void testSuccess() throws Exception {

assertEquals("size", 1, result.size());

AggregatedResponses r = result.get("warmup");
AggregatedResponses r = result.get("warmup_3-1");

// test requests
assertNotNull(r);
assertEquals("samples", 10, r.getDuration().getStoredSamplesCount());
assertEquals("success", 10, r.getDuration().getSuccessCount());
assertEquals("failure", 0, r.getDuration().getErrorsCount());
Expand All @@ -51,11 +51,12 @@ public void testDifferentNodeNames() throws Exception {
JMeterResultParser a = new JMeterResultParser();
Map<String, AggregatedResponses> result = a.aggregate(new InputStreamReader(getClass().getResourceAsStream("JMeterResultParserTest-differentNodeNames.xml")));

assertEquals("size", 1, result.size());
assertEquals("size", 2, result.size());

AggregatedResponses r = result.get("warmup");
AggregatedResponses r = result.get("warmup_3-1");

// test requests
assertNotNull(r);
assertEquals("samples", 3, r.getDuration().getStoredSamplesCount());
assertEquals("success", 3, r.getDuration().getSuccessCount());
assertEquals("failure", 0, r.getDuration().getErrorsCount());
Expand All @@ -68,9 +69,10 @@ public void testSomeErrors() throws Exception {

assertEquals("size", 1, result.size());

AggregatedResponses r = result.get("warmup");
AggregatedResponses r = result.get("warmup_3-1");

// test requests
assertNotNull(r);
assertEquals("samples", 1, r.getDuration().getStoredSamplesCount());
assertEquals("success", 1, r.getDuration().getSuccessCount());
assertEquals("failure", 2, r.getDuration().getErrorsCount());
Expand All @@ -83,9 +85,10 @@ public void testOnlyErrors() throws Exception {

assertEquals("size", 1, result.size());

AggregatedResponses r = result.get("warmup");
AggregatedResponses r = result.get("warmup_3-1");

// test requests
assertNotNull(r);
assertEquals("samples", 0, r.getDuration().getStoredSamplesCount());
assertEquals("success", 0, r.getDuration().getSuccessCount());
assertEquals("failure", 3, r.getDuration().getErrorsCount());
Expand Down Expand Up @@ -127,6 +130,18 @@ public void testPatternSuccess() throws Exception {
assertEquals("failure", 0, r.getDuration().getErrorsCount());
}

public void testSpacesAreReplacedWithUnderscoresInTestName() throws Exception {
JMeterResultParser a = new JMeterResultParser();
Map<String, AggregatedResponses> result = a.aggregate(new InputStreamReader(getClass().getResourceAsStream("JMeterResultParserTest-differentNodeNames.xml")));

assertEquals("size", 2, result.size());

AggregatedResponses r = result.get("test_name_with_spaces");

// test requests
assertNotNull(r);
}

// TODO: more tests


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
<httpSample t="1403" lt="1224" ts="1316697692340" s="true" lb="/main" rc="200" rm="OK" tn="warmup 3-1" dt="text" by="53890"/>
<sample t="19" lt="19" ts="1316697693748" s="true" lb="/main/6/data" rc="200" rm="OK" tn="warmup 3-1" dt="bin" by="20480"/>
<httpSample t="4" lt="4" ts="1316697693767" s="true" lb="/main/10/data" rc="200" rm="OK" tn="warmup 3-1" dt="bin" by="20480"/>
<sample t="58" lt="58" ts="1316697693798" s="true" lb="/main/8/data" rc="200" rm="OK" tn="test name with spaces" dt="bin" by="20480"/>
</testResults>
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
<body>
<h1>JMeter Summary</h1>
<div class="aggregations">
<h2>Group: warmup</h2>
<h2>Group: warmup_1-1</h2>
<div class="aggregation">
<h3>Summary</h3>
<table>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Group: warmup
Group: warmup_1-1
time: 20111216T145509+0100 - 20111216T145539+0100
total duration: 30
requests: 10
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
<body>
<h1>JMeter Summary</h1>
<div class="aggregations">
<h2>Group: warmup</h2>
<h2>Group: warmup_1-1</h2>
<div class="aggregation">
<h3>Summary</h3>
<table>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Group: warmup
Group: warmup_1-1
time: 20111216T145511+0100 - 20111216T145511+0100
total duration: 0
requests: 1
Expand Down