jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmoua...@apache.org
Subject svn commit: r1854414 - in /jmeter/trunk: src/core/org/apache/jmeter/report/processor/graph/impl/ test/src/org/apache/jmeter/report/processor/graph/impl/ xdocs/
Date Tue, 26 Feb 2019 19:32:36 GMT
Author: pmouawad
Date: Tue Feb 26 19:32:36 2019
New Revision: 1854414

URL: http://svn.apache.org/viewvc?rev=1854414&view=rev
Log:
 Refactor and Test ResponseTimePercentilesOverTimeGraphConsumer
 
 This closes #449 

Added:
    jmeter/trunk/test/src/org/apache/jmeter/report/processor/graph/impl/ResponseTimePercentilesOverTimeGraphConsumerSpec.groovy
Modified:
    jmeter/trunk/src/core/org/apache/jmeter/report/processor/graph/impl/ResponseTimePercentilesOverTimeGraphConsumer.java
    jmeter/trunk/xdocs/changes.xml

Modified: jmeter/trunk/src/core/org/apache/jmeter/report/processor/graph/impl/ResponseTimePercentilesOverTimeGraphConsumer.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/report/processor/graph/impl/ResponseTimePercentilesOverTimeGraphConsumer.java?rev=1854414&r1=1854413&r2=1854414&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/report/processor/graph/impl/ResponseTimePercentilesOverTimeGraphConsumer.java
(original)
+++ jmeter/trunk/src/core/org/apache/jmeter/report/processor/graph/impl/ResponseTimePercentilesOverTimeGraphConsumer.java
Tue Feb 26 19:32:36 2019
@@ -20,6 +20,7 @@ package org.apache.jmeter.report.process
 import java.util.HashMap;
 import java.util.Map;
 
+import org.apache.jmeter.report.processor.AggregatorFactory;
 import org.apache.jmeter.report.processor.MaxAggregatorFactory;
 import org.apache.jmeter.report.processor.MinAggregatorFactory;
 import org.apache.jmeter.report.processor.PercentileAggregatorFactory;
@@ -31,22 +32,17 @@ import org.apache.jmeter.report.processo
 import org.apache.jmeter.util.JMeterUtils;
 
 /**
- * The class ResponseTimePercentilesOverTimeGraphConsumer provides a graph to visualize percentiles
- * over time period.
- * Only successful responses are taken into account for computations
+ * The class ResponseTimePercentilesOverTimeGraphConsumer provides a graph to
+ * visualize percentiles over time period.
+ * Only successful responses are taken into account for computations.
  *
  * @since 3.1
  */
