Ejemplo n.º 1
0
 /**
  * Get the SampleListeners for the sampler. Listeners who receive transaction sample
  * will not be in this list.
  *
  * @param samplePack
  * @param transactionPack
  * @param transactionSampler
  * @return the listeners who should receive the sample result
  */
 private List <ExecutionListener> GetSampleListeners(ExecutionPackage samplePack)
 {
     return(samplePack.GetSampleListeners());
     //List<SampleListener> sampleListeners = samplePack.GetSampleListeners();
     //// Do not send subsamples to listeners which receive the transaction sample
     //if(transactionSampler != null)
     //{
     //    List<SampleListener> onlySubSamplerListeners = new List<SampleListener>();
     //    List<SampleListener> transListeners = transactionPack.GetSampleListeners();
     //    foreach(SampleListener listener in sampleListeners) {
     //        // Check if this instance is present in transaction listener list
     //        Boolean found = false;
     //        foreach(SampleListener trans in transListeners)
     //        {
     //            // Check for the same instance
     //            if(trans == listener)
     //            {
     //                found = true;
     //                break;
     //            }
     //        }
     //        if(!found) {
     //            onlySubSamplerListeners.Add(listener);
     //        }
     //    }
     //    sampleListeners = onlySubSamplerListeners;
     //}
     //return sampleListeners;
 }
Ejemplo n.º 2
0
        /**
         * Configures Transaction Sampler from SamplePackage extracted from Test plan and returns it
         * @param transactionSampler {@link TransactionSampler}
         * @return {@link SamplePackage}
         */
        public ExecutionPackage ConfigureTransactionSampler(TransactionSampler transactionSampler)
        {
            TransactionController controller = transactionSampler.getTransactionController();
            ExecutionPackage      pack       = null;

            if (transactionControllerConfigMap.TryGetValue(controller, out pack))
            {
                pack.SetSampler(transactionSampler);
            }
            return(pack);
        }
Ejemplo n.º 3
0
 /**
  * Reset pack to its initial state
  * @param pack
  */
 public void Done(ExecutionPackage pack)
 {
     pack.RecoverRunningVersion();
 }
Ejemplo n.º 4
0
        /**
         * Process the current sampler, handling transaction samplers.
         *
         * @param current sampler
         * @param parent sampler
         * @param threadContext
         * @return SampleResult if a transaction was processed
         */
        private ExecuteResult ProcessTestAgent(TestAgent current, TestAgent parent, NetMeterContext threadContext)
        {
            ExecuteResult transactionResult = null;

            try
            {
                // Check if we have a sampler to sample
                if (current != null)
                {
                    threadContext.SetCurrentSampler(current);
                    // Get the sampler ready to sample
                    ExecutionPackage pack = compiler.ConfigureSampler(current);
                    // runPreProcessors(pack.getPreProcessors());

                    // Hack: save the package for any transaction controllers
                    threadVars.PutObject(PACKAGE_OBJECT, pack);

                    //delay(pack.getTimers());
                    TestAgent sampler = pack.GetSampler();
                    sampler.SetThreadContext(threadContext);
                    // TODO should this set the thread names for all the subsamples?
                    // might be more efficient than fetching the name elsewehere
                    sampler.SetThreadName(threadName);
                    // TestBeanHelper.prepare(sampler);

                    // Perform the actual sample
                    currentSampler = sampler;
                    ExecuteResult result = sampler.Execute(null);
                    currentSampler = null;
                    // TODO: remove this useless Entry parameter

                    // If we got any results, then perform processing on the result
                    if (result != null)
                    {
                        result.SetGroupThreads(threadGroup.GetNumberOfThreads());
                        result.SetAllThreads(NetMeterContextManager.GetNumberOfThreads());
                        result.SetThreadName(threadName);
                        threadContext.SetPreviousResult(result);
                        RunPostProcessors(pack.GetPostProcessors());
                        CheckTestAssertions(pack.GetAssertions(), result, threadContext);
                        // Do not send subsamples to listeners which receive the transaction sample
                        List <ExecutionListener> sampleListeners = GetSampleListeners(pack);
                        NotifyListeners(sampleListeners, result);
                        compiler.Done(pack);

                        // Check if thread or test should be stopped
                        if (result.isStopThread() || (!result.Success && onErrorStopThread))
                        {
                            StopThread();
                        }
                        if (result.isStopTest() || (!result.Success && onErrorStopTest))
                        {
                            StopTest();
                        }
                        if (result.isStopTestNow() || (!result.Success && onErrorStopTestNow))
                        {
                            StopTestNow();
                        }
                        if (result.isStartNextThreadLoop())
                        {
                            threadContext.restartNextLoop = true;
                        }
                    }
                    else
                    {
                        compiler.Done(pack); // Finish up
                    }
                }
                if (scheduler)
                {
                    // checks the scheduler to stop the iteration
                    StopScheduler();
                }
            }
            catch (Exception e)
            {
                if (current != null)
                {
                    log.Error("Error while processing sampler '" + current.GetName() + "' :", e);
                }
                else
                {
                    log.Error("", e);
                }
                StopThread();
            }
            return(transactionResult);
        }