jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1700627 - in /jmeter/branches/SampleTimeout: bin/Sleeps.jmx bin/user.properties src/components/org/apache/jmeter/timers/InterruptTimer.java src/core/org/apache/jmeter/threads/JMeterThread.java
Date Tue, 01 Sep 2015 17:42:45 GMT
Author: sebb
Date: Tue Sep  1 17:42:45 2015
New Revision: 1700627

URL: http://svn.apache.org/r1700627
Log:
Implement sampleStarted/Stopped, but make it switchable for now.
When it is enabled, InterruptTimer works in conjunction with other Timers

Added:
    jmeter/branches/SampleTimeout/bin/Sleeps.jmx   (with props)
Modified:
    jmeter/branches/SampleTimeout/bin/user.properties
    jmeter/branches/SampleTimeout/src/components/org/apache/jmeter/timers/InterruptTimer.java
    jmeter/branches/SampleTimeout/src/core/org/apache/jmeter/threads/JMeterThread.java

Added: jmeter/branches/SampleTimeout/bin/Sleeps.jmx
URL: http://svn.apache.org/viewvc/jmeter/branches/SampleTimeout/bin/Sleeps.jmx?rev=1700627&view=auto
==============================================================================
--- jmeter/branches/SampleTimeout/bin/Sleeps.jmx (added)
+++ jmeter/branches/SampleTimeout/bin/Sleeps.jmx Tue Sep  1 17:42:45 2015
@@ -0,0 +1,181 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<jmeterTestPlan version="1.2" properties="2.8" jmeter="2.14-SNAPSHOT.20150901">
+  <hashTree>
+    <TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="Sleeps" enabled="true">
+      <stringProp name="TestPlan.comments"></stringProp>
+      <boolProp name="TestPlan.functional_mode">false</boolProp>
+      <boolProp name="TestPlan.serialize_threadgroups">false</boolProp>
+      <elementProp name="TestPlan.user_defined_variables" elementType="Arguments" guiclass="ArgumentsPanel"
testclass="Arguments" testname="User Defined Variables" enabled="true">
+        <collectionProp name="Arguments.arguments"/>
+      </elementProp>
+      <stringProp name="TestPlan.user_define_classpath"></stringProp>
+    </TestPlan>
+    <hashTree>
+      <ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="Thread
Group" enabled="true">
+        <stringProp name="ThreadGroup.on_sample_error">continue</stringProp>
+        <elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel"
testclass="LoopController" testname="Loop Controller" enabled="true">
+          <boolProp name="LoopController.continue_forever">false</boolProp>
+          <stringProp name="LoopController.loops">2</stringProp>
+        </elementProp>
+        <stringProp name="ThreadGroup.num_threads">3</stringProp>
+        <stringProp name="ThreadGroup.ramp_time">1</stringProp>
+        <longProp name="ThreadGroup.start_time">1441126827000</longProp>
+        <longProp name="ThreadGroup.end_time">1441126827000</longProp>
+        <boolProp name="ThreadGroup.scheduler">false</boolProp>
+        <stringProp name="ThreadGroup.duration"></stringProp>
+        <stringProp name="ThreadGroup.delay"></stringProp>
+      </ThreadGroup>
+      <hashTree>
+        <JavaSampler guiclass="JavaTestSamplerGui" testclass="JavaSampler" testname="Sleep
1000" enabled="true">
+          <elementProp name="arguments" elementType="Arguments" guiclass="ArgumentsPanel"
testclass="Arguments" enabled="true">
+            <collectionProp name="Arguments.arguments">
+              <elementProp name="SleepTime" elementType="Argument">
+                <stringProp name="Argument.name">SleepTime</stringProp>
+                <stringProp name="Argument.value">1000</stringProp>
+                <stringProp name="Argument.metadata">=</stringProp>
+              </elementProp>
+              <elementProp name="SleepMask" elementType="Argument">
+                <stringProp name="Argument.name">SleepMask</stringProp>
+                <stringProp name="Argument.value">0</stringProp>
+                <stringProp name="Argument.metadata">=</stringProp>
+              </elementProp>
+            </collectionProp>
+          </elementProp>
+          <stringProp name="classname">org.apache.jmeter.protocol.java.test.SleepTest</stringProp>
+        </JavaSampler>
+        <hashTree>
+          <ConstantTimer guiclass="ConstantTimerGui" testclass="ConstantTimer" testname="Timer
1000" enabled="true">
+            <stringProp name="ConstantTimer.delay">1000</stringProp>
+          </ConstantTimer>
+          <hashTree/>
+        </hashTree>
+        <JavaSampler guiclass="JavaTestSamplerGui" testclass="JavaSampler" testname="Sleep
2000" enabled="true">
+          <elementProp name="arguments" elementType="Arguments" guiclass="ArgumentsPanel"
testclass="Arguments" enabled="true">
+            <collectionProp name="Arguments.arguments">
+              <elementProp name="SleepTime" elementType="Argument">
+                <stringProp name="Argument.name">SleepTime</stringProp>
+                <stringProp name="Argument.value">2000</stringProp>
+                <stringProp name="Argument.metadata">=</stringProp>
+              </elementProp>
+              <elementProp name="SleepMask" elementType="Argument">
+                <stringProp name="Argument.name">SleepMask</stringProp>
+                <stringProp name="Argument.value">0</stringProp>
+                <stringProp name="Argument.metadata">=</stringProp>
+              </elementProp>
+            </collectionProp>
+          </elementProp>
+          <stringProp name="classname">org.apache.jmeter.protocol.java.test.SleepTest</stringProp>
+        </JavaSampler>
+        <hashTree/>
+        <JavaSampler guiclass="JavaTestSamplerGui" testclass="JavaSampler" testname="Sleep
1000" enabled="true">
+          <elementProp name="arguments" elementType="Arguments" guiclass="ArgumentsPanel"
testclass="Arguments" enabled="true">
+            <collectionProp name="Arguments.arguments">
+              <elementProp name="SleepTime" elementType="Argument">
+                <stringProp name="Argument.name">SleepTime</stringProp>
+                <stringProp name="Argument.value">1000</stringProp>
+                <stringProp name="Argument.metadata">=</stringProp>
+              </elementProp>
+              <elementProp name="SleepMask" elementType="Argument">
+                <stringProp name="Argument.name">SleepMask</stringProp>
+                <stringProp name="Argument.value">0</stringProp>
+                <stringProp name="Argument.metadata">=</stringProp>
+              </elementProp>
+            </collectionProp>
+          </elementProp>
+          <stringProp name="classname">org.apache.jmeter.protocol.java.test.SleepTest</stringProp>
+        </JavaSampler>
+        <hashTree/>
+        <JavaSampler guiclass="JavaTestSamplerGui" testclass="JavaSampler" testname="Sleep
2000" enabled="true">
+          <elementProp name="arguments" elementType="Arguments" guiclass="ArgumentsPanel"
testclass="Arguments" enabled="true">
+            <collectionProp name="Arguments.arguments">
+              <elementProp name="SleepTime" elementType="Argument">
+                <stringProp name="Argument.name">SleepTime</stringProp>
+                <stringProp name="Argument.value">2000</stringProp>
+                <stringProp name="Argument.metadata">=</stringProp>
+              </elementProp>
+              <elementProp name="SleepMask" elementType="Argument">
+                <stringProp name="Argument.name">SleepMask</stringProp>
+                <stringProp name="Argument.value">0</stringProp>
+                <stringProp name="Argument.metadata">=</stringProp>
+              </elementProp>
+            </collectionProp>
+          </elementProp>
+          <stringProp name="classname">org.apache.jmeter.protocol.java.test.SleepTest</stringProp>
+        </JavaSampler>
+        <hashTree/>
+        <InterruptTimer guiclass="InterruptTimerGui" testclass="InterruptTimer" testname="Interrupt
1500" enabled="true">
+          <stringProp name="InterruptTimer.timeout">1500</stringProp>
+          <stringProp name="type"></stringProp>
+          <stringProp name="calldelay"></stringProp>
+        </InterruptTimer>
+        <hashTree/>
+      </hashTree>
+      <ResultCollector guiclass="ViewResultsFullVisualizer" testclass="ResultCollector"
testname="View Results Tree" enabled="false">
+        <boolProp name="ResultCollector.error_logging">false</boolProp>
+        <objProp>
+          <name>saveConfig</name>
+          <value class="SampleSaveConfiguration">
+            <time>true</time>
+            <latency>true</latency>
+            <timestamp>true</timestamp>
+            <success>true</success>
+            <label>true</label>
+            <code>true</code>
+            <message>true</message>
+            <threadName>true</threadName>
+            <dataType>true</dataType>
+            <encoding>false</encoding>
+            <assertions>true</assertions>
+            <subresults>true</subresults>
+            <responseData>false</responseData>
+            <samplerData>false</samplerData>
+            <xml>false</xml>
+            <fieldNames>false</fieldNames>
+            <responseHeaders>false</responseHeaders>
+            <requestHeaders>false</requestHeaders>
+            <responseDataOnError>false</responseDataOnError>
+            <saveAssertionResultsFailureMessage>false</saveAssertionResultsFailureMessage>
+            <assertionsResultsToSave>0</assertionsResultsToSave>
+            <bytes>true</bytes>
+            <threadCounts>true</threadCounts>
+          </value>
+        </objProp>
+        <stringProp name="filename"></stringProp>
+      </ResultCollector>
+      <hashTree/>
+      <ResultCollector guiclass="TableVisualizer" testclass="ResultCollector" testname="View
Results in Table" enabled="true">
+        <boolProp name="ResultCollector.error_logging">false</boolProp>
+        <objProp>
+          <name>saveConfig</name>
+          <value class="SampleSaveConfiguration">
+            <time>true</time>
+            <latency>true</latency>
+            <timestamp>true</timestamp>
+            <success>true</success>
+            <label>true</label>
+            <code>true</code>
+            <message>true</message>
+            <threadName>true</threadName>
+            <dataType>true</dataType>
+            <encoding>false</encoding>
+            <assertions>true</assertions>
+            <subresults>true</subresults>
+            <responseData>false</responseData>
+            <samplerData>false</samplerData>
+            <xml>false</xml>
+            <fieldNames>false</fieldNames>
+            <responseHeaders>false</responseHeaders>
+            <requestHeaders>false</requestHeaders>
+            <responseDataOnError>false</responseDataOnError>
+            <saveAssertionResultsFailureMessage>false</saveAssertionResultsFailureMessage>
+            <assertionsResultsToSave>0</assertionsResultsToSave>
+            <bytes>true</bytes>
+            <threadCounts>true</threadCounts>
+          </value>
+        </objProp>
+        <stringProp name="filename"></stringProp>
+      </ResultCollector>
+      <hashTree/>
+    </hashTree>
+  </hashTree>
+</jmeterTestPlan>

