jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1521679 - in /jmeter/trunk: bin/jmeter.properties src/protocol/http/org/apache/jmeter/protocol/http/proxy/ProxyControl.java xdocs/changes.xml xdocs/usermanual/component_reference.xml
Date Tue, 10 Sep 2013 23:29:24 GMT
Author: sebb
Date: Tue Sep 10 23:29:23 2013
New Revision: 1521679

URL: http://svn.apache.org/r1521679
Log:
Proxy recording and redirects
Added code to disable redirected samples.
Bugzilla Id: 55531

Modified:
    jmeter/trunk/bin/jmeter.properties
    jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/ProxyControl.java
    jmeter/trunk/xdocs/changes.xml
    jmeter/trunk/xdocs/usermanual/component_reference.xml

Modified: jmeter/trunk/bin/jmeter.properties
URL: http://svn.apache.org/viewvc/jmeter/trunk/bin/jmeter.properties?rev=1521679&r1=1521678&r2=1521679&view=diff
==============================================================================
--- jmeter/trunk/bin/jmeter.properties (original)
+++ jmeter/trunk/bin/jmeter.properties Tue Sep 10 23:29:23 2013
@@ -554,6 +554,10 @@ upgrade_properties=/bin/upgrade.properti
 # If false, will revert to using a single key with no certificate
 #proxy.cert.dynamic_keys=true
 
+# Whether to attempt disabling of samples that resulted from redirects
+# where the generated samples use auto-redirection
+#proxy.redirect.disabling=true
+
 # SSL configuration
 #proxy.ssl.protocol=SSLv3
 

Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/ProxyControl.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/ProxyControl.java?rev=1521679&r1=1521678&r2=1521679&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/ProxyControl.java
(original)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/ProxyControl.java
Tue Sep 10 23:29:23 2013
@@ -60,6 +60,7 @@ import org.apache.jmeter.gui.tree.JMeter
 import org.apache.jmeter.protocol.http.control.HeaderManager;
 import org.apache.jmeter.protocol.http.control.RecordingController;
 import org.apache.jmeter.protocol.http.gui.HeaderPanel;
+import org.apache.jmeter.protocol.http.sampler.HTTPSampleResult;
 import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase;
 import org.apache.jmeter.protocol.http.sampler.HTTPSamplerFactory;
 import org.apache.jmeter.samplers.SampleEvent;
@@ -202,7 +203,7 @@ public class ProxyControl extends Generi
     }
 
     static final KeystoreMode KEYSTORE_MODE;
-    
+
     static {
         if (CERT_ALIAS != null) {
             KEYSTORE_MODE = KeystoreMode.USER_KEYSTORE;
@@ -218,6 +219,18 @@ public class ProxyControl extends Generi
         }
     }
 
+    // Whether to use the redirect disabling feature (can be switched off if it does not
work)
+    private static final boolean ATTEMPT_REDIRECT_DISABLING =
+            JMeterUtils.getPropDefault("proxy.redirect.disabling", true); // $NON-NLS-1$
+
+    // Although this field is mutable, it is only accessed within the synchronized method
deliverSampler()
+    private static String LAST_REDIRECT = null;
+    /*
+     * TODO this assumes that the redirected response will always immediately follow the
original response.
+     * This may not always be true.
+     * Is there a better way to do this?
+     */
+
     private transient Daemon server;
 
     private long lastTime = 0;// When was the last sample seen?
