jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmoua...@apache.org
Subject svn commit: r1755459 - in /jmeter/trunk: bin/ src/core/org/apache/jmeter/report/config/ src/core/org/apache/jmeter/report/dashboard/ xdocs/ xdocs/usermanual/
Date Sun, 07 Aug 2016 20:53:07 GMT
Author: pmouawad
Date: Sun Aug  7 20:53:07 2016
New Revision: 1755459

URL: http://svn.apache.org/viewvc?rev=1755459&view=rev
Log:
Bug 59956 - Web Report / Dashboard : Add ability to generate a graph for a range of data
Bugzilla Id: 59956

Modified:
    jmeter/trunk/bin/reportgenerator.properties
    jmeter/trunk/bin/user.properties
    jmeter/trunk/src/core/org/apache/jmeter/report/config/ReportGeneratorConfiguration.java
    jmeter/trunk/src/core/org/apache/jmeter/report/dashboard/ReportGenerator.java
    jmeter/trunk/xdocs/changes.xml
    jmeter/trunk/xdocs/usermanual/generating-dashboard.xml

Modified: jmeter/trunk/bin/reportgenerator.properties
URL: http://svn.apache.org/viewvc/jmeter/trunk/bin/reportgenerator.properties?rev=1755459&r1=1755458&r2=1755459&view=diff
==============================================================================
--- jmeter/trunk/bin/reportgenerator.properties (original)
+++ jmeter/trunk/bin/reportgenerator.properties Sun Aug  7 20:53:07 2016
@@ -52,6 +52,12 @@
 # Configure this property to change the report title
 #jmeter.reportgenerator.report_title=Apache JMeter Dashboard
 
+# Used to generate a report based on a date range
+# Date range start date at format dd/MM/yyyy HH:mm:ss
+#jmeter.reportgenerator.start_date=
+# Date range end date at format dd/MM/yyyy HH:mm:ss
+#jmeter.reportgenerator.end_date=
+
 # Defines the overall granularity for over time graphs
 jmeter.reportgenerator.overall_granularity=60000
 

Modified: jmeter/trunk/bin/user.properties
URL: http://svn.apache.org/viewvc/jmeter/trunk/bin/user.properties?rev=1755459&r1=1755458&r2=1755459&view=diff
==============================================================================
--- jmeter/trunk/bin/user.properties (original)
+++ jmeter/trunk/bin/user.properties Sun Aug  7 20:53:07 2016
@@ -76,6 +76,12 @@
 # Configure this property to change the report title
 #jmeter.reportgenerator.report_title=Apache JMeter Dashboard
 
+# Used to generate a report based on a date range if needed
+# Date range start date at format dd/MM/yyyy HH:mm:ss
+#jmeter.reportgenerator.start_date=
+# Date range end date at format dd/MM/yyyy HH:mm:ss
+#jmeter.reportgenerator.end_date=
+
 # Change this parameter if you want to change the granularity of over time graphs.
 #jmeter.reportgenerator.overall_granularity=60000
 

Modified: jmeter/trunk/src/core/org/apache/jmeter/report/config/ReportGeneratorConfiguration.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/report/config/ReportGeneratorConfiguration.java?rev=1755459&r1=1755458&r2=1755459&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/report/config/ReportGeneratorConfiguration.java
(original)
+++ jmeter/trunk/src/core/org/apache/jmeter/report/config/ReportGeneratorConfiguration.java
Sun Aug  7 20:53:07 2016
@@ -18,6 +18,9 @@
 package org.apache.jmeter.report.config;
 
 import java.io.File;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Properties;
@@ -39,6 +42,8 @@ public class ReportGeneratorConfiguratio
 
     private static final Logger LOG = LoggingManager.getLoggerForClass();
 
+    private static final String DATE_FORMAT = "dd/MM/yyyy HH:mm:ss"; //$NON-NLS-1$
+
     public static final char KEY_DELIMITER = '.';
     public static final String REPORT_GENERATOR_KEY_PREFIX = "jmeter.reportgenerator";
     public static final String REPORT_GENERATOR_GRAPH_KEY_PREFIX = REPORT_GENERATOR_KEY_PREFIX
@@ -69,6 +74,14 @@ public class ReportGeneratorConfiguratio
     // report title
     private static final String REPORT_GENERATOR_KEY_REPORT_TITLE = REPORT_GENERATOR_KEY_PREFIX
             + KEY_DELIMITER + "report_title";