Propchange: jmeter/branches/SampleTimeout/bin/Sleeps.jmx
------------------------------------------------------------------------------
    svn:eol-style = LF

Modified: jmeter/branches/SampleTimeout/bin/user.properties
URL: http://svn.apache.org/viewvc/jmeter/branches/SampleTimeout/bin/user.properties?rev=1700627&r1=1700626&r2=1700627&view=diff
==============================================================================
--- jmeter/branches/SampleTimeout/bin/user.properties (original)
+++ jmeter/branches/SampleTimeout/bin/user.properties Tue Sep  1 17:42:45 2015
@@ -67,4 +67,8 @@
 #log_level.jmeter.protocol.http.proxy.HttpRequestHdr=DEBUG
 
 #enable InterruptTimer debug
-#log_level.jmeter.timers.InterruptTimer=DEBUG
\ No newline at end of file
+#log_level.jmeter.timers.InterruptTimer=DEBUG
+
+# this controls whether JMeterThread implements samplerStarted/Stopped or not
+# default true
+#temp.sampleStarted=true
\ No newline at end of file

Modified: jmeter/branches/SampleTimeout/src/components/org/apache/jmeter/timers/InterruptTimer.java
URL: http://svn.apache.org/viewvc/jmeter/branches/SampleTimeout/src/components/org/apache/jmeter/timers/InterruptTimer.java?rev=1700627&r1=1700626&r2=1700627&view=diff
==============================================================================
--- jmeter/branches/SampleTimeout/src/components/org/apache/jmeter/timers/InterruptTimer.java
(original)
+++ jmeter/branches/SampleTimeout/src/components/org/apache/jmeter/timers/InterruptTimer.java
Tue Sep  1 17:42:45 2015
@@ -27,12 +27,15 @@ import java.util.concurrent.ThreadFactor
 import java.util.concurrent.TimeUnit;
 
 import org.apache.jmeter.samplers.Interruptible;
