Exemple #1
0
        /**
         * Records a sample.
         *
         */
        public void AddSample(ExecuteResult res)
        {
            Int64 aTimeInMillis = res.GetTime();

            counter+=res.getSampleCount();
            errorCount += res.getErrorCount();

            Int64 startTime = res.getStartTime();
            Int64 endTime = res.getEndTime();

            if (firstTime > startTime)
            {
                // this is our first sample, set the start time to current timestamp
                firstTime = startTime;
            }

            // Always update the end time
            if (lastTime < endTime)
            {
                lastTime = endTime;
            }
            runningSum += aTimeInMillis;

            if (aTimeInMillis > max)
            {
                max = aTimeInMillis;
            }

            if (aTimeInMillis < min)
            {
                min = aTimeInMillis;
            }
        }
 public TransactionSampler(TransactionController controller, String name)
 {
     transactionController = controller;
     SetName(name); // ensure name is available for debugging
     transactionSampleResult = new ExecuteResult();
     transactionSampleResult.setSampleLabel(name);
     // Assume success
     transactionSampleResult.Success = true;
     transactionSampleResult.sampleStart();
 }
 public void addSubSamplerResult(ExecuteResult res)
 {
     // Another subsample for the transaction
     calls++;
     // The transaction fails if any sub sample fails
     if (!res.Success)
     {
         transactionSampleResult.Success = false;
         noFailingSamples++;
     }
     // Add the sub result to the transaction result
     transactionSampleResult.addSubResult(res);
     // Add current time to total for later use (exclude pause time)
     totalTime += res.GetTime();
 }
Exemple #4
0
 public void SetPreviousResult(ExecuteResult result)
 {
     this.previousResult = result;
 }
Exemple #5
0
 /**
  * Add a subresult to the collection without updating any parent fields.
  *
  * @param subResult
  */
 public void addRawSubResult(ExecuteResult subResult)
 {
     storeSubResult(subResult);
 }
Exemple #6
0
 public AssertionResult GetResult(ExecuteResult response)
 {
     AssertionResult result;
     result = EvaluateResponse(response);
     return result;
 }
Exemple #7
0
 /**
  * Add a subresult to the collection without updating any parent fields.
  *
  * @param subResult
  */
 public void addRawSubResult(ExecuteResult subResult)
 {
     storeSubResult(subResult);
 }
Exemple #8
0
 /**
  * Copy constructor.
  *
  * @param res existing sample result
  */
 public ExecuteResult(ExecuteResult res)
     : this()
 {
     allThreads = res.allThreads;//OK
     assertionResults = res.assertionResults;// TODO ??
     bytes = res.bytes;
     headersSize = res.headersSize;
     bodySize = res.bodySize;
     contentType = res.contentType;//OK
     dataEncoding = res.dataEncoding;//OK
     dataType = res.dataType;//OK
     endTime = res.endTime;//OK
     // files is created automatically, and applies per instance
     groupThreads = res.groupThreads;//OK
     idleTime = res.idleTime;
     isMon = res.isMon;
     label = res.label;//OK
     latency = res.latency;
     location = res.location;//OK
     parent = res.parent; // TODO ??
     pauseTime = res.pauseTime;
     requestHeaders = res.requestHeaders;//OK
     responseCode = res.responseCode;//OK
     responseData = res.responseData;//OK
     responseDataAsString = null;
     responseHeaders = res.responseHeaders;//OK
     responseMessage = res.responseMessage;//OK
     // Don't copy this; it is per instance resultFileName = res.resultFileName;
     sampleCount = res.sampleCount;
     samplerData = res.samplerData;
     //saveConfig = res.saveConfig;
     startTime = res.startTime;//OK
     stopTest = res.stopTest;
     stopTestNow = res.stopTestNow;
     stopThread = res.stopThread;
     startNextThreadLoop = res.startNextThreadLoop;
     subResults = res.subResults; // TODO ??
     Success = res.Success;//OK
     threadName = res.threadName;//OK
     time = res.time;
     timeStamp = res.timeStamp;
 }
