jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmoua...@apache.org
Subject svn commit: r1859230 - in /jmeter/trunk: src/core/org/apache/jmeter/samplers/ src/protocol/http/org/apache/jmeter/protocol/http/sampler/ test/src/org/apache/jmeter/protocol/http/sampler/ xdocs/
Date Tue, 14 May 2019 13:14:11 GMT
Author: pmouawad
Date: Tue May 14 13:14:11 2019
New Revision: 1859230

URL: http://svn.apache.org/viewvc?rev=1859230&view=rev
Log:
Bug 63364 - When setting "subresults.disable_renaming=true", sub results are still renamed
using their parent SampleLabel while they shouldn't
Bugzilla Id: 63364

Added:
    jmeter/trunk/test/src/org/apache/jmeter/protocol/http/sampler/SamplingNamingTest.java
  (with props)
Modified:
    jmeter/trunk/src/core/org/apache/jmeter/samplers/SampleResult.java
    jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPAbstractImpl.java
    jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
    jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPJavaImpl.java
    jmeter/trunk/xdocs/changes.xml

Modified: jmeter/trunk/src/core/org/apache/jmeter/samplers/SampleResult.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/samplers/SampleResult.java?rev=1859230&r1=1859229&r2=1859230&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/samplers/SampleResult.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/samplers/SampleResult.java Tue May 14 13:14:11
2019
@@ -624,7 +624,7 @@ public class SampleResult implements Ser
      * see https://bz.apache.org/bugzilla/show_bug.cgi?id=63055
      * @return true if TestPlan is in functional mode or property subresults.disable_renaming
is true
      */
-    protected final boolean isRenameSampleLabel() {
+    public static final boolean isRenameSampleLabel() {
         return !(TestPlan.getFunctionalMode() || DISABLE_SUBRESULTS_RENAMING);
     }
 

Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPAbstractImpl.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPAbstractImpl.java?rev=1859230&r1=1859229&r2=1859230&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPAbstractImpl.java
(original)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPAbstractImpl.java
Tue May 14 13:14:11 2019
@@ -602,4 +602,12 @@ public abstract class HTTPAbstractImpl i
                 throw new IllegalStateException("Unknown CACHED_RESOURCE_MODE");
         }
     }
+    
+    protected final void configureSampleLabel(SampleResult res, URL url) {
+        if (SampleResult.isRenameSampleLabel()) {
+            res.setSampleLabel(this.testElement.getName());
+        } else {
+            res.setSampleLabel(url.toString());
+        }
+    }
 }

Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java?rev=1859230&r1=1859229&r2=1859230&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
(original)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
Tue May 14 13:14:11 2019
@@ -806,7 +806,7 @@ public class HTTPHC4Impl extends HTTPHCA
     protected HTTPSampleResult createSampleResult(URL url, String method) {
         HTTPSampleResult res = new HTTPSampleResult();
 
-        res.setSampleLabel(this.testElement.getName());
+        configureSampleLabel(res, url);
         res.setHTTPMethod(method);
         res.setURL(url);
         

Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPJavaImpl.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPJavaImpl.java?rev=1859230&r1=1859229&r2=1859230&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPJavaImpl.java
(original)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPJavaImpl.java
Tue May 14 13:14:11 2019
@@ -511,8 +511,7 @@ public class HTTPJavaImpl extends HTTPAb
         }
 
         HTTPSampleResult res = new HTTPSampleResult();
-
-        res.setSampleLabel(this.testElement.getName());
+        configureSampleLabel(res, url);
         res.setURL(url);
         res.setHTTPMethod(method);
 

