jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fschumac...@apache.org
Subject [jmeter] branch bug_64553 updated: Give the cumulated add its own method
Date Mon, 17 Aug 2020 14:06:40 GMT
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/bug_64553 by this push:
     new 5b8d1ce  Give the cumulated add its own method
5b8d1ce is described below

commit 5b8d1cec1518ad957d0c46eda5948b018979c0a6
Author: Felix Schumacher <felix.schumacher@internetallee.de>
AuthorDate: Mon Aug 17 16:06:15 2020 +0200

    Give the cumulated add its own method
---
 .../jmeter/visualizers/backend/SamplerMetric.java      | 18 +++++++++++++++++-
 .../graphite/GraphiteBackendListenerClient.java        |  4 ++--
 .../influxdb/InfluxdbBackendListenerClient.java        |  4 ++--
 .../backend/SamplerMetricFixedModeTest.java            | 10 +++++-----
 .../backend/SamplerMetricTimedModeTest.java            |  4 ++--
 5 files changed, 28 insertions(+), 12 deletions(-)

diff --git a/src/components/src/main/java/org/apache/jmeter/visualizers/backend/SamplerMetric.java
b/src/components/src/main/java/org/apache/jmeter/visualizers/backend/SamplerMetric.java
index e6ad2f0..33a3909 100644
--- a/src/components/src/main/java/org/apache/jmeter/visualizers/backend/SamplerMetric.java
+++ b/src/components/src/main/java/org/apache/jmeter/visualizers/backend/SamplerMetric.java
@@ -99,9 +99,25 @@ public class SamplerMetric {
     /**
      * Add a {@link SampleResult} to be used in the statistics
      * @param result {@link SampleResult} to be used
+     */
+    public synchronized void add(SampleResult result) {
+        add(result, false);
+    }
+
+    /**
+     * Add a {@link SampleResult} and its sub-results to be used in the statistics
+     * @param result {@link SampleResult} to be used
+     */
+    public synchronized void addCumulated(SampleResult result) {
+        add(result, true);
+    }
+
+    /**
+     * Add a {@link SampleResult} to be used in the statistics
+     * @param result {@link SampleResult} to be used
      * @param isCumulated is the overall Sampler Metric
      */
-    public synchronized void add(SampleResult result, boolean isCumulated) {
+    private synchronized void add(SampleResult result, boolean isCumulated) {
         if(result.isSuccessful()) {
             successes+=result.getSampleCount()-result.getErrorCount();
         } else {
diff --git a/src/components/src/main/java/org/apache/jmeter/visualizers/backend/graphite/GraphiteBackendListenerClient.java
b/src/components/src/main/java/org/apache/jmeter/visualizers/backend/graphite/GraphiteBackendListenerClient.java
index f6bb597..16d8b4a 100644
--- a/src/components/src/main/java/org/apache/jmeter/visualizers/backend/graphite/GraphiteBackendListenerClient.java
+++ b/src/components/src/main/java/org/apache/jmeter/visualizers/backend/graphite/GraphiteBackendListenerClient.java
@@ -285,10 +285,10 @@ public class GraphiteBackendListenerClient extends AbstractBackendListenerClient
                     }
                     if (samplersToFilterMatch) {
                         SamplerMetric samplerMetric = getSamplerMetric(sampleResult.getSampleLabel());
-                        samplerMetric.add(sampleResult, false);
+                        samplerMetric.add(sampleResult);
                     }
                 }
-                getSamplerMetric(CUMULATED_METRICS).add(sampleResult, true);
+                getSamplerMetric(CUMULATED_METRICS).addCumulated(sampleResult);
             }
         }
     }
diff --git a/src/components/src/main/java/org/apache/jmeter/visualizers/backend/influxdb/InfluxdbBackendListenerClient.java
b/src/components/src/main/java/org/apache/jmeter/visualizers/backend/influxdb/InfluxdbBackendListenerClient.java
index 09b44ed..0c61e97 100644
--- a/src/components/src/main/java/org/apache/jmeter/visualizers/backend/influxdb/InfluxdbBackendListenerClient.java
+++ b/src/components/src/main/java/org/apache/jmeter/visualizers/backend/influxdb/InfluxdbBackendListenerClient.java
@@ -300,10 +300,10 @@ public class InfluxdbBackendListenerClient extends AbstractBackendListenerClient
                 Matcher matcher = samplersToFilter.matcher(sampleResult.getSampleLabel());
                 if (!summaryOnly && (matcher.find())) {
                     SamplerMetric samplerMetric = getSamplerMetricInfluxdb(sampleResult.getSampleLabel());
-                    samplerMetric.add(sampleResult, false);
+                    samplerMetric.add(sampleResult);
                 }
                 SamplerMetric cumulatedMetrics = getSamplerMetricInfluxdb(CUMULATED_METRICS);