+import org.apache.jmeter.samplers.SampleEvent;
+import org.apache.jmeter.samplers.SampleListener;
 import org.apache.jmeter.samplers.Sampler;
 import org.apache.jmeter.testelement.AbstractTestElement;
 import org.apache.jmeter.testelement.TestElement;
 import org.apache.jmeter.testelement.ThreadListener;
 import org.apache.jmeter.threads.JMeterContext;
 import org.apache.jmeter.threads.JMeterContextService;
+import org.apache.jmeter.threads.JMeterThread;
 import org.apache.jmeter.util.JMeterUtils;
 import org.apache.jorphan.logging.LoggingManager;
 import org.apache.log.Logger;
@@ -42,7 +45,7 @@ import org.apache.log.Logger;
  * Sample timeout implementation using Executor threads
  *
  */
-public class InterruptTimer extends AbstractTestElement implements Timer, Serializable, ThreadListener
{
+public class InterruptTimer extends AbstractTestElement implements Timer, Serializable, ThreadListener,
SampleListener {
 
     private static final long serialVersionUID = 1L;
 
@@ -66,7 +69,7 @@ public class InterruptTimer extends Abst
         return TPOOLHolder.EXEC_SERVICE;
     }
 
-    private JMeterContext context;
+    private JMeterContext context; // Cache this here to avoid refetching
 
     private ScheduledFuture<?> future;
     
@@ -113,17 +116,43 @@ public class InterruptTimer extends Abst
      */
     @Override
     public long delay() {
+        // Check if sampleStarted/Stopped are available
+        // (this is a temp. hack to allow the features to be compared)
+        if (JMeterThread.IMPLEMENTS_SAMPLE_STARTED) {
+            return 0;// we are not using delay
+        }
         if (debug) {
             LOG.debug(whoAmI("delay()", this));
         }
         cancelTask(); // cancel previous if any
+        createTask();
+        return 0;
+    }
+
+    @Override
+    public void sampleStarted(SampleEvent e) {
+        if (debug) {
+            LOG.debug(whoAmI("sampleStarted()", this));
+        }
+        createTask();
+    }
+
+    @Override
+    public void sampleStopped(SampleEvent e) {
+        if (debug) {
+            LOG.debug(whoAmI("sampleStopped()", this));
+        }
+        cancelTask();
+    }
+
+    private void createTask() {
         long timeout = getPropertyAsLong(TIMEOUT); // refetch each time so it can be a variable
         if (timeout <= 0) {
-            return 0;
+            return;
         }
         final Sampler samp = context.getCurrentSampler();
         if (!(samp instanceof Interruptible)) { // may be applied to a whole test 
-            return 0; // Cannot time out in this case
+            return; // Cannot time out in this case
         }
         final Interruptible sampler = (Interruptible) samp;
         
@@ -173,7 +202,6 @@ public class InterruptTimer extends Abst
         if (debug) {
             LOG.debug("Scheduled timer: @" + System.identityHashCode(future) + " " + getInfo(samp));
         }
-        return 0;
     }
 
     @Override
@@ -237,4 +265,9 @@ public class InterruptTimer extends Abst
     public String getCallDelay() {
         return getPropertyAsString("calldelay","0");
     }
+
+    @Override
+    public void sampleOccurred(SampleEvent e) {
+        // Not used
+    }
 }

