Author: pmouawad
Date: Sat Mar 9 09:22:13 2019
New Revision: 1855097
URL: http://svn.apache.org/viewvc?rev=1855097&view=rev
Log:
Bug 59896 - Report / Dashboard : Add a menu entry to generate a report on demand from a CSV
file
Take into account part of Vladimir feedback
Bugzilla Id: 59896
Added:
jmeter/trunk/test/resources/org/apache/jmeter/gui/report/
jmeter/trunk/test/resources/org/apache/jmeter/gui/report/HTMLReportExpect.json
Removed:
jmeter/trunk/bin/testfiles/HTMLReportExpect.json
Modified:
jmeter/trunk/test/src/org/apache/jmeter/gui/action/HtmlReportGeneratorSpec.groovy
Added: jmeter/trunk/test/resources/org/apache/jmeter/gui/report/HTMLReportExpect.json
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/resources/org/apache/jmeter/gui/report/HTMLReportExpect.json?rev=1855097&view=auto
==============================================================================
--- jmeter/trunk/test/resources/org/apache/jmeter/gui/report/HTMLReportExpect.json (added)
+++ jmeter/trunk/test/resources/org/apache/jmeter/gui/report/HTMLReportExpect.json Sat Mar
9 09:22:13 2019
@@ -0,0 +1,47 @@
+{
+ "JR-KO" : {
+ "transaction" : "JR-KO",
+ "sampleCount" : 3,
+ "errorCount" : 3,
+ "errorPct" : 100.0,
+ "meanResTime" : 199.66666666666666,
+ "minResTime" : 100.0,
+ "maxResTime" : 329.0,
+ "pct1ResTime" : 329.0,
+ "pct2ResTime" : 329.0,
+ "pct3ResTime" : 329.0,
+ "throughput" : 0.07922465471254654,
+ "receivedKBytesPerSec" : 0.0015473565373544248,
+ "sentKBytesPerSec" : 6.1894261494177E-4
+ },
+ "Total" : {
+ "transaction" : "Total",
+ "sampleCount" : 255,
+ "errorCount" : 3,
+ "errorPct" : 1.1764706,
+ "meanResTime" : 235.47450980392148,
+ "minResTime" : 100.0,
+ "maxResTime" : 353.0,
+ "pct1ResTime" : 337.0,
+ "pct2ResTime" : 339.2,
+ "pct3ResTime" : 353.0,
+ "throughput" : 4.2369361136495804,
+ "receivedKBytesPerSec" : 0.07457474869153444,
+ "sentKBytesPerSec" : 0.03310106338788735
+ },
+ "JR-OK" : {
+ "transaction" : "JR-OK",
+ "sampleCount" : 252,
+ "errorCount" : 0,
+ "errorPct" : 0.0,
+ "meanResTime" : 235.90079365079367,
+ "minResTime" : 101.0,
+ "maxResTime" : 353.0,
+ "pct1ResTime" : 337.0,
+ "pct2ResTime" : 339.35,
+ "pct3ResTime" : 353.0,
+ "throughput" : 4.187089806430174,
+ "receivedKBytesPerSec" : 0.0736011880036554,
+ "sentKBytesPerSec" : 0.03271163911273573
+ }
+}
Modified: jmeter/trunk/test/src/org/apache/jmeter/gui/action/HtmlReportGeneratorSpec.groovy
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/gui/action/HtmlReportGeneratorSpec.groovy?rev=1855097&r1=1855096&r2=1855097&view=diff
==============================================================================
--- jmeter/trunk/test/src/org/apache/jmeter/gui/action/HtmlReportGeneratorSpec.groovy (original)
+++ jmeter/trunk/test/src/org/apache/jmeter/gui/action/HtmlReportGeneratorSpec.groovy Sat
Mar 9 09:22:13 2019
@@ -19,11 +19,14 @@
package org.apache.jmeter.gui.action
import spock.lang.IgnoreIf
+import spock.lang.Shared
import spock.lang.Unroll
+import java.net.URL;
import java.text.MessageFormat
import org.apache.commons.io.FileUtils
+import org.apache.commons.io.FilenameUtils
import org.apache.jmeter.junit.spock.JMeterSpec
import org.apache.jmeter.util.JMeterUtils
@@ -33,6 +36,8 @@ import com.fasterxml.jackson.databind.Ob
class HtmlReportGeneratorSpec extends JMeterSpec{
+ @Shared jmeterBinDir = JMeterUtils.getJMeterBinDir();
+
def "check if generation from csv: '#csvPath' with properties: '#userPropertiesPath'
in folder: '#outputDirectoryPath' contains the expected error"(){
when:
HtmlReportGenerator htmlReportGenerator = new HtmlReportGenerator(csvPath, userPropertiesPath,
outputDirectoryPath)
@@ -41,11 +46,11 @@ class HtmlReportGeneratorSpec extends JM
resultList.equals(expected)
where:
csvPath | userPropertiesPath
| outputDirectoryPath
| expected
- JMeterUtils.getJMeterBinDir()+"/testfiles/HTMLReportTestFile.csv" | JMeterUtils.getJMeterBinDir()+"/user.properties"
| JMeterUtils.getJMeterBinDir()+"/testfiles/testReport" | []
- JMeterUtils.getJMeterBinDir()+"/testfiles/HTMLReportTestFile.csv" | JMeterUtils.getJMeterBinDir()+"/user.properties"
| JMeterUtils.getJMeterBinDir()+"/testfiles" | [
+ jmeterBinDir+"/testfiles/HTMLReportTestFile.csv" | jmeterBinDir+"/user.properties"
| jmeterBinDir+"/testfiles/testReport" | []
+ jmeterBinDir+"/testfiles/HTMLReportTestFile.csv" | jmeterBinDir+"/user.properties"
| jmeterBinDir+"/testfiles" | [
JMeterUtils.getResString("generate_report_ui.output_directory") + MessageFormat.format(JMeterUtils.getResString(HtmlReportGenerator.NOT_EMPTY_DIRECTORY),
outputDirectoryPath)
]
- JMeterUtils.getJMeterBinDir()+"/testfiles/HTMLReportTestFileMissing.csv" | JMeterUtils.getJMeterBinDir()+"/user.properties"
| JMeterUtils.getJMeterBinDir()+"/testfiles/testReport" | [
+ jmeterBinDir+"/testfiles/HTMLReportTestFileMissing.csv" | jmeterBinDir+"/user.properties"
| jmeterBinDir+"/testfiles/testReport" | [
JMeterUtils.getResString("generate_report_ui.csv_file") + MessageFormat.format(JMeterUtils.getResString(HtmlReportGenerator.NO_FILE),
csvPath)
]
"" | ""
| ""
| [
@@ -53,14 +58,14 @@ class HtmlReportGeneratorSpec extends JM
JMeterUtils.getResString("generate_report_ui.user_properties_file") + MessageFormat.format(JMeterUtils.getResString(HtmlReportGenerator.NO_FILE),
userPropertiesPath),
JMeterUtils.getResString("generate_report_ui.output_directory") + MessageFormat.format(JMeterUtils.getResString(HtmlReportGenerator.CANNOT_CREATE_DIRECTORY),
outputDirectoryPath)
]
- JMeterUtils.getJMeterBinDir()+"/testfiles/HTMLReportTestFile.csv" | JMeterUtils.getJMeterBinDir()+"/user.properties"
| JMeterUtils.getJMeterBinDir()+"/testfiles/testReport/oneLevel/twolevel" | [
+ jmeterBinDir+"/testfiles/HTMLReportTestFile.csv" | jmeterBinDir+"/user.properties"
| jmeterBinDir+"/testfiles/testReport/oneLevel/twolevel" | [
JMeterUtils.getResString("generate_report_ui.output_directory") + MessageFormat.format(JMeterUtils.getResString(HtmlReportGenerator.CANNOT_CREATE_DIRECTORY),
outputDirectoryPath)
]
}
def "check that report generation succeeds and statistic are generated"(){
setup:
- File testDirectory = new File(JMeterUtils.getJMeterBinDir(), "/testfiles/testReport")
+ File testDirectory = new File(jmeterBinDir, "/testfiles/testReport")
if(testDirectory.exists()) {
if (testDirectory.list().length>0) {
FileUtils.cleanDirectory(testDirectory)
@@ -69,18 +74,18 @@ class HtmlReportGeneratorSpec extends JM
testDirectory.mkdir()
}
ObjectMapper mapper = new ObjectMapper()
- File expected = new File(JMeterUtils.getJMeterBinDir(),"/testfiles/HTMLReportExpect.json")
+ URL expected = HtmlReportGenerator.class.getResource("/org/apache/jmeter/gui/report/HTMLReportExpect.json");
JsonNode expectedRoot = null;
expected.withReader { jsonFileReader ->
expectedRoot = mapper.readTree(jsonFileReader)
}
when:
HtmlReportGenerator htmlReportGenerator = new HtmlReportGenerator(
- JMeterUtils.getJMeterBinDir() + "/testfiles/HTMLReportTestFile.csv",
- JMeterUtils.getJMeterBinDir() + "/user.properties",
- JMeterUtils.getJMeterBinDir() + "/testfiles/testReport")
+ jmeterBinDir + "/testfiles/HTMLReportTestFile.csv",
+ jmeterBinDir + "/user.properties",
+ testDirectory.toString())
List<String> resultList = htmlReportGenerator.run()
- File statistics = new File(JMeterUtils.getJMeterBinDir(), "/testfiles/testReport/statistics.json")
+ File statistics = new File(jmeterBinDir, "/testfiles/testReport/statistics.json")
JsonNode actualRoot = null;
if (statistics.exists()) {
statistics.withReader { jsonFileReader ->
@@ -90,6 +95,7 @@ class HtmlReportGeneratorSpec extends JM
then:
resultList.isEmpty()
statistics.exists()
+ expectedRoot != null
expectedRoot == actualRoot
cleanup:
if(testDirectory.exists()) {
@@ -101,7 +107,7 @@ class HtmlReportGeneratorSpec extends JM
def "check that report generation fails when format does not match and error is reported"(){
setup:
- File testDirectory = new File(JMeterUtils.getJMeterBinDir(),"/testfiles/testReportThatShouldBeEmpty")
+ File testDirectory = new File(jmeterBinDir,"/testfiles/testReportThatShouldBeEmpty")
if(testDirectory.exists()) {
if (testDirectory.list().length>0) {
FileUtils.cleanDirectory(testDirectory)
@@ -111,9 +117,9 @@ class HtmlReportGeneratorSpec extends JM
}
when:
HtmlReportGenerator htmlReportGenerator = new HtmlReportGenerator(
- JMeterUtils.getJMeterBinDir() + "/testfiles/HTMLReportFalseTestFile.csv",
- JMeterUtils.getJMeterBinDir() + "/user.properties",
- JMeterUtils.getJMeterBinDir() + "/testfiles/testReport")
+ jmeterBinDir + "/testfiles/HTMLReportFalseTestFile.csv",
+ jmeterBinDir + "/user.properties",
+ testDirectory.toString())
List<String> resultList = htmlReportGenerator.run()
then:
testDirectory.list().length == 0
|