You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by fs...@apache.org on 2020/03/10 19:43:58 UTC

[jmeter] 01/02: Recurse into sub samplers more deeply when checking assertions

This is an automated email from the ASF dual-hosted git repository.

fschumacher pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jmeter.git

commit 1a2f24ab25f2a571f7bcb599b4be692eb47dde92
Author: Felix Schumacher <fe...@internetallee.de>
AuthorDate: Sun Mar 8 15:26:25 2020 +0100

    Recurse into sub samplers more deeply when checking assertions
    
    With this change we recurse up to three levels into sub results of SampleResults
    instead of only one level deep.
    
    This helps in case of parallel downloads of embedded elements of a web page, which
    get stored as sub-sub-sampleresults.
    
    Bugzilla Id: 64196
---
 .../org/apache/jmeter/threads/JMeterThread.java    | 38 +++++++++++++---------
 xdocs/changes.xml                                  |  1 +
 2 files changed, 24 insertions(+), 15 deletions(-)

diff --git a/src/core/src/main/java/org/apache/jmeter/threads/JMeterThread.java b/src/core/src/main/java/org/apache/jmeter/threads/JMeterThread.java
index b730df8..af8e8bf 100644
--- a/src/core/src/main/java/org/apache/jmeter/threads/JMeterThread.java
+++ b/src/core/src/main/java/org/apache/jmeter/threads/JMeterThread.java
@@ -879,21 +879,7 @@ public class JMeterThread implements Runnable, Interruptible {
                 }
                 if (scopedAssertion.isScopeChildren(scope)
                         || scopedAssertion.isScopeAll(scope)) {
-                    SampleResult[] children = parent.getSubResults();
-                    boolean childError = false;
-                    for (SampleResult childSampleResult : children) {
-                        processAssertion(childSampleResult, assertion);
-                        if (!childSampleResult.isSuccessful()) {
-                            childError = true;
-                        }
-                    }
-                    // If parent is OK, but child failed, add a message and flag the parent as failed
-                    if (childError && parent.isSuccessful()) {
-                        AssertionResult assertionResult = new AssertionResult(((AbstractTestElement) assertion).getName());
-                        assertionResult.setResultForFailure("One or more sub-samples failed");
-                        parent.addAssertionResult(assertionResult);
-                        parent.setSuccessful(false);
-                    }
+                    recurseAssertionChecks(parent, assertion, 3);
                 }
             } else {
                 processAssertion(parent, assertion);
@@ -902,6 +888,28 @@ public class JMeterThread implements Runnable, Interruptible {
         threadContext.getVariables().put(LAST_SAMPLE_OK, Boolean.toString(parent.isSuccessful()));
     }
 
+    private void recurseAssertionChecks(SampleResult parent, Assertion assertion, int level) {
+        if (level < 0) {
+            return;
+        }
+        SampleResult[] children = parent.getSubResults();
+        boolean childError = false;
+        for (SampleResult childSampleResult : children) {
+            processAssertion(childSampleResult, assertion);
+            recurseAssertionChecks(childSampleResult, assertion, level - 1);
+            if (!childSampleResult.isSuccessful()) {
+                childError = true;
+            }
+        }
+        // If parent is OK, but child failed, add a message and flag the parent as failed
+        if (childError && parent.isSuccessful()) {
+            AssertionResult assertionResult = new AssertionResult(((AbstractTestElement) assertion).getName());
+            assertionResult.setResultForFailure("One or more sub-samples failed");
+            parent.addAssertionResult(assertionResult);
+            parent.setSuccessful(false);
+        }
+    }
+
     private void processAssertion(SampleResult result, Assertion assertion) {
         AssertionResult assertionResult;
         try {
diff --git a/xdocs/changes.xml b/xdocs/changes.xml
index f666d2e..7d56b01 100644
--- a/xdocs/changes.xml
+++ b/xdocs/changes.xml
@@ -180,6 +180,7 @@ to view the last release notes of version 5.2.1.
 <ul>
     <li><bug>64091</bug>Precise Throughput Timer might produce less samples when low test duration is used</li>
     <li><bug>64142</bug>Presence of DebugPostProcessor in Test plan breaks ActiveThread Over time in report due to missing information</li>
+    <li><bug>64196</bug>Recurse into sub samplers more deeply when checking assertions</li>
 </ul>
 
 <h3>Functions</h3>