From commits-return-818-apmail-jmeter-commits-archive=jmeter.apache.org@jmeter.apache.org Sat Mar 24 23:22:54 2012 Return-Path: X-Original-To: apmail-jmeter-commits-archive@minotaur.apache.org Delivered-To: apmail-jmeter-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 9962D9596 for ; Sat, 24 Mar 2012 23:22:54 +0000 (UTC) Received: (qmail 91121 invoked by uid 500); 24 Mar 2012 23:22:54 -0000 Delivered-To: apmail-jmeter-commits-archive@jmeter.apache.org Received: (qmail 91099 invoked by uid 500); 24 Mar 2012 23:22:54 -0000 Mailing-List: contact commits-help@jmeter.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@jmeter.apache.org Delivered-To: mailing list commits@jmeter.apache.org Received: (qmail 91092 invoked by uid 99); 24 Mar 2012 23:22:54 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 24 Mar 2012 23:22:54 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 24 Mar 2012 23:22:50 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 8EF832388847 for ; Sat, 24 Mar 2012 23:22:29 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1304962 - in /jmeter/trunk: src/core/org/apache/jmeter/control/TransactionController.java src/core/org/apache/jmeter/threads/JMeterThread.java xdocs/changes.xml Date: Sat, 24 Mar 2012 23:22:29 -0000 To: commits@jmeter.apache.org From: pmouawad@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120324232229.8EF832388847@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: pmouawad Date: Sat Mar 24 23:22:29 2012 New Revision: 1304962 URL: http://svn.apache.org/viewvc?rev=1304962&view=rev Log: Bug 52968 - Option Start Next Loop in Thread Group does not mark parent Transaction Sampler in error when an error occurs Modified: jmeter/trunk/src/core/org/apache/jmeter/control/TransactionController.java jmeter/trunk/src/core/org/apache/jmeter/threads/JMeterThread.java jmeter/trunk/xdocs/changes.xml Modified: jmeter/trunk/src/core/org/apache/jmeter/control/TransactionController.java URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/control/TransactionController.java?rev=1304962&r1=1304961&r2=1304962&view=diff ============================================================================== --- jmeter/trunk/src/core/org/apache/jmeter/control/TransactionController.java (original) +++ jmeter/trunk/src/core/org/apache/jmeter/control/TransactionController.java Sat Mar 24 23:22:29 2012 @@ -26,6 +26,7 @@ import org.apache.jmeter.samplers.Sample import org.apache.jmeter.samplers.Sampler; import org.apache.jmeter.testelement.property.BooleanProperty; import org.apache.jmeter.threads.JMeterContext; +import org.apache.jmeter.threads.JMeterContextService; import org.apache.jmeter.threads.JMeterThread; import org.apache.jmeter.threads.JMeterVariables; import org.apache.jmeter.threads.ListenerNotifier; @@ -43,33 +44,52 @@ import org.apache.log.Logger; */ public class TransactionController extends GenericController implements SampleListener, Controller, Serializable { private static final long serialVersionUID = 233L; + + private static final String TRUE = Boolean.toString(true); // i.e. "true" + private static final String PARENT = "TransactionController.parent";// $NON-NLS-1$ + + private final static String INCLUDE_TIMERS = "TransactionController.includeTimers";// $NON-NLS-1$ + private static final Logger log = LoggingManager.getLoggerForClass(); + /** + * Only used in parent Mode + */ private transient TransactionSampler transactionSampler; - + + /** + * Only used in NON parent Mode + */ private transient ListenerNotifier lnf; + /** + * Only used in NON parent Mode + */ private transient SampleResult res; - + + /** + * Only used in NON parent Mode + */ private transient int calls; - + + /** + * Only used in NON parent Mode + */ private transient int noFailingSamples; /** * Cumulated pause time to excluse timer and post/pre processor times + * Only used in NON parent Mode */ private transient long pauseTime; /** * Previous end time + * Only used in NON parent Mode */ private transient long prevEndTime; - private static final String PARENT = "TransactionController.parent";// $NON-NLS-1$ - - private final static String INCLUDE_TIMERS = "TransactionController.includeTimers";// $NON-NLS-1$ - /** * Creates a Transaction Controller */ @@ -173,32 +193,12 @@ public class TransactionController exten { if (res != null) { res.setIdleTime(pauseTime+res.getIdleTime()); - res.sampleEnd(); + res.sampleEnd(); res.setResponseMessage("Number of samples in transaction : " + calls + ", number of failing samples : " + noFailingSamples); if(res.isSuccessful()) { res.setResponseCodeOK(); } - - // TODO could these be done earlier (or just once?) - JMeterContext threadContext = getThreadContext(); - JMeterVariables threadVars = threadContext.getVariables(); - - SamplePackage pack = (SamplePackage) threadVars.getObject(JMeterThread.PACKAGE_OBJECT); - if (pack == null) { - // If child of TransactionController is a ThroughputController and TPC does - // not sample its children, then we will have this - // TODO Should this be at warn level ? - log.warn("Could not fetch SamplePackage"); - } else { - SampleEvent event = new SampleEvent(res, threadContext.getThreadGroup().getName(),threadVars, true); - // We must set res to null now, before sending the event for the transaction, - // so that we can ignore that event in our sampleOccured method - res = null; - // bug 50032 - if (!getThreadContext().isReinitializingSubControllers()) { - lnf.notifyListeners(event, pack.getSampleListeners()); - } - } + notifyListeners(); } } else { @@ -209,6 +209,52 @@ public class TransactionController exten return returnValue; } + /** + * @see org.apache.jmeter.control.GenericController#triggerEndOfLoop() + */ + @Override + public void triggerEndOfLoop() { + if(!isParent()) { + if (res != null) { + res.setIdleTime(pauseTime+res.getIdleTime()); + res.sampleEnd(); + res.setSuccessful(TRUE.equals(JMeterContextService.getContext().getVariables().get(JMeterThread.LAST_SAMPLE_OK))); + res.setResponseMessage("Number of samples in transaction : " + calls + ", number of failing samples : " + noFailingSamples); + notifyListeners(); + } + } else { + transactionSampler.setTransactionDone(); + // This transaction is done + transactionSampler = null; + } + super.triggerEndOfLoop(); + } + + /** + * Create additional SampleEvent in NON Parent Mode + */ + protected void notifyListeners() { + // TODO could these be done earlier (or just once?) + JMeterContext threadContext = getThreadContext(); + JMeterVariables threadVars = threadContext.getVariables(); + SamplePackage pack = (SamplePackage) threadVars.getObject(JMeterThread.PACKAGE_OBJECT); + if (pack == null) { + // If child of TransactionController is a ThroughputController and TPC does + // not sample its children, then we will have this + // TODO Should this be at warn level ? + log.warn("Could not fetch SamplePackage"); + } else { + SampleEvent event = new SampleEvent(res, threadContext.getThreadGroup().getName(),threadVars, true); + // We must set res to null now, before sending the event for the transaction, + // so that we can ignore that event in our sampleOccured method + res = null; + // bug 50032 + if (!getThreadContext().isReinitializingSubControllers()) { + lnf.notifyListeners(event, pack.getSampleListeners()); + } + } + } + public void sampleOccurred(SampleEvent se) { if (!isParent()) { // Check if we are still sampling our children Modified: jmeter/trunk/src/core/org/apache/jmeter/threads/JMeterThread.java URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/threads/JMeterThread.java?rev=1304962&r1=1304961&r2=1304962&view=diff ============================================================================== --- jmeter/trunk/src/core/org/apache/jmeter/threads/JMeterThread.java (original) +++ jmeter/trunk/src/core/org/apache/jmeter/threads/JMeterThread.java Sat Mar 24 23:22:29 2012 @@ -271,7 +271,7 @@ public class JMeterThread implements Run process_sampler(sam, null, threadContext); if(onErrorStartNextLoop || threadContext.isRestartNextLoop()) { if(threadContext.isRestartNextLoop()) { - triggerEndOfLoopOnParentControllers(sam); + triggerEndOfLoopOnParentControllers(sam, threadContext); sam = null; threadContext.getVariables().put(LAST_SAMPLE_OK, TRUE); threadContext.setRestartNextLoop(false); @@ -281,7 +281,7 @@ public class JMeterThread implements Run if(log.isDebugEnabled()) { log.debug("StartNextLoop option is on, Last sample failed, starting next loop"); } - triggerEndOfLoopOnParentControllers(sam); + triggerEndOfLoopOnParentControllers(sam, threadContext); sam = null; threadContext.getVariables().put(LAST_SAMPLE_OK, TRUE); } else { @@ -333,10 +333,18 @@ public class JMeterThread implements Run /** * Trigger end of loop on parent controllers up to Thread Group * @param sam Sampler Base sampler + * @param threadContext */ - private void triggerEndOfLoopOnParentControllers(Sampler sam) { + private void triggerEndOfLoopOnParentControllers(Sampler sam, JMeterContext threadContext) { // Find parent controllers of current sampler - FindTestElementsUpToRootTraverser pathToRootTraverser = new FindTestElementsUpToRootTraverser(sam); + FindTestElementsUpToRootTraverser pathToRootTraverser=null; + TransactionSampler transactionSampler = null; + if(sam instanceof TransactionSampler) { + transactionSampler = (TransactionSampler) sam; + pathToRootTraverser = new FindTestElementsUpToRootTraverser((transactionSampler).getTransactionController()); + } else { + pathToRootTraverser = new FindTestElementsUpToRootTraverser(sam); + } testTree.traverse(pathToRootTraverser); List controllersToReinit = pathToRootTraverser.getControllersToRoot(); @@ -351,6 +359,9 @@ public class JMeterThread implements Run parentController.triggerEndOfLoop(); } } + if(transactionSampler!=null) { + process_sampler(transactionSampler, null, threadContext); + } } /** Modified: jmeter/trunk/xdocs/changes.xml URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1304962&r1=1304961&r2=1304962&view=diff ============================================================================== --- jmeter/trunk/xdocs/changes.xml (original) +++ jmeter/trunk/xdocs/changes.xml Sat Mar 24 23:22:29 2012 @@ -103,6 +103,7 @@ Graph Full Results Listener has been rem

Controllers

    +
  • Bug 52968 - Option Start Next Loop in Thread Group does not mark parent Transaction Sampler in error when an error occurs

Listeners