Exemple #9
0
 /**
  * @param parent
  *            The parent to set.
  */
 public void setParent(ExecuteResult parent)
 {
     this.parent = parent;
 }
Exemple #10
0
 private void NotifyListeners(List<ExecutionListener> listeners, ExecuteResult result)
 {
     ExecutionEvent sampleEvent = new ExecutionEvent(result, threadGroup.GetName(), threadVars);
     notifier.notifyListeners(sampleEvent, listeners);
 }
Exemple #11
0
 private void CheckTestAssertions(List<Assertion> assertions, ExecuteResult parent, NetMeterContext threadContext)
 {
     foreach (Assertion assertion in assertions)
     {
         //TestBeanHelper.prepare((TestElement) assertion);
         if (assertion is AbstractScopedAssertion)
         {
             AbstractScopedAssertion scopedAssertion = (AbstractScopedAssertion) assertion;
             String scope = scopedAssertion.fetchScope();
             if (scopedAssertion.isScopeParent(scope) || scopedAssertion.isScopeAll(scope) || scopedAssertion.isScopeVariable(scope))
             {
                 ProcessTestAssertion(parent, assertion);
             }
             if (scopedAssertion.isScopeChildren(scope) || scopedAssertion.isScopeAll(scope))
             {
                 ExecuteResult[] children = parent.getSubResults();
                 Boolean childError = false;
                 foreach (ExecuteResult child in children)
                 {
                     ProcessTestAssertion(child, assertion);
                     if (!child.Success)
                     {
                         childError = true;
                     }
                 }
                 // If parent is OK, but child failed, add a message and flag the parent as failed
                 if (childError && parent.Success)
                 {
                     AssertionResult assertionResult = new AssertionResult(((AbstractTestElement)assertion).GetName());
                     assertionResult.setResultForFailure("One or more sub-samples failed");
                     parent.addAssertionResult(assertionResult);
                     parent.Success = false;
                 }
             }
         }
         else
         {
             ProcessTestAssertion(parent, assertion);
         }
     }
     threadContext.GetVariables().Add(LAST_SAMPLE_OK, parent.Success.ToString());
 }
Exemple #12
0
 /**
  * Only intended for use when loading results from a file.
  *
  * @param result
  * @param threadGroup
  * @param hostname
  */
 public ExecutionEvent(ExecuteResult result, String threadGroup, String hostname)
     : this(result, threadGroup, hostname, false)
 {
 }
Exemple #13
0
 /**
  * Contructor used for normal samples, saves variable values if any are defined.
  *
  * @param result
  * @param threadGroup name
  * @param jmvars Jmeter variables
  */
 public ExecutionEvent(ExecuteResult result, String threadGroup, NetMeterVariables jmvars)
     : this(result, threadGroup, jmvars, false)
 {
 }
Exemple #14
0
 /**
  * Creates SampleEvent without saving any variables.
  *
  * Use by Proxy and StatisticalSampleSender.
  *
  * @param result SampleResult
  * @param threadGroup name
  */
 public ExecutionEvent(ExecuteResult result, String threadGroup)
     : this(result, threadGroup, HOSTNAME, false)
 {
 }
Exemple #15
0
 /**
  * @param result
  * @param threadGroup
  * @param jmvars
  * @param isTransactionSampleEvent
  */
 public ExecutionEvent(ExecuteResult result, String threadGroup, NetMeterVariables jmvars, Boolean isTransactionSampleEvent)
     : this(result, threadGroup, HOSTNAME, isTransactionSampleEvent)
 {
     saveVars(jmvars);
 }
Exemple #16
0
 private void Init()
 {
     variables = null;
     previousResult = null;
     currentSampler = null;
     previousSampler = null;
     samplingStarted = false;
     threadNum = 0;
     nThread = null;
     isReinitSubControllers = false;
     samplerContext.Clear();
     restartNextLoop = false;
 }
