Bug 63055 Don't rename SampleResult Label when test is running in Functional mode or property subresults.disable_renaming=true.

Implemented by Artem Fedorov (artem.fedorov at blazemeter.com) and contributed by BlazeMeter.

This closes #439
Bugzilla Id: 63055

git-svn-id: https://svn.apache.org/repos/asf/jmeter/trunk@1852943 13f79535-47bb-0310-9956-ffa450edef68

Former-commit-id: 1a40450242
This commit is contained in:
Philippe Mouawad 2019-02-04 20:19:53 +00:00
parent bb1476ba08
commit 926f9e882a
5 changed files with 62 additions and 4 deletions

View File

@ -576,6 +576,11 @@ sampleresult.timestamp.start=true
# Set this to <= 0 to disable the background thread # Set this to <= 0 to disable the background thread
#sampleresult.nanoThreadSleep=5000 #sampleresult.nanoThreadSleep=5000
# Since version 5.0 JMeter has a new SubResult Naming Policy which numbers subresults by default
# This property if set to true discards renaming policy. This can be required if you're using JMeter for functional testing.
# Defaults to: false
#subresults.disable_renaming=false
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
# Upgrade property # Upgrade property
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
@ -1320,3 +1325,11 @@ jmeter.reportgenerator.apdex_tolerated_threshold=1500
# Switch that allows using Local documentation opened in JMeter GUI # Switch that allows using Local documentation opened in JMeter GUI
# By default we use Online documentation opened in Browser # By default we use Online documentation opened in Browser
#help.local=false #help.local=false
#---------------------------------------------------------------------------
# Documentation generation
#---------------------------------------------------------------------------
# Path to XSL file used to generate Schematic View of Test Plan
# When empty, JMeter will use the embedded one in src/core/org/apache/jmeter/gui/action/schematic.xsl
#docgeneration.schematic_xsl=

View File