+    
+    // start date for which report must be generated
+    private static final String REPORT_GENERATOR_KEY_START_DATE = REPORT_GENERATOR_KEY_PREFIX
+            + KEY_DELIMITER + "start_date";
+    
+    // end date for which report must be generated
+    private static final String REPORT_GENERATOR_KEY_END_DATE = REPORT_GENERATOR_KEY_PREFIX
+            + KEY_DELIMITER + "end_date";
 
     private static final String LOAD_EXPORTER_FMT = "Load configuration for exporter \"%s\"";
     private static final String LOAD_GRAPH_FMT = "Load configuration for graph \"%s\"";
@@ -260,6 +273,8 @@ public class ReportGeneratorConfiguratio
                 throws ConfigurationException;
     }
     private String reportTitle;
+    private Date startDate;
+    private Date endDate;
     private String sampleFilter;
     private File tempDirectory;
     private long apdexSatisfiedThreshold;
@@ -613,6 +628,34 @@ public class ReportGeneratorConfiguratio
                 REPORT_GENERATOR_KEY_REPORT_TITLE, String.class);
         configuration.setReportTitle(reportTitle);
 
+        Date reportStartDate = null;
+        Date reportEndDate = null;
+        final String startDateValue = getOptionalProperty(props,
+                REPORT_GENERATOR_KEY_START_DATE, String.class);
+        final String endDateValue = getOptionalProperty(props,
+                REPORT_GENERATOR_KEY_END_DATE, String.class);
+        SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT);
+        try {
+            if(!StringUtils.isEmpty(startDateValue)) {
+                reportStartDate = dateFormat.parse(startDateValue);
+                configuration.setStartDate(reportStartDate);
+            }
+        } catch (ParseException e) {
+            LOG.error("Error parsing property 'REPORT_GENERATOR_KEY_START_DATE' with value:"
+ startDateValue
+                    +" using format:"+DATE_FORMAT, e);
+        }
+        try {
+            if(!StringUtils.isEmpty(endDateValue)) {
+                reportEndDate = dateFormat.parse(endDateValue);
+                configuration.setEndDate(reportEndDate);
+            }
+        } catch (ParseException e) {
+            LOG.error("Error parsing property 'REPORT_GENERATOR_KEY_START_DATE' with value:"
+ endDateValue 
+                    +" using format:"+DATE_FORMAT, e);
+        }
+        
+        LOG.info("Will use date range start date: "+startDateValue+", end date: "+endDateValue);
+
         // Find graph identifiers and load a configuration for each
         final Map<String, GraphConfiguration> graphConfigurations = configuration
                 .getGraphConfigurations();
@@ -666,4 +709,32 @@ public class ReportGeneratorConfiguratio
         }
         return filteredSamplesPattern;
     }
+
+    /**
+     * @return the start date to use to generate the report
+     */
+    public Date getStartDate() {
+        return startDate;
+    }
+
+    /**
+     * @param startDate the start date to use to generate the report
+     */
+    public void setStartDate(Date startDate) {
+        this.startDate = startDate;
+    }
+
+    /**
+     * @return the end date to use to generate the report
+     */
+    public Date getEndDate() {
+        return endDate;
+    }
+
+    /**
+     * @param endDate the end date to use to generate the report
+     */
+    public void setEndDate(Date endDate) {
+        this.endDate = endDate;
+    }
 }

Modified: jmeter/trunk/src/core/org/apache/jmeter/report/dashboard/ReportGenerator.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/report/dashboard/ReportGenerator.java?rev=1755459&r1=1755458&r2=1755459&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/report/dashboard/ReportGenerator.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/report/dashboard/ReportGenerator.java Sun Aug
 7 20:53:07 2016