Modified: jmeter/branches/SampleTimeout/src/core/org/apache/jmeter/threads/JMeterThread.java
URL: http://svn.apache.org/viewvc/jmeter/branches/SampleTimeout/src/core/org/apache/jmeter/threads/JMeterThread.java?rev=1700627&r1=1700626&r2=1700627&view=diff
==============================================================================
--- jmeter/branches/SampleTimeout/src/core/org/apache/jmeter/threads/JMeterThread.java (original)
+++ jmeter/branches/SampleTimeout/src/core/org/apache/jmeter/threads/JMeterThread.java Tue
Sep  1 17:42:45 2015
@@ -65,6 +65,11 @@ import org.apache.log.Logger;
  */
 public class JMeterThread implements Runnable, Interruptible {
     private static final Logger log = LoggingManager.getLoggerForClass();
+    
+    public static final boolean IMPLEMENTS_SAMPLE_STARTED = JMeterUtils.getPropDefault("temp.sampleStarted",
true);
+    static {
+        log.info("IMPLEMENTS_SAMPLE_STARTED="+IMPLEMENTS_SAMPLE_STARTED);
+    }
 
     public static final String PACKAGE_OBJECT = "JMeterThread.pack"; // $NON-NLS-1$
 
@@ -431,7 +436,24 @@ public class JMeterThread implements Run
 
                 // Perform the actual sample
                 currentSampler = sampler;
+                if (IMPLEMENTS_SAMPLE_STARTED) {
+                    for(SampleListener listener : pack.getSampleListeners()) {
+                        try {
+                            TestBeanHelper.prepare((TestElement) listener);
+                            listener.sampleStarted(null);
+                        } catch (RuntimeException e) {
+                            log.error("Detected problem in Listener: ", e);
+                            log.info("Continuing to process further listeners");
+                        }
+                    }                    
+                }
                 SampleResult result = sampler.sample(null); // TODO: remove this useless
Entry parameter
+                if (IMPLEMENTS_SAMPLE_STARTED) {
+                    for(SampleListener listener : pack.getSampleListeners()) {
+                        // We don't need to prepare these again here
+                        listener.sampleStopped(null);
+                    }                    
+                }
                 currentSampler = null;
 
                 // If we got any results, then perform processing on the result
@@ -452,7 +474,7 @@ public class JMeterThread implements Run
                     checkAssertions(pack.getAssertions(), result, threadContext);
                     // Do not send subsamples to listeners which receive the transaction
sample
                     List<SampleListener> sampleListeners = getSampleListeners(pack,
transactionPack, transactionSampler);
-                    notifyListeners(sampleListeners, result);
+                    notifyListeners(sampleListeners, result); // TODO could skip the TestBean
prepare here?
                     compiler.done(pack);
                     // Add the result as subsample of transaction if we are in a transaction
                     if(transactionSampler != null) {



Mime
View raw message