-                cumulatedMetrics.add(sampleResult, true);
+                cumulatedMetrics.addCumulated(sampleResult);
             }
         }
     }
diff --git a/src/components/src/test/java/org/apache/jmeter/visualizers/backend/SamplerMetricFixedModeTest.java
b/src/components/src/test/java/org/apache/jmeter/visualizers/backend/SamplerMetricFixedModeTest.java
index 0c25028..6f479f3 100644
--- a/src/components/src/test/java/org/apache/jmeter/visualizers/backend/SamplerMetricFixedModeTest.java
+++ b/src/components/src/test/java/org/apache/jmeter/visualizers/backend/SamplerMetricFixedModeTest.java
@@ -36,7 +36,7 @@ public class SamplerMetricFixedModeTest {
     @Test
     public void checkResetOkAndAllStats() throws Exception {
         SamplerMetric metric = new SamplerMetric();
-        metric.add(createSampleResult(true), false);
+        metric.add(createSampleResult(true));
         assertEquals("Before reset  ok.max", DEFAULT_ELAPSED_TIME, metric.getOkMaxTime(),
0.001);
         assertEquals("Before reset all.max", DEFAULT_ELAPSED_TIME, metric.getAllMaxTime(),
0.001);
         assertEquals("Before reset failure", 1, metric.getHits(), 0.0);
@@ -56,7 +56,7 @@ public class SamplerMetricFixedModeTest {
     @Test
     public void checkResetKoAndAllStats() throws Exception {
         SamplerMetric metric = new SamplerMetric();
-        metric.add(createSampleResult(false), false);
+        metric.add(createSampleResult(false));
         assertEquals("Before reset  ko.max", DEFAULT_ELAPSED_TIME, metric.getKoMaxTime(),
0.001);
         assertEquals("Before reset all.max", DEFAULT_ELAPSED_TIME, metric.getAllMaxTime(),
0.001);
         assertEquals("Before reset failure", 1, metric.getFailures(), 0.0);
@@ -76,9 +76,9 @@ public class SamplerMetricFixedModeTest {
     @Test
     public void checkErrorsDetailStat() {
         SamplerMetric metric = new SamplerMetric();
-        metric.add(createSampleResult("400", "bad request"), false);
-        metric.add(createSampleResult("400", "Bad Request "), false);
-        metric.add(createSampleResult("500", "Internal Server Error"), false);
+        metric.add(createSampleResult("400", "bad request"));
+        metric.add(createSampleResult("400", "Bad Request "));
+        metric.add(createSampleResult("500", "Internal Server Error"));
         ErrorMetric error = new ErrorMetric(createSampleResult("400", "Bad request"));
         assertEquals("Count for '400 - bad request' error ", 2, metric.getErrors().get(error),
0.0);
         error = new ErrorMetric(createSampleResult("500", "Internal Server Error"));
diff --git a/src/components/src/test/java/org/apache/jmeter/visualizers/backend/SamplerMetricTimedModeTest.java
b/src/components/src/test/java/org/apache/jmeter/visualizers/backend/SamplerMetricTimedModeTest.java
index ac4573f..82ca45d 100644
--- a/src/components/src/test/java/org/apache/jmeter/visualizers/backend/SamplerMetricTimedModeTest.java
+++ b/src/components/src/test/java/org/apache/jmeter/visualizers/backend/SamplerMetricTimedModeTest.java
@@ -38,7 +38,7 @@ public class SamplerMetricTimedModeTest {
 
         SamplerMetric metric = new SamplerMetric();
 
-        metric.add(createSampleResult(true), false);
+        metric.add(createSampleResult(true));
         assertEquals("Before reset  ok.max", DEFAULT_ELAPSED_TIME, metric.getOkMaxTime(),
0.001);
         assertEquals("Before reset all.max", DEFAULT_ELAPSED_TIME, metric.getAllMaxTime(),
0.001);
         assertEquals("Before reset failure", 1, metric.getHits(), 0.0);
@@ -58,7 +58,7 @@ public class SamplerMetricTimedModeTest {
     public void checkResetKoAndAllStats() throws Exception {
 
         SamplerMetric metric = new SamplerMetric();
-        metric.add(createSampleResult(false), false);
+        metric.add(createSampleResult(false));
         assertEquals("Before reset  ko.max", DEFAULT_ELAPSED_TIME, metric.getKoMaxTime(),
0.001);
         assertEquals("Before reset all.max", DEFAULT_ELAPSED_TIME, metric.getAllMaxTime(),
0.001);
         assertEquals("Before reset failure", 1, metric.getFailures(), 0.0);


Mime
View raw message