Exemple #17
0
        /**
         * Read response from the input stream, converting to MD5 digest if the useMD5 property is set.
         *
         * For the MD5 case, the result byte count is set to the size of the original response.
         *
         * Closes the inputStream
         *
         * @param sampleResult
         * @param in input stream
         * @param length expected input length or zero
         * @return the response or the MD5 of the response
         * @throws IOException
         */
        public byte[] ReadResponse(ExecuteResult sampleResult, int length)
        {
            //try {
            //    byte[] readBuffer = new byte[8192]; // 8kB is the (max) size to have the latency ('the first packet')
            //    int bufferSize=32;// Enough for MD5

            //    MessageDigest md=null;
            //    boolean asMD5 = useMD5();
            //    if (asMD5) {
            //        try {
            //            md = MessageDigest.getInstance("MD5"); //$NON-NLS-1$
            //        } catch (NoSuchAlgorithmException e) {
            //            log.error("Should not happen - could not find MD5 digest", e);
            //            asMD5=false;
            //        }
            //    } else {
            //        if (length <= 0) {// may also happen if long value > int.max
            //            bufferSize = 4 * 1024;
            //        } else {
            //            bufferSize = length;
            //        }
            //    }
            //    ByteArrayOutputStream w = new ByteArrayOutputStream(bufferSize);
            //    int bytesRead = 0;
            //    int totalBytes = 0;
            //    boolean first = true;
            //    while ((bytesRead = in.read(readBuffer)) > -1) {
            //        if (first) {
            //            sampleResult.latencyEnd();
            //            first = false;
            //        }
            //        if (asMD5 && md != null) {
            //            md.update(readBuffer, 0 , bytesRead);
            //            totalBytes += bytesRead;
            //        } else {
            //            w.write(readBuffer, 0, bytesRead);
            //        }
            //    }
            //    if (first){ // Bug 46838 - if there was no data, still need to set latency
            //        sampleResult.latencyEnd();
            //    }
            //    in.close();
            //    w.flush();
            //    if (asMD5 && md != null) {
            //        byte[] md5Result = md.digest();
            //        w.write(JOrphanUtils.baToHexBytes(md5Result));
            //        sampleResult.setBytes(totalBytes);
            //    }
            //    w.close();
            //    return w.toByteArray();
            //} finally {
            //    IOUtils.closeQuietly(in);
            //}
            return null;
        }
Exemple #18
0
 private void ProcessTestAssertion(ExecuteResult result, Assertion assertion)
 {
     AssertionResult assertionResult;
     try
     {
         assertionResult = assertion.GetResult(result);
     }
     //catch (ThreadDeath e)
     //{
     //    throw e;
     //}
     //catch (Error e)
     //{
     //    log.error("Error processing Assertion ",e);
     //    assertionResult = new AssertionResult("Assertion failed! See log file.");
     //    assertionResult.setError(true);
     //    assertionResult.setFailureMessage(e.toString());
     //}
     catch (Exception ex)
     {
         //log.error("Exception processing Assertion ",ex);
         assertionResult = new AssertionResult("Assertion failed! See log file.");
         assertionResult.setError(true);
         assertionResult.setFailureMessage(ex.Message);
     }
     result.Success = result.Success && !(assertionResult.isError() || assertionResult.isFailure());
     result.addAssertionResult(assertionResult);
 }
Exemple #19
0
        private ExecutionEvent(ExecuteResult result, String threadGroup, String hostname, Boolean isTransactionSampleEvent)
        {
            String hn="";
            try
            {
                hn = Dns.GetHostName();
            }
            catch (SocketException e)
            {
                log.Error("Cannot obtain local host name "+e);
            }
            HOSTNAME = hn;

            String vars = NetMeterUtils.getProperty(SAMPLE_VARIABLES);
            variableNames=vars != null ? vars.Split(',') : new String[0];
            varCount = variableNames.Length;

            if (varCount > 0)
            {
                log.Info(varCount + " sample_variables have been declared: "+vars);
            }
            this.result = result;
            this.threadGroup = threadGroup;
            this.hostname = hostname;
            values = new String[variableNames.Length];
            this.isTransaction = isTransactionSampleEvent;
        }
