mirror of https://github.com/apache/jmeter.git
Add test to check report generation from read-only directory
Closes #6357 and #6358
This commit is contained in:
parent
939ae3c046
commit
872112bf5d
|
@ -18,6 +18,7 @@
|
||||||
package org.apache.jmeter.report.dashboard
|
package org.apache.jmeter.report.dashboard
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper
|
import com.fasterxml.jackson.databind.ObjectMapper
|
||||||
|
import org.apache.commons.io.FileUtils
|
||||||
import org.apache.jmeter.junit.JMeterTestCase
|
import org.apache.jmeter.junit.JMeterTestCase
|
||||||
import org.apache.jmeter.util.JMeterUtils
|
import org.apache.jmeter.util.JMeterUtils
|
||||||
import org.junit.jupiter.api.Assertions.assertEquals
|
import org.junit.jupiter.api.Assertions.assertEquals
|
||||||
|
@ -26,7 +27,10 @@ import org.junit.jupiter.api.assertThrows
|
||||||
import org.junit.jupiter.api.io.TempDir
|
import org.junit.jupiter.api.io.TempDir
|
||||||
import org.junit.jupiter.api.parallel.Isolated
|
import org.junit.jupiter.api.parallel.Isolated
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
import java.nio.file.Files
|
||||||
|
import java.nio.file.Path
|
||||||
import java.nio.file.Paths
|
import java.nio.file.Paths
|
||||||
|
import kotlin.io.path.absolutePathString
|
||||||
|
|
||||||
@Isolated("modifies shared properties")
|
@Isolated("modifies shared properties")
|
||||||
class ReportGeneratorTest : JMeterTestCase() {
|
class ReportGeneratorTest : JMeterTestCase() {
|
||||||
|
@ -43,6 +47,29 @@ class ReportGeneratorTest : JMeterTestCase() {
|
||||||
fun combine(vararg paths: String) =
|
fun combine(vararg paths: String) =
|
||||||
Paths.get(JMeterUtils.getJMeterBinDir(), *paths).toString()
|
Paths.get(JMeterUtils.getJMeterBinDir(), *paths).toString()
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `check that report generation succeeds from read-only templates`() {
|
||||||
|
val roTemplate = Files.createTempDirectory("report-template-ro")
|
||||||
|
FileUtils.copyDirectoryToDirectory(Path.of(combine("report-template")).toFile(), roTemplate.toFile())
|
||||||
|
Files.walk(roTemplate).forEach { p -> p.toFile().setReadOnly() }
|
||||||
|
JMeterUtils.setProperty("jmeter.reportgenerator.exporter.html.property.template_dir", roTemplate.absolutePathString())
|
||||||
|
val roReport = Files.createTempDirectory("report-from-ro-template")
|
||||||
|
|
||||||
|
val mapper = ObjectMapper()
|
||||||
|
val expected = ReportGenerator::class.java.getResource("/org/apache/jmeter/gui/report/HTMLReportExpect.json")
|
||||||
|
val expectedRoot = mapper.readTree(expected)
|
||||||
|
|
||||||
|
JMeterUtils.setProperty("jmeter.reportgenerator.outputdir", roReport.absolutePathString())
|
||||||
|
val reportGenerator = ReportGenerator(
|
||||||
|
combine("testfiles", "HTMLReportTestFile.csv"), null
|
||||||
|
)
|
||||||
|
reportGenerator.generate()
|
||||||
|
val statistics = File(roReport.toFile(), "statistics.json")
|
||||||
|
val actualRoot = mapper.readTree(statistics)
|
||||||
|
|
||||||
|
assertEquals(expectedRoot, actualRoot, "test report json file")
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `check that report generation succeeds and statistics json are generated`() {
|
fun `check that report generation succeeds and statistics json are generated`() {
|
||||||
val mapper = ObjectMapper()
|
val mapper = ObjectMapper()
|
||||||
|
|
|
@ -67,7 +67,7 @@ Summary
|
||||||
<li><pr>6274</pr> Change references to old MySQL driver to new class <code>com.mysql.cj.jdbc.Driver</code></li>
|
<li><pr>6274</pr> Change references to old MySQL driver to new class <code>com.mysql.cj.jdbc.Driver</code></li>
|
||||||
<li><issue>6352</issue> Calculate delays in Open Model Thread Group and Precise Throughput
|
<li><issue>6352</issue> Calculate delays in Open Model Thread Group and Precise Throughput
|
||||||
Timer relative to start of Thread Group instead of the start of the test.</li>
|
Timer relative to start of Thread Group instead of the start of the test.</li>
|
||||||
<li><issue>6357</issue> Ensure writable directories when copying template files while report generation.</li>
|
<li><issue>6357</issue><pr>6358</pr> Ensure writable directories when copying template files while report generation.</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<!-- =================== Thanks =================== -->
|
<!-- =================== Thanks =================== -->
|
||||||
|
|
Loading…
Reference in New Issue