@ -32,6 +32,7 @@ import java.util.concurrent.TimeUnit;
import org.apache.jmeter.assertions.AssertionResult; import org.apache.jmeter.assertions.AssertionResult;
import org.apache.jmeter.gui.Searchable; import org.apache.jmeter.gui.Searchable;
import org.apache.jmeter.testelement.TestPlan;
import org.apache.jmeter.threads.JMeterContext.TestLogicalAction; import org.apache.jmeter.threads.JMeterContext.TestLogicalAction;
import org.apache.jmeter.util.JMeterUtils; import org.apache.jmeter.util.JMeterUtils;
import org.apache.jorphan.util.JOrphanUtils; import org.apache.jorphan.util.JOrphanUtils;
@ -96,7 +97,9 @@ public class SampleResult implements Serializable, Cloneable, Searchable {
* @see #setDataType(java.lang.String) * @see #setDataType(java.lang.String)
*/ */
public static final String BINARY = "bin"; // $NON-NLS-1$ public static final String BINARY = "bin"; // $NON-NLS-1$
private static final boolean DISABLE_SUBRESULTS_RENAMING = JMeterUtils.getPropDefault("subresults.disable_renaming", false);
// List of types that are known to be binary // List of types that are known to be binary
private static final String[] BINARY_TYPES = { private static final String[] BINARY_TYPES = {
"image/", //$NON-NLS-1$ "image/", //$NON-NLS-1$
@ -614,8 +617,17 @@ public class SampleResult implements Serializable, Cloneable, Searchable {
* the {@link SampleResult} to be added * the {@link SampleResult} to be added
*/ */
public void addSubResult(SampleResult subResult) { public void addSubResult(SampleResult subResult) {
addSubResult(subResult, true); addSubResult(subResult, isRenameSampleLabel());
} }
/**
* @return true if TestPlan is in functional mode or property subresults.disable_renaming is true
* @see https://bz.apache.org/bugzilla/show_bug.cgi?id=63055
*/
protected final boolean isRenameSampleLabel() {
return !(TestPlan.getFunctionalMode() || DISABLE_SUBRESULTS_RENAMING);
}
/** /**
* Add a subresult and adjust the parent byte count and end-time. * Add a subresult and adjust the parent byte count and end-time.
* *
@ -652,7 +664,7 @@ public class SampleResult implements Serializable, Cloneable, Searchable {
* the {@link SampleResult} to be added * the {@link SampleResult} to be added
*/ */
public void addRawSubResult(SampleResult subResult){ public void addRawSubResult(SampleResult subResult){
storeSubResult(subResult, true); storeSubResult(subResult, isRenameSampleLabel());
} }
/** /**
@ -676,7 +688,7 @@ public class SampleResult implements Serializable, Cloneable, Searchable {
* the {@link SampleResult} to be added * the {@link SampleResult} to be added
*/ */
public void storeSubResult(SampleResult subResult) { public void storeSubResult(SampleResult subResult) {
storeSubResult(subResult, true); storeSubResult(subResult, isRenameSampleLabel());
} }
/** /**

View File

@ -26,6 +26,7 @@ import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
import org.apache.jmeter.junit.JMeterTestCase; import org.apache.jmeter.junit.JMeterTestCase;
import org.apache.jmeter.testelement.TestPlan;
import org.apache.jmeter.util.Calculator; import org.apache.jmeter.util.Calculator;
import org.apache.jmeter.util.LogRecordingDelegatingLogger; import org.apache.jmeter.util.LogRecordingDelegatingLogger;
import org.apache.jorphan.test.JMeterSerialTest; import org.apache.jorphan.test.JMeterSerialTest;
@ -344,5 +345,31 @@ public class TestSampleResult implements JMeterSerialTest {
Thread.sleep(ms); Thread.sleep(ms);
return System.currentTimeMillis() - start; return System.currentTimeMillis() - start;
} }
@Test
public void testCompareSampleLabels() {
final boolean prevValue = TestPlan.getFunctionalMode();
TestPlan plan = new TestPlan();
plan.setFunctionalMode(true);
try {
SampleResult result = new SampleResult();
result.setStartTime(System.currentTimeMillis());
result.setSampleLabel("parent label");
SampleResult subResult = new SampleResult();
subResult.setStartTime(System.currentTimeMillis());
subResult.setSampleLabel("subResult label");
result.addSubResult(subResult);
assertEquals("subResult label", subResult.getSampleLabel());
plan.setFunctionalMode(false);
subResult.setSampleLabel("parent label");
result.addRawSubResult(subResult);
assertEquals("parent label-0", subResult.getSampleLabel());
} finally {
plan.setFunctionalMode(prevValue);
}
}
} }

View File

@ -100,6 +100,7 @@ containing a fix to this issue, we decided to remove it. If you still needed, yo
<ul> <ul>
<li><bug>62934</bug>Add compatibility for JDBC drivers that do not support QueryTimeout </li> <li><bug>62934</bug>Add compatibility for JDBC drivers that do not support QueryTimeout </li>
<li><bug>62935</bug>Pass custom <code>mail.*</code> properties to Mail Reader Sampler. Implemented by Artem Fedorov (artem.fedorov at blazemeter.com) and contributed by BlazeMeter.</li> <li><bug>62935</bug>Pass custom <code>mail.*</code> properties to Mail Reader Sampler. Implemented by Artem Fedorov (artem.fedorov at blazemeter.com) and contributed by BlazeMeter.</li>
<li><bug>63055</bug>Don't rename SampleResult Label when test is running in Functional mode or property <code>subresults.disable_renaming=true</code>. Implemented by Artem Fedorov (artem.fedorov at blazemeter.com) and contributed by BlazeMeter.</li>
</ul> </ul>
<h3>Controllers</h3> <h3>Controllers</h3>

View File

@ -732,6 +732,11 @@ JMETER-SERVER</source>
Set this to a value less than zero to disable the background thread.<br/> Set this to a value less than zero to disable the background thread.<br/>
Defaults to: <code>5000</code> Defaults to: <code>5000</code>
</property> </property>
<property name="subresults.disable_renaming">
Since version 5.0 JMeter has a new SubResult Naming Policy which numbers subresults by default<br/>
This property if set to <code>true</code> discards renaming policy. This can be required if you're using JMeter for functional testing.<br/>
Defaults to: <code>false</code>
</property>
</properties> </properties>
</section> </section>
<section name="&sect-num;.17 Upgrade" anchor="upgrade"> <section name="&sect-num;.17 Upgrade" anchor="upgrade">