@@ -87,6 +87,7 @@ public class ReportGenerator {
     public static final String BEGIN_DATE_CONSUMER_NAME = "beginDate";
     public static final String END_DATE_CONSUMER_NAME = "endDate";
     public static final String NAME_FILTER_CONSUMER_NAME = "nameFilter";
+    public static final String DATE_RANGE_FILTER_CONSUMER_NAME = "dateRangeFilter";
     public static final String APDEX_SUMMARY_CONSUMER_NAME = "apdexSummary";
     public static final String ERRORS_SUMMARY_CONSUMER_NAME = "errorsSummary";
     public static final String REQUESTS_SUMMARY_CONSUMER_NAME = "requestsSummary";
@@ -212,9 +213,10 @@ public class ReportGenerator {
 
         NormalizerSampleConsumer normalizer = new NormalizerSampleConsumer();
         normalizer.setName(NORMALIZER_CONSUMER_NAME);
-
-        normalizer.addSampleConsumer(createBeginDateConsumer());
-        normalizer.addSampleConsumer(createEndDateConsumer());
+        
+        FilterConsumer dateRangeConsumer = createFilterByDateRange();
+        dateRangeConsumer.addSampleConsumer(createBeginDateConsumer());
+        dateRangeConsumer.addSampleConsumer(createEndDateConsumer());
 
         FilterConsumer nameFilter = createNameFilter();
 
@@ -222,8 +224,10 @@ public class ReportGenerator {
 
         nameFilter.addSampleConsumer(excludeControllerFilter);
 
-        normalizer.addSampleConsumer(nameFilter);
-
+        dateRangeConsumer.addSampleConsumer(nameFilter);
+        
+        normalizer.addSampleConsumer(dateRangeConsumer);
+        
         source.addSampleConsumer(normalizer);
 
         // Get graph configurations
@@ -264,6 +268,38 @@ public class ReportGenerator {
 
     }
 
+    /**
+     * @return {@link FilterConsumer} that filter data based on date range
+     */
+    private FilterConsumer createFilterByDateRange() {
+        FilterConsumer dateRangeFilter = new FilterConsumer();
+        dateRangeFilter.setName(DATE_RANGE_FILTER_CONSUMER_NAME);
+        dateRangeFilter.setSamplePredicate(new SamplePredicate() {
+
+            @Override
+            public boolean matches(Sample sample) {
+                long sampleStartTime = sample.getStartTime();
+                if(configuration.getStartDate() != null) {
+                    if((sampleStartTime >= configuration.getStartDate().getTime())) {
+                        if(configuration.getEndDate() != null) {
+                            return sampleStartTime <= configuration.getEndDate().getTime();
                            
+                        } else {
+                            return true;                            
+                        }
+                    }
+                    return false;
+                } else {
+                    if(configuration.getEndDate() != null) {
+                        return sampleStartTime <= configuration.getEndDate().getTime();

+                    } else {
+                        return true;                            
+                    }
+                }
+            }
+        });     
+        return dateRangeFilter;
+    }
+
     private void removeTempDir(File tmpDir, boolean tmpDirCreated) {
         if (tmpDirCreated) {
             try {

Modified: jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1755459&r1=1755458&r2=1755459&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml [utf-8] (original)
+++ jmeter/trunk/xdocs/changes.xml [utf-8] Sun Aug  7 20:53:07 2016
@@ -126,6 +126,7 @@ Summary
     <li><bug>59924</bug>The log level of XXX package is set to DEBUG if
<code>log_level.XXXX</code> property value contains spaces, same for __log function</li>
     <li><bug>59777</bug>Extract slf4j binding into its own jar and make
it a jmeter lib</li>
     <li><bug>59954</bug>Web Report/Dashboard : Add average metric</li>
+    <li><bug>59956</bug>Web Report / Dashboard : Add ability to generate
a graph for a range of data</li>
 </ul>
 
 <ch_section>Non-functional changes</ch_section>

Modified: jmeter/trunk/xdocs/usermanual/generating-dashboard.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/usermanual/generating-dashboard.xml?rev=1755459&r1=1755458&r2=1755459&view=diff
==============================================================================
--- jmeter/trunk/xdocs/usermanual/generating-dashboard.xml (original)
+++ jmeter/trunk/xdocs/usermanual/generating-dashboard.xml Sun Aug  7 20:53:07 2016
@@ -108,6 +108,16 @@ jmeter.save.saveservice.timestamp_format
                             Title used in the generated report. 
                             Default: "Apache JMeter Dashboard"
                         </property>
+                        <property name="start_date" required="No">
+                            Start date of the range of data to use for report.
+                            Date format is <code>dd/MM/yyyy HH:mm:ss</code> 
+                            Default: not filled which means data range will be used from
the begining
+                        </property>
+                        <property name="end_date" required="No">
+                            End date of the range of data to use for report. 
+                            Date format is <code>dd/MM/yyyy HH:mm:ss</code>
+                            Default: not filled which means data range will be used until
the end
+                        </property>
                         <property name="overall_granularity" required="No">
                             Granularity of over time graphs. Data is aggregated to have 1
minute ticks. 
                             Default: "60000" (1 minute)



Mime
View raw message