Exemple #20
0
 /**
  * Creates SampleEvent without saving any variables.
  *
  * Use by Proxy and StatisticalSampleSender.
  *
  * @param result SampleResult
  * @param threadGroup name
  */
 public ExecutionEvent(ExecuteResult result, String threadGroup)
     : this(result, threadGroup, HOSTNAME, false)
 {
 }
Exemple #21
0
 /**
  * Add a subresult read from a results file.
  *
  * As for addSubResult(), except that the fields don't need to be accumulated
  *
  * @param subResult
  */
 public void storeSubResult(ExecuteResult subResult)
 {
     if (subResults == null)
     {
         subResults = new List<ExecuteResult>();
     }
     subResults.Add(subResult);
     subResult.setParent(this);
 }
Exemple #22
0
 /**
  * Contructor used for normal samples, saves variable values if any are defined.
  *
  * @param result
  * @param threadGroup name
  * @param jmvars Jmeter variables
  */
 public ExecutionEvent(ExecuteResult result, String threadGroup, NetMeterVariables jmvars)
     : this(result, threadGroup, jmvars, false)
 {
 }
Exemple #23
0
 /**
  * Create a sample with specific start and end times for test purposes, but
  * don't allow the times to be changed later
  *
  * (used by StatVisualizerModel.Test)
  *
  * @param start
  *            start time
  * @param end
  *            end time
  */
 public static ExecuteResult createTestSample(Int64 start, Int64 end)
 {
     ExecuteResult res = new ExecuteResult();
     res.setStartTime(start);
     res.setEndTime(end);
     return res;
 }
Exemple #24
0
 /**
  * Only intended for use when loading results from a file.
  *
  * @param result
  * @param threadGroup
  * @param hostname
  */
 public ExecutionEvent(ExecuteResult result, String threadGroup, String hostname)
     : this(result, threadGroup, hostname, false)
 {
 }
Exemple #25
0
        /**
         * Add a subresult and adjust the parent byte count and end-time.
         *
         * @param subResult
         */
        public void addSubResult(ExecuteResult subResult)
        {
            String tn = getThreadName();
            if (0 == tn.Length)
            {
                tn = Thread.CurrentThread.Name;//TODO do this more efficiently
                this.SetThreadName(tn);
            }
            subResult.SetThreadName(tn); // TODO is this really necessary?

            // Extend the time to the end of the added sample
            setEndTime(Math.Max(getEndTime(), subResult.getEndTime() + nanoTimeOffset - subResult.nanoTimeOffset)); // Bug 51855
            // Include the byte count for the added sample
            setBytes(getBytes() + subResult.getBytes());
            setHeadersSize(getHeadersSize() + subResult.getHeadersSize());
            setBodySize(getBodySize() + subResult.getBodySize());
            addRawSubResult(subResult);
        }
Exemple #26
0
 /**
  * @param result
  * @param threadGroup
  * @param jmvars
  * @param isTransactionSampleEvent
  */
 public ExecutionEvent(ExecuteResult result, String threadGroup, NetMeterVariables jmvars, Boolean isTransactionSampleEvent)
     : this(result, threadGroup, HOSTNAME, isTransactionSampleEvent)
 {
     saveVars(jmvars);
 }
Exemple #27
0
        private AssertionResult EvaluateResponse(ExecuteResult response)
        {
            AssertionResult result = new AssertionResult();

            return result;
        }
Exemple #28
0
 /**
  * @param parent
  *            The parent to set.
  */
 public void setParent(ExecuteResult parent)
 {
     this.parent = parent;
 }