You are viewing a plain text version of this content. The canonical link for it is here.
Posted to devnull@infra.apache.org by vl...@apache.org on 2019/06/08 18:42:30 UTC
[jmeter] 26/47: Bug 43450 (partial fix) - Allow SampleCount to be
saved/restored from CSV files
This is an automated email from the ASF dual-hosted git repository.
vladimirsitnikov pushed a commit to annotated tag v2_3
in repository https://gitbox.apache.org/repos/asf/jmeter.git
commit 38303130810afbb4665a53b6d451ce85ba60ff3c
Author: Sebastian Bazley <se...@apache.org>
AuthorDate: Sat Sep 22 00:12:06 2007 +0000
Bug 43450 (partial fix) - Allow SampleCount to be saved/restored from CSV files
git-svn-id: https://svn.apache.org/repos/asf/jakarta/jmeter/branches/rel-2-2@578333 13f79535-47bb-0310-9956-ffa450edef68
Former-commit-id: 3fec648474f8c91903b85187867663c1f01b8bc7
---
bin/jmeter.properties | 1 +
.../apache/jmeter/resources/messages.properties | 1 +
.../jmeter/samplers/SampleSaveConfiguration.java | 23 ++++++++++++++++++--
.../org/apache/jmeter/save/OldSaveService.java | 25 +++++++++++++++++++++-
.../SampleSaveConfigurationConverter.java | 5 +++++
xdocs/changes.xml | 1 +
6 files changed, 53 insertions(+), 3 deletions(-)
diff --git a/bin/jmeter.properties b/bin/jmeter.properties
index a25d9c5..18f0f79 100644
--- a/bin/jmeter.properties
+++ b/bin/jmeter.properties
@@ -273,6 +273,7 @@ log_level.jorphan=INFO
#jmeter.save.saveservice.url=false
#jmeter.save.saveservice.filename=false
#jmeter.save.saveservice.thread_counts=false
+#jmeter.save.saveservice.sample_count=false
# Timestamp format
# legitimate values: none, ms, or a format suitable for SimpleDateFormat
diff --git a/src/core/org/apache/jmeter/resources/messages.properties b/src/core/org/apache/jmeter/resources/messages.properties
index 663586e..a11b8b2 100644
--- a/src/core/org/apache/jmeter/resources/messages.properties
+++ b/src/core/org/apache/jmeter/resources/messages.properties
@@ -634,6 +634,7 @@ save_responseheaders=Save Response Headers
save_samplerdata=Save Sampler Data
save_subresults=Save Sub Results
save_success=Save Success
+save_samplecount=Save Sample Count
save_threadcounts=Save Active Thread Counts
save_threadname=Save Thread Name
save_time=Save Elapsed Time
diff --git a/src/core/org/apache/jmeter/samplers/SampleSaveConfiguration.java b/src/core/org/apache/jmeter/samplers/SampleSaveConfiguration.java
index 19566b8..abd9cb1 100644
--- a/src/core/org/apache/jmeter/samplers/SampleSaveConfiguration.java
+++ b/src/core/org/apache/jmeter/samplers/SampleSaveConfiguration.java
@@ -37,7 +37,7 @@ import org.apache.jmeter.util.JMeterUtils;
* - clone s.xyz = xyz
* - setXyz(boolean)
* - saveXyz()
- * - update SampleSaveConfigurationConverter to add new field
+ * - update SampleSaveConfigurationConverter to add new fields to marshall() and shouldSerialiseMember()
* - update SampleResultConverter and/or HTTPSampleConverter
* - update CSV routines in OldSaveService
* - update messages.properties to add save_xyz entry
@@ -56,7 +56,7 @@ import org.apache.jmeter.util.JMeterUtils;
*
*/
public class SampleSaveConfiguration implements Cloneable, Serializable {
- private static final long serialVersionUID = 5;
+ private static final long serialVersionUID = 6L;
// ---------------------------------------------------------------------
// PROPERTY FILE CONSTANTS
@@ -197,6 +197,8 @@ public class SampleSaveConfiguration implements Cloneable, Serializable {
private static final String SAVE_THREAD_COUNTS = "jmeter.save.saveservice.thread_counts"; // $NON_NLS-1$
+ private static final String SAVE_SAMPLE_COUNT = "jmeter.save.saveservice.sample_count"; // $NON_NLS-1$
+
// N.B. Remember to update the equals and hashCode methods when adding new variables.
// Initialise values from properties
@@ -211,6 +213,8 @@ public class SampleSaveConfiguration implements Cloneable, Serializable {
private boolean url = _url, bytes = _bytes , fileName = _fileName;
private boolean threadCounts = _threadCounts;
+
+ private boolean sampleCount = _sampleCount;
// Does not appear to be used (yet)
private int assertionsResultsToSave = _assertionsResultsToSave;
@@ -256,6 +260,8 @@ public class SampleSaveConfiguration implements Cloneable, Serializable {
private static final boolean _threadCounts;
+ private static final boolean _sampleCount;
+
private static final DateFormat _formatter;
/**
@@ -342,6 +348,8 @@ public class SampleSaveConfiguration implements Cloneable, Serializable {
}
_threadCounts=TRUE.equalsIgnoreCase(props.getProperty(SAVE_THREAD_COUNTS, FALSE));
+
+ _sampleCount=TRUE.equalsIgnoreCase(props.getProperty(SAVE_SAMPLE_COUNT, FALSE));
}
// Don't save this, as not settable via GUI
@@ -382,6 +390,7 @@ public class SampleSaveConfiguration implements Cloneable, Serializable {
subresults = value;
success = value;
threadCounts = value;
+ sampleCount = value;
threadName = value;
time = value;
timestamp = value;
@@ -442,6 +451,7 @@ public class SampleSaveConfiguration implements Cloneable, Serializable {
s.url == url &&
s.bytes == bytes &&
s.fileName == fileName &&
+ s.sampleCount == sampleCount &&
s.threadCounts == threadCounts;
boolean stringValues = false;
@@ -486,6 +496,7 @@ public class SampleSaveConfiguration implements Cloneable, Serializable {
hash = 31 * hash + (threadCounts ? 1 : 0);
hash = 31 * hash + (delimiter != null ? delimiter.hashCode() : 0);
hash = 31 * hash + (formatter != null ? formatter.hashCode() : 0);
+ hash = 31 * hash + (sampleCount ? 1 : 0);
return hash;
}
@@ -687,6 +698,14 @@ public class SampleSaveConfiguration implements Cloneable, Serializable {
this.threadCounts = save;
}
+ public boolean saveSampleCount() {
+ return sampleCount;
+ }
+
+ public void setSampleCount(boolean save) {
+ this.sampleCount = save;
+ }
+
///////////////// End of standard field accessors /////////////////////
/**
diff --git a/src/core/org/apache/jmeter/save/OldSaveService.java b/src/core/org/apache/jmeter/save/OldSaveService.java
index 5e082b1..c97742b 100644
--- a/src/core/org/apache/jmeter/save/OldSaveService.java
+++ b/src/core/org/apache/jmeter/save/OldSaveService.java
@@ -100,6 +100,7 @@ public final class OldSaveService {
private static final String CSV_BYTES= "bytes"; // $NON-NLS-1$
private static final String CSV_THREAD_COUNT1 = "grpThreads"; // $NON-NLS-1$
private static final String CSV_THREAD_COUNT2 = "allThreads"; // $NON-NLS-1$
+ private static final String CSV_SAMPLE_COUNT = "SampleCount"; // $NON-NLS-1$
private static final String CSV_URL = "URL"; // $NON-NLS-1$
private static final String CSV_FILENAME = "Filename"; // $NON-NLS-1$
private static final String CSV_LATENCY = "Latency"; // $NON-NLS-1$
@@ -259,6 +260,12 @@ public final class OldSaveService {
result.setEncodingAndType(text);
}
+ if (saveConfig.saveEncoding()) {
+ field = CSV_SAMPLE_COUNT;
+ text = parts[i++];
+ result.setSampleCount(Integer.parseInt(text));
+ }
+
} catch (NumberFormatException e) {
log.warn("Error parsing field '" + field + "' at line " + lineNumber + " " + e);
@@ -368,6 +375,11 @@ public final class OldSaveService {
text.append(delim);
}
+ if (saveConfig.saveSampleCount()) {
+ text.append(CSV_SAMPLE_COUNT);
+ text.append(delim);
+ }
+
String resultString = null;
int size = text.length();
int delSize = delim.length();
@@ -399,8 +411,10 @@ public final class OldSaveService {
headerLabelMethods.put(CSV_FILENAME, new Functor("setFileName"));
headerLabelMethods.put(CSV_LATENCY, new Functor("setLatency"));
headerLabelMethods.put(CSV_ENCODING, new Functor("setEncoding"));
+ // Both these are needed in the list even though they set the same variable
headerLabelMethods.put(CSV_THREAD_COUNT1,new Functor("setThreadCounts"));
- headerLabelMethods.put(CSV_THREAD_COUNT2, new Functor("setThreadCounts"));
+ headerLabelMethods.put(CSV_THREAD_COUNT2,new Functor("setThreadCounts"));
+ headerLabelMethods.put(CSV_SAMPLE_COUNT, new Functor("setSampleCount"));
}
/**
@@ -578,6 +592,11 @@ public final class OldSaveService {
text.append(delimiter);
}
+ if (saveConfig.saveSampleCount()) {
+ text.append(sample.getSampleCount());
+ text.append(delimiter);
+ }
+
String resultString = null;
int size = text.length();
int delSize = delimiter.length();
@@ -697,6 +716,10 @@ public final class OldSaveService {
return config;
}
+ /*
+ * TODO - I think this is used for the original test plan format
+ * It seems to be rather out of date, as many attributes are missing?
+ */
/**
* This method determines the content of the result data that will be
* stored.
diff --git a/src/core/org/apache/jmeter/save/converters/SampleSaveConfigurationConverter.java b/src/core/org/apache/jmeter/save/converters/SampleSaveConfigurationConverter.java
index 8f638f7..e15f0bc 100644
--- a/src/core/org/apache/jmeter/save/converters/SampleSaveConfigurationConverter.java
+++ b/src/core/org/apache/jmeter/save/converters/SampleSaveConfigurationConverter.java
@@ -47,6 +47,7 @@ public class SampleSaveConfigurationConverter extends ReflectionConverter {
private static final String NODE_URL = "url"; // $NON-NLS-1$
private static final String NODE_BYTES = "bytes"; // $NON-NLS-1$
private static final String NODE_THREAD_COUNT = "threadCounts"; // $NON-NLS-1$
+ private static final String NODE_SAMPLE_COUNT = "sampleCount"; // $NON-NLS-1$
// Additional member names which are currently not written out
private static final String NODE_DELIMITER = "delimiter"; // $NON-NLS-1$
@@ -61,11 +62,14 @@ public class SampleSaveConfigurationConverter extends ReflectionConverter {
public boolean shouldSerializeMember(Class definedIn, String fieldName) {
if (SampleSaveConfiguration.class != definedIn) return true;
+ // These are new fields; not saved unless true
if (fieldName.equals(NODE_BYTES)) return false;
if (fieldName.equals(NODE_URL)) return false;
if (fieldName.equals(NODE_FILENAME)) return false;
if (fieldName.equals(NODE_THREAD_COUNT)) return false;
+ if (fieldName.equals(NODE_SAMPLE_COUNT)) return false;
+ // These fields are not currently saved or restored
if (fieldName.equals(NODE_DELIMITER)) return false;
if (fieldName.equals(NODE_PRINTMS)) return false;
return true;
@@ -109,6 +113,7 @@ public class SampleSaveConfigurationConverter extends ReflectionConverter {
createNode(writer,prop.saveUrl(),NODE_URL);
createNode(writer,prop.saveFileName(),NODE_FILENAME);
createNode(writer,prop.saveThreadCounts(),NODE_THREAD_COUNT);
+ createNode(writer,prop.saveSampleCount(),NODE_SAMPLE_COUNT);
}
// Helper method to simplify marshall routine
diff --git a/xdocs/changes.xml b/xdocs/changes.xml
index 2500dca..f773e42 100644
--- a/xdocs/changes.xml
+++ b/xdocs/changes.xml
@@ -40,6 +40,7 @@
<li>Fixup broken jmeter-server script</li>
<li>Bug 43364 - option to revert If Controller to pre 2.3RC3 behaviour</li>
<li>Bug 43449 - Statistical Remote mode does not handle Latency</li>
+<li>Bug 43450 (partial fix) - Allow SampleCount to be saved/restored from CSV files</li>
</ul>
<h4>Improvements</h4>