-public class ResponseTimePercentilesOverTimeGraphConsumer extends
-        AbstractOverTimeGraphConsumer {
+public class ResponseTimePercentilesOverTimeGraphConsumer
+        extends AbstractOverTimeGraphConsumer {
+
     private static final String PERCENTILE_FORMAT = "%dth percentile";
-    /*
-     * (non-Javadoc)
-     *
-     * @see
-     * org.apache.jmeter.report.csv.processor.impl.AbstractOverTimeGraphConsumer
-     * #createTimeStampKeysSelector()
-     */
+
     @Override
     protected TimeStampKeysSelector createTimeStampKeysSelector() {
         TimeStampKeysSelector keysSelector = new TimeStampKeysSelector();
@@ -54,79 +50,60 @@ public class ResponseTimePercentilesOver
         return keysSelector;
     }
 
-    /**
-     * Creates the group info for elapsed time percentile depending on jmeter
-     * properties.
-     *
-     * @param propertyKey
-     *            the property key
-     * @param defaultValue
-     *            the default value
-     * @param serieName Serie name
-     * @return the group info
-     */
-    private GroupInfo createPercentileGroupInfo(String propertyKey, int defaultValue, String
serieName) {
-        int property = JMeterUtils.getPropDefault(propertyKey, defaultValue);
-        PercentileAggregatorFactory factory = new PercentileAggregatorFactory();
-        factory.setPercentileIndex(property);
-        StaticSeriesSelector seriesSelector = new StaticSeriesSelector();
-        seriesSelector.setSeriesName(serieName);
+    @Override
+    protected Map<String, GroupInfo> createGroupInfos() {
+        HashMap<String, GroupInfo> groupInfos = new HashMap<>(8);
+
+        groupInfos.put("aggregate_report_min", createMinGroupInfo());
+
+        groupInfos.put("aggregate_report_max", createMaxGroupInfo());
+
+        groupInfos.put("aggregate_rpt_pct1",
+                createPercentileGroupInfo("aggregate_rpt_pct1", 90));
+
+        groupInfos.put("aggregate_rpt_pct2",
+                createPercentileGroupInfo("aggregate_rpt_pct2", 95));
+
+        groupInfos.put("aggregate_rpt_pct3",
+                createPercentileGroupInfo("aggregate_rpt_pct3", 99));
 
-        return new GroupInfo(factory, seriesSelector,
-                new SuccessfulElapsedTimeValueSelector(), false, false);
+        return groupInfos;
+    }
+
+    private String formatPercentile(int percentile) {
+        return String.format(PERCENTILE_FORMAT, Integer.valueOf(percentile));
     }
 
-    /**
-     * Creates the group info for min elapsed time
-     * @return the group info
-     */
     private GroupInfo createMinGroupInfo() {
         StaticSeriesSelector seriesSelector = new StaticSeriesSelector();
         seriesSelector.setSeriesName("Min");
-        return new GroupInfo(new MinAggregatorFactory(), seriesSelector,
-                new SuccessfulElapsedTimeValueSelector(), false, false);
+        return createGroupInfo(new MinAggregatorFactory(), seriesSelector);
     }
 
-    /**
-     * Creates the group info for max elapsed time
-     * @return the group info
-     */
     private GroupInfo createMaxGroupInfo() {
         StaticSeriesSelector seriesSelector = new StaticSeriesSelector();
         seriesSelector.setSeriesName("Max");
-        return new GroupInfo(new MaxAggregatorFactory(), seriesSelector,
-                new SuccessfulElapsedTimeValueSelector(), false, false);
+        return createGroupInfo(new MaxAggregatorFactory(), seriesSelector);
     }
 
-    /**
-     *
-     * @see org.apache.jmeter.report.processor.graph.AbstractGraphConsumer#createGroupInfos()
-     */
-    @Override
-    protected Map<String, GroupInfo> createGroupInfos() {
-        HashMap<String, GroupInfo> groupInfos = new HashMap<>(2);
-
-        groupInfos.put("aggregate_report_min", //$NON-NLS-1$
-                createMinGroupInfo());
+    private GroupInfo createPercentileGroupInfo(String propKey, int defaultValue) {
+        String seriesName = formatPercentile(defaultValue);
 
-        groupInfos.put("aggregate_report_max", //$NON-NLS-1$
-                createMaxGroupInfo());
+        int property = JMeterUtils.getPropDefault(propKey, defaultValue);
+        PercentileAggregatorFactory factory = new PercentileAggregatorFactory();
+        factory.setPercentileIndex(property);
+        StaticSeriesSelector seriesSelector = new StaticSeriesSelector();
+        seriesSelector.setSeriesName(seriesName);
 
-        groupInfos.put("aggregate_rpt_pct1", //$NON-NLS-1$
-                createPercentileGroupInfo("aggregate_rpt_pct1", 90, //$NON-NLS-1$
-                        String.format(
-                                PERCENTILE_FORMAT, Integer.valueOf(90))));
-
-        groupInfos.put("aggregate_rpt_pct2", //$NON-NLS-1$
-                createPercentileGroupInfo("aggregate_rpt_pct2", 95, //$NON-NLS-1$
-                        String.format(
-                                PERCENTILE_FORMAT, Integer.valueOf(95))));
-
-        groupInfos.put("aggregate_rpt_pct3", //$NON-NLS-1$
-                createPercentileGroupInfo("aggregate_rpt_pct3", 99,//$NON-NLS-1$
-                        String.format(
-                                PERCENTILE_FORMAT, Integer.valueOf(99))));
+        return createGroupInfo(factory, seriesSelector);
+    }
 
-        return groupInfos;
+    private GroupInfo createGroupInfo(AggregatorFactory aggregationFactory, StaticSeriesSelector
seriesSelector) {
+        return new GroupInfo(
+                aggregationFactory,
+                seriesSelector,
+                new SuccessfulElapsedTimeValueSelector(),
+                false,
+                false);
     }
 }

Added: jmeter/trunk/test/src/org/apache/jmeter/report/processor/graph/impl/ResponseTimePercentilesOverTimeGraphConsumerSpec.groovy
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/report/processor/graph/impl/ResponseTimePercentilesOverTimeGraphConsumerSpec.groovy?rev=1854414&view=auto
==============================================================================
--- jmeter/trunk/test/src/org/apache/jmeter/report/processor/graph/impl/ResponseTimePercentilesOverTimeGraphConsumerSpec.groovy
(added)
+++ jmeter/trunk/test/src/org/apache/jmeter/report/processor/graph/impl/ResponseTimePercentilesOverTimeGraphConsumerSpec.groovy
Tue Feb 26 19:32:36 2019
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ 
+ package org.apache.jmeter.report.processor.graph.impl
+
+import org.apache.jmeter.junit.spock.JMeterSpec
+
+import java.util.stream.Collectors
+
+class ResponseTimePercentilesOverTimeGraphConsumerSpec extends JMeterSpec {
+
+    static def EXPECTED_KEYS =
+            ['aggregate_report_min',
+             'aggregate_report_max',
+             'aggregate_rpt_pct1',
+             'aggregate_rpt_pct2',
+             'aggregate_rpt_pct3'] as Set
+
+    def sut = new ResponseTimePercentilesOverTimeGraphConsumer()
+
+    def "GroupInfos have only the required keys"() {
+        when:
+            def groupInfosMap = sut.createGroupInfos()
+        then:
+            groupInfosMap.keySet() == EXPECTED_KEYS
+    }
+
+    def "GroupInfos have the expected settings"() {
+        when:
+            def groupInfos = sut.createGroupInfos()
+            def groupInfoValues = groupInfos
+                    .entrySet().stream()
+                    .map { it.value }
+                    .collect(Collectors.toList())
+        then:
+            groupInfoValues.every { !it.enablesAggregatedKeysSeries() }
+            groupInfoValues.every { !it.enablesOverallSeries() }
+    }
+
+}

Modified: jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1854414&r1=1854413&r2=1854414&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml [utf-8] (original)
+++ jmeter/trunk/xdocs/changes.xml [utf-8] Tue Feb 26 19:32:36 2019
@@ -114,7 +114,8 @@ Summary
 
 <ch_section>Non-functional changes</ch_section>
 <ul>
-    <li>Bug 63203 - Unit Tests : Replace use of <code>@Deprecated</code>
by <code>@VisibleForTesting</code> for methods/constructors/classes made public
for Unit Testing only</li>
+    <li><bug>63203</bug>Unit Tests : Replace use of <code>@Deprecated</code>
by <code>@VisibleForTesting</code> for methods/constructors/classes made public
for Unit Testing only</li>
+    <li><pr>449</pr>Refactor and Test ResponseTimePercentilesOverTimeGraphConsumer.
Contributed by Graham Russell (graham at ham1.co.uk)</li>
 </ul>
 
  <!-- =================== Bug fixes =================== -->



Mime
View raw message