jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmoua...@apache.org
Subject svn commit: r1833732 - in /jmeter/trunk: src/core/org/apache/jmeter/reporters/ResultCollector.java src/core/org/apache/jmeter/save/CSVSaveService.java xdocs/changes.xml
Date Mon, 18 Jun 2018 16:07:52 GMT
Author: pmouawad
Date: Mon Jun 18 16:07:51 2018
New Revision: 1833732

URL: http://svn.apache.org/viewvc?rev=1833732&view=rev
Log:
Bug 62470 - CSV Output : Enable logging of sub results when jmeter.save.saveservice.subresults=true

Contributed by UbikLoadPack support
Bugzilla Id: 62470

Modified:
    jmeter/trunk/src/core/org/apache/jmeter/reporters/ResultCollector.java
    jmeter/trunk/src/core/org/apache/jmeter/save/CSVSaveService.java
    jmeter/trunk/xdocs/changes.xml

Modified: jmeter/trunk/src/core/org/apache/jmeter/reporters/ResultCollector.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/reporters/ResultCollector.java?rev=1833732&r1=1833731&r2=1833732&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/reporters/ResultCollector.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/reporters/ResultCollector.java Mon Jun 18 16:07:51
2018
@@ -552,8 +552,7 @@ public class ResultCollector extends Abs
                     if (config.saveAsXml()) {
                         SaveService.saveSampleResult(event, out);
                     } else { // !saveAsXml
-                        String savee = CSVSaveService.resultToDelimitedString(event);
-                        out.println(savee);
+                        CSVSaveService.saveSampleResult(event, out);
                     }
                 } catch (Exception err) {
                     log.error("Error trying to record a sample", err); // should throw exception
back to caller

Modified: jmeter/trunk/src/core/org/apache/jmeter/save/CSVSaveService.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/save/CSVSaveService.java?rev=1833732&r1=1833731&r2=1833732&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/save/CSVSaveService.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/save/CSVSaveService.java Mon Jun 18 16:07:51 2018
@@ -25,6 +25,7 @@ import java.io.FileWriter;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
+import java.io.PrintWriter;
 import java.io.Reader;
 import java.io.StringReader;
 import java.io.Writer;
@@ -779,24 +780,39 @@ public final class CSVSaveService {
             return sb.toString();
         }
     }
-
+    
+    /**
+     * Convert a result into a string, where the fields of the result are
+     * separated by a specified String.
+     * 
+     * @param event
+     *            the sample event to be converted
+     * @param delimiter
+     *            the separation string
+     * @return the separated value representation of the result
+     */
+    public static String resultToDelimitedString(SampleEvent event,
+            final String delimiter) {
+        return resultToDelimitedString(event, event.getResult(), event.getResult().getSaveConfig(),
delimiter);
+    }
+    
     /**
      * Convert a result into a string, where the fields of the result are
      * separated by a specified String.
      * 
      * @param event
      *            the sample event to be converted
+     * @param sample {@link SampleResult} to log
+     * @param saveConfig {@link SampleSaveConfiguration} to use for logging
      * @param delimiter
      *            the separation string
      * @return the separated value representation of the result
      */
     public static String resultToDelimitedString(SampleEvent event,
+            SampleResult sample,
+            SampleSaveConfiguration saveConfig,
             final String delimiter) {
         StringQuoter text = new StringQuoter(delimiter.charAt(0));
-
-        SampleResult sample = event.getResult();
-        SampleSaveConfiguration saveConfig = sample.getSaveConfig();
-
         if (saveConfig.saveTimestamp()) {
             if (saveConfig.printMilliseconds()) {
                 text.append(sample.getTimeStamp());
@@ -884,7 +900,7 @@ public final class CSVSaveService {
         }
 
         if (saveConfig.saveIdleTime()) {
-            text.append(event.getResult().getIdleTime());
+            text.append(sample.getIdleTime());
         }
 
         if (saveConfig.saveConnectTime()) {
@@ -1080,4 +1096,23 @@ public final class CSVSaveService {
             throws IOException {
         return csvReadFile(new BufferedReader(new StringReader(line)), delim);
     }
+
+    /**
+     * @param event {@link SampleEvent}
+     * @param out {@link PrintWriter} to which samples will be written
+     */
+    public static void saveSampleResult(SampleEvent event, PrintWriter out) {
+        SampleSaveConfiguration saveConfiguration = event.getResult().getSaveConfig();
+        String delimiter = saveConfiguration.getDelimiter();
+        String savee = resultToDelimitedString(event, event.getResult(), saveConfiguration,
delimiter);
+        out.println(savee);
+        
+        if(saveConfiguration.saveSubresults()) {
+            SampleResult result = event.getResult();
+            for (SampleResult subResult : result.getSubResults()) {
+                savee = resultToDelimitedString(event, subResult, saveConfiguration, delimiter);
+                out.println(savee);
+            }
+        }
+    }
 }

Modified: jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1833732&r1=1833731&r2=1833732&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml [utf-8] (original)
+++ jmeter/trunk/xdocs/changes.xml [utf-8] Mon Jun 18 16:07:51 2018
@@ -142,6 +142,7 @@ this behaviour, set <code>httpclient.res
   <li><bug>62234</bug>Search/Replace Feature : Enhance UX and add Replace/Next/Previous/Replace
&amp; Find features. Contributed by Ubik Load Pack (support at ubikloadpack.com)</li>
   <li><bug>62238</bug>Add ability to Switch to next iteration of Current
Loop. Contributed by Ubik Load Pack (support at ubikloadpack.com)</li>
   <li><bug>62239</bug>Add ability to Break Current Loop</li>
+  <li><bug>62470</bug>CSV Output : Enable logging of sub results when <code>jmeter.save.saveservice.subresults=true</code>.
Contributed by Ubik Load Pack (support at ubikloadpack.com)</li>
   <li><bug>62065</bug>Use Maven artifact for JAF Module instead of embedded
module</li>
   <li><pr>379</pr> Improve chinese translations. Contributed by XmeterNet</li>
   <li><bug>61714</bug>Update Real-time results documentation</li>



Mime
View raw message