Added: jmeter/trunk/test/src/org/apache/jmeter/protocol/http/sampler/SamplingNamingTest.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/sampler/SamplingNamingTest.java?rev=1859230&view=auto
==============================================================================
--- jmeter/trunk/test/src/org/apache/jmeter/protocol/http/sampler/SamplingNamingTest.java
(added)
+++ jmeter/trunk/test/src/org/apache/jmeter/protocol/http/sampler/SamplingNamingTest.java
Tue May 14 13:14:11 2019
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * 
+ */
+
+package org.apache.jmeter.protocol.http.sampler;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.jmeter.junit.JMeterTestCase;
+import org.apache.jmeter.samplers.SampleResult;
+import org.apache.jmeter.testelement.TestPlan;
+import org.apache.jorphan.test.JMeterSerialTest;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+@RunWith(Parameterized.class)
+public class SamplingNamingTest extends JMeterTestCase implements JMeterSerialTest {
+    private static final String JMETER_HOME_PAGE = "https://jmeter.apache.org";
+    private static final String LABEL = "JMeter-HP";
+    private String implementation;
+    
+    public SamplingNamingTest(String implementation) {
+        this.implementation = implementation;
+    }
+    
+    @Parameters(name = "Run {index}: implementation:{0}")
+    public static final String[] getImplementations() {
+        return new String[]{
+                HTTPSamplerFactory.IMPL_HTTP_CLIENT4,
+                HTTPSamplerFactory.IMPL_JAVA};
+    }
+    
+    @Test
+    @Parameters(name = "getImplementations")
+    public void testBug63364() {
+        TestPlan plan = new TestPlan();
+        SampleResult[] subResults = doSample(implementation);
+        Assert.assertTrue("We have at least one sample result",subResults.length>0);
+        for (int i = 0; i < subResults.length; i++) {
+            assertEquals(LABEL+"-"+i, subResults[i].getSampleLabel());
+        }
+        final boolean prevValue = TestPlan.getFunctionalMode();
+        plan.setFunctionalMode(true);
+        try {
+            subResults = doSample(implementation);
+            Assert.assertTrue("We have at least one sample result",subResults.length>0);
+            for (int i = 0; i < subResults.length; i++) {
+                Assert.assertTrue(subResults[i].getSampleLabel().startsWith(JMETER_HOME_PAGE));
+            }
+        } finally {
+            plan.setFunctionalMode(prevValue);
+        }
+    }
+
+
+    /**
+     * @param implementation HTTP implementation
+     * @return array of {@link SampleResult}
+     */
+    private SampleResult[] doSample(String implementation) {
+        HTTPSamplerProxy httpSamplerProxy = new HTTPSamplerProxy(implementation);
+        httpSamplerProxy.setName(LABEL);
+        httpSamplerProxy.setConnectTimeout("500");
+        httpSamplerProxy.setResponseTimeout("1000");
+        httpSamplerProxy.setImageParser(true);
+        httpSamplerProxy.setMethod("GET");
+        httpSamplerProxy.setPath(JMETER_HOME_PAGE);
+        // We intentionally keep only resources which start with JMETER_HOME_PAGE
+        httpSamplerProxy.setEmbeddedUrlRE(JMETER_HOME_PAGE+".*");
+        SampleResult result = httpSamplerProxy.sample();
+        assertEquals(LABEL, result.getSampleLabel());
+        SampleResult[] subResults = result.getSubResults();
+        return subResults;
+    }
+}

Propchange: jmeter/trunk/test/src/org/apache/jmeter/protocol/http/sampler/SamplingNamingTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jmeter/trunk/test/src/org/apache/jmeter/protocol/http/sampler/SamplingNamingTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1859230&r1=1859229&r2=1859230&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml [utf-8] (original)
+++ jmeter/trunk/xdocs/changes.xml [utf-8] Tue May 14 13:14:11 2019
@@ -132,6 +132,7 @@ to view the last major behaviors with th
 <h3>HTTP Samplers and Test Script Recorder</h3>
 <ul>
     <li><bug>63298</bug>HTTP Requests with encoded URLs are being sent
in decoded format</li>
+    <li><bug>63364</bug>When setting <code>subresults.disable_renaming=true</code>,
sub results are still renamed using their parent SampleLabel while they shouldn't. Contributed
by Ubik Load Pack (support at ubikloadpack.com)</li>
 </ul>
 
 <h3>Other Samplers</h3>



Mime
View raw message