apache / jmeter

Apache JMeter open-source load testing tool for analyzing and measuring the performance of a variety of services
https://jmeter.apache.org/
Apache License 2.0
8.43k stars 2.11k forks source link

`AccessDeniedException` during report generation when JMeter installation itself isn't writable #6357

Closed felixscheinost closed 1 month ago

felixscheinost commented 1 month ago

Expected behavior

Cause of the bug: Having JMeter installed via Nix.

I am trying to generate a HTML report using jmeter -g run.csv -o report

I am expecting report generation to work.

Actual behavior

Report generation fails.

A look into jmeter.log shows the following stacktrace:

org.apache.jmeter.report.dashboard.GenerationException: Data exporter "html" is unable to export data.
        at org.apache.jmeter.report.dashboard.ReportGenerator.exportData(ReportGenerator.java:389) ~[ApacheJMeter_core.jar:5.6.3]
        at org.apache.jmeter.report.dashboard.ReportGenerator.generate(ReportGenerator.java:261) ~[ApacheJMeter_core.jar:5.6.3]
        at org.apache.jmeter.JMeter.start(JMeter.java:485) [ApacheJMeter_core.jar:5.6.3]
        at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) ~[?:?]
        at java.base/java.lang.reflect.Method.invoke(Method.java:580) ~[?:?]
        at org.apache.jmeter.NewDriver.main(NewDriver.java:259) [ApacheJMeter.jar:5.6.3]
Caused by: org.apache.jmeter.report.dashboard.ExportException: Unable to process template files.
        at org.apache.jmeter.report.dashboard.HtmlTemplateExporter.export(HtmlTemplateExporter.java:457) ~[ApacheJMeter_core.jar:5.6.3]
        at org.apache.jmeter.report.dashboard.ReportGenerator.exportData(ReportGenerator.java:383) ~[ApacheJMeter_core.jar:5.6.3]
        ... 5 more
Caused by: java.nio.file.AccessDeniedException: <path>/report/content/css
        at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:90) ~[?:?]
        at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:106) ~[?:?]
        at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111) ~[?:?]
        at java.base/sun.nio.fs.UnixFileSystem.copyDirectory(UnixFileSystem.java:522) ~[?:?]
        at java.base/sun.nio.fs.UnixFileSystem.copy(UnixFileSystem.java:1051) ~[?:?]
        at java.base/sun.nio.fs.UnixFileSystemProvider.copy(UnixFileSystemProvider.java:300) ~[?:?]
        at java.base/java.nio.file.Files.copy(Files.java:1304) ~[?:?]
        at org.apache.jmeter.report.dashboard.TemplateVisitor.preVisitDirectory(TemplateVisitor.java:90) ~[ApacheJMeter_core.jar:5.6.3]
        at org.apache.jmeter.report.dashboard.TemplateVisitor.preVisitDirectory(TemplateVisitor.java:49) ~[ApacheJMeter_core.jar:5.6.3]
        at java.base/java.nio.file.Files.walkFileTree(Files.java:2792) ~[?:?]
        at java.base/java.nio.file.Files.walkFileTree(Files.java:2857) ~[?:?]
        at org.apache.jmeter.report.dashboard.HtmlTemplateExporter.export(HtmlTemplateExporter.java:455) ~[ApacheJMeter_core.jar:5.6.3]
        at org.apache.jmeter.report.dashboard.ReportGenerator.exportData(ReportGenerator.java:383) ~[ApacheJMeter_core.jar:5.6.3]

Reason for the problem:

content is copied from the installation directory of JMeter.

Installation directory of JMeter is in /nix/store, not writable.

$ which jmeter
/nix/store/m3pc9c1k98p7kxp4z64jnkhk86yhmrvn-jmeter-5.6.3/bin/jmeter

$ ls -l /nix/store/m3pc9c1k98p7kxp4z64jnkhk86yhmrvn-jmeter-5.6.3/bin/report-template
total 12
dr-xr-xr-x 5 root nixbld  160 Jan  1  1970 content
-r--r--r-- 1 root nixbld 9899 Jan  1  1970 index.html.fmkr
dr-xr-xr-x 7 root nixbld  224 Jan  1  1970 sbadmin2-1.0.7

So content dir is copied non-writable to the report directory.

Subsequent copies of the contents of content fail.

The code copying the static files to the report directory should ensure that the copied files have the necessary permissions.

You may dismiss this as a Nix-specific bug and while I agree that this is a peculiar setup, it still is perfectly sensible to have the contents of installed software be read-only when those contents aren't supposed to change.

Steps to reproduce the problem

  1. nix-shell -p jmeter
  2. Generate some .csv
  3. jmeter -g <csv> -o report

JMeter Version

5.6.3

Java Version

No response

OS Version

No response

FSchumacher commented 1 month ago

Would you be able to test #6358 and report back, whether it fixes your problem?

felixscheinost commented 1 month ago

Wow, thanks so much for the quick fix!

Also 👍 for the well-maintained build and README, I was able to build and test the project very easily.

I can confirm that the PR fixes my problem, thanks again!