@@ -483,6 +496,26 @@ public class ProxyControl extends Generi
      */
     public synchronized void deliverSampler(final HTTPSamplerBase sampler, final TestElement[]
subConfigs, final SampleResult result) {
         if (sampler != null) {
+            if (ATTEMPT_REDIRECT_DISABLING && (samplerRedirectAutomatically || samplerFollowRedirects))
{
+                if (result instanceof HTTPSampleResult) {
+                    final HTTPSampleResult httpSampleResult = (HTTPSampleResult) result;
+                    final String urlAsString = httpSampleResult.getUrlAsString();
+                    if (urlAsString.equals(LAST_REDIRECT)) { // the url matches the last
redirect
+                        sampler.setEnabled(false);
+                        sampler.setComment("Detected a redirect from the previous sample");
+                    } else { // this is not the result of a redirect
+                        LAST_REDIRECT = null; // so break the chain                     
      
+                    }
+                    if (httpSampleResult.isRedirect()) { // Save Location so resulting sample
can be disabled
+                        if (LAST_REDIRECT == null) {
+                            sampler.setComment("Detected the start of a redirect chain");
+                        }
+                        LAST_REDIRECT = httpSampleResult.getRedirectLocation();
+                    } else {
+                        LAST_REDIRECT = null;
+                    }
+                }
+            }
             if (filterContentType(result) && filterUrl(sampler)) {
                 JMeterTreeNode myTarget = findTargetControllerNode();
                 @SuppressWarnings("unchecked") // OK, because find only returns correct element
types
@@ -1159,7 +1192,7 @@ public class ProxyControl extends Generi
             initUserKeyStore();
             break;
         default:
-            throw new IllegalStateException("Impossible case: " + KEYSTORE_MODE);       

+            throw new IllegalStateException("Impossible case: " + KEYSTORE_MODE);
         }
     }
 

Modified: jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1521679&r1=1521678&r2=1521679&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml (original)
+++ jmeter/trunk/xdocs/changes.xml Tue Sep 10 23:29:23 2013
@@ -361,6 +361,7 @@ Previously the default was 1, which coul
 <li><bugzilla>54874</bugzilla> - Support device in addition to source IP
address. Based on patch by Dan Fruehauf (malkodan at gmail.com)</li>
 <li><bugzilla>55488</bugzilla> - Add .ico and .woff file extension to default
suggested exclusions in proxy recorder. Contributed by Antonio Gomes Rodrigues</li>
 <li><bugzilla>55525</bugzilla> - Proxy should support alias for keyserver
entry</li>
+<li><bugzilla>55531</bugzilla> - Proxy recording and redirects. Added code
to disable redirected samples.</li>
 </ul>
 
 <h3>Other samplers</h3>

Modified: jmeter/trunk/xdocs/usermanual/component_reference.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/usermanual/component_reference.xml?rev=1521679&r1=1521678&r2=1521679&view=diff
==============================================================================
--- jmeter/trunk/xdocs/usermanual/component_reference.xml (original)
+++ jmeter/trunk/xdocs/usermanual/component_reference.xml Tue Sep 10 23:29:23 2013
@@ -5835,17 +5835,18 @@ This setting will also be needed when ru
 During recording, the browser will follow a redirect response and generate an additional
request.
 The Proxy will record both the original request and the redirected request
 (subject to whatever exclusions are configured).
-The generated samples have "Follow Redirects" selected by default,
-so when a test plan is replayed, JMeter will follow the redirect, 
-and then replay the redirect request that was recorded.
-To avoid this duplicate replay, either delete the redirected sample from the test plan,
-or ensure that the recorded samples don't have "Follow Redirects" selected.
-The default of "Follow Redirects" was chosen because that is generally better.
-Redirects may depend on the original request, so repeating the originally recorded sample
may not always work.
+The generated samples have "Follow Redirects" selected by default, because that is generally
better.
+[Redirects may depend on the original request, so repeating the originally recorded sample
may not always work.]
 </p>
 <p>
-It is hoped (eventually) to be able to detect redirects during recording and drop/disable
them
-so they don't get replayed.
+Now if JMeter is set to follow the redirect during replay, it will issue the original request,

+and then replay the redirect request that was recorded.
+To avoid this duplicate replay, JMeter tries to detect when a sample is the result of a previous
+redirect. If the current response is a redirect, JMeter will save the redirect URL.
+When the next request is received, it is compared with the saved redirect URL and if there
is a match,
+JMeter will disable the generated sample. It also adds comments to the redirect chain.
+This assumes that all the requests in a redirect chain will follow each other without any
intervening requests.
+To disable the redirect detection, set the property <code>proxy.redirect.disabling=false</code>
 </p>
 
 <h4>Includes and Excludes</h4>



Mime
View raw message