Gatling Test Failed : Read Only FileSystem

Team,
We are trying to run gatling maven plugin using the command mvn gatling:test .Our Container’s filesystem is set to readOnly because of some limitation. When we tried to run the above mvn command (mvn gatling:test), We are getting the below error:

[ERROR] Failed to execute goal io.gatling:gatling-maven-plugin:3.1.1:test (default-cli) on project : Gatling failed.: Read-only file system → [Help 1].

Could you please suggest any workaround to avoid or skip this error.

Thanks and Regards,
Gaurav

Hey!

Did you manage to solve your issue?

On my side, I manage to reproduce something like what you described:

$ git clone git@github.com:gatling/gatling-maven-plugin-demo.git
$ cd gatling-maven-plugin-demo
$ docker run -it --rm -w "/maven-demo" -v "$(pwd)":"/maven-demo":ro maven mvn gatling:test -Dgatling.simulationClass=computerdatabase.BasicSimulation
[INFO] Scanning for projects...
[[...snip download lines..]]

[INFO] 
[INFO] -------------< io.gatling.demo:gatling-maven-plugin-demo >--------------
[INFO] Building gatling-maven-plugin-demo 3.6.1
[INFO] --------------------------------[ jar ]---------------------------------
[[...snip download lines..]]

[INFO]
[INFO] --- gatling-maven-plugin:3.1.2:test (default-cli) @ gatling-maven-plugin-demo ---
[[...snip download lines..]]

19:03:50.347 [ERROR] i.g.c.ZincCompiler$ - error writing /maven-demo/target/test-classes/Engine$.class: java.nio.file.FileSystemException /maven-demo/target/test-classes/Engine$.class: Read-only file system

19:03:50.348 [ERROR] i.g.c.ZincCompiler$ - error writing /maven-demo/target/test-classes/Engine.class: java.nio.file.FileSystemException /maven-demo/target/test-classes/Engine.class: Read-only file system
19:03:50.348 [ERROR] i.g.c.ZincCompiler$ - error writing /maven-demo/target/test-classes/Engine$delayedInit$body.class: java.nio.file.FileSystemException /maven-demo/target/test-classes/Engine$delayedInit$body.class: Read-only file system
19:03:50.348 [ERROR] i.g.c.ZincCompiler$ - error writing /maven-demo/target/test-classes/IDEPathHelper$.class: java.nio.file.FileSystemException /maven-demo/target/test-classes/IDEPathHelper$.class: Read-only file system
19:03:50.348 [ERROR] i.g.c.ZincCompiler$ - error writing /maven-demo/target/test-classes/IDEPathHelper.class: java.nio.file.FileSystemException /maven-demo/target/test-classes/IDEPathHelper.class: Read-only file system
19:03:50.348 [ERROR] i.g.c.ZincCompiler$ - error writing /maven-demo/target/test-classes/Recorder$.class: java.nio.file.FileSystemException /maven-demo/target/test-classes/Recorder$.class: Read-only file system
19:03:50.348 [ERROR] i.g.c.ZincCompiler$ - error writing /maven-demo/target/test-classes/Recorder.class: java.nio.file.FileSystemException /maven-demo/target/test-classes/Recorder.class: Read-only file system
19:03:50.348 [ERROR] i.g.c.ZincCompiler$ - error writing /maven-demo/target/test-classes/Recorder$delayedInit$body.class: java.nio.file.FileSystemException /maven-demo/target/test-classes/Recorder$delayedInit$body.class: Read-only file system
19:03:50.348 [ERROR] i.g.c.ZincCompiler$ - error writing /maven-demo/target/test-classes/computerdatabase/BasicOtherSimulation.class: java.nio.file.FileSystemException /maven-demo/target/test-classes/computerdatabase/BasicOtherSimulation.class: Read-only file system
19:03:50.348 [ERROR] i.g.c.ZincCompiler$ - error writing /maven-demo/target/test-classes/computerdatabase/BasicSimulation.class: java.nio.file.FileSystemException /maven-demo/target/test-classes/computerdatabase/BasicSimulation.class: Read-only file system
19:03:50.353 [ERROR] i.g.c.ZincCompiler$ - 10 errors found
19:03:50.355 [ERROR] i.g.c.ZincCompiler$ - Compilation crashed
sbt.internal.inc.CompileFailed: null
    at sbt.internal.inc.IncrementalCompilerImpl.handleCompilationError(IncrementalCompilerImpl.scala:335)
    at sbt.internal.inc.IncrementalCompilerImpl.compileIncrementally(IncrementalCompilerImpl.scala:420)
    at sbt.internal.inc.IncrementalCompilerImpl.compile(IncrementalCompilerImpl.scala:137)
    at io.gatling.compiler.ZincCompiler$.doCompile(ZincCompiler.scala:257)
    at io.gatling.compiler.ZincCompiler$.delayedEndpoint$io$gatling$compiler$ZincCompiler$1(ZincCompiler.scala:264)
    at io.gatling.compiler.ZincCompiler$delayedInit$body.apply(ZincCompiler.scala:41)
    at scala.Function0.apply$mcV$sp(Function0.scala:39)
    at scala.Function0.apply$mcV$sp$(Function0.scala:39)
    at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:17)
    at scala.App.$anonfun$main$1(App.scala:76)
    at scala.App.$anonfun$main$1$adapted(App.scala:76)
    at scala.collection.IterableOnceOps.foreach(IterableOnce.scala:563)
    at scala.collection.IterableOnceOps.foreach$(IterableOnce.scala:561)
    at scala.collection.AbstractIterable.foreach(Iterable.scala:919)
    at scala.App.main(App.scala:76)
    at scala.App.main$(App.scala:74)
    at io.gatling.compiler.ZincCompiler$.main(ZincCompiler.scala:41)
    at io.gatling.compiler.ZincCompiler.main(ZincCompiler.scala)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:567)
    at io.gatling.mojo.MainWithArgsInFile.runMain(MainWithArgsInFile.java:53)
    at io.gatling.mojo.MainWithArgsInFile.main(MainWithArgsInFile.java:34)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  10.207 s
[INFO] Finished at: 2021-07-26T19:03:50Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal io.gatling:gatling-maven-plugin:3.1.2:test (default-cli) on project gatling-maven-plugin-demo: Could not record simulation results.: /maven-demo/target/gatling/lastRun.txt: Read-only file system -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] [http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException](http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException)

Maven needs a writing place to put the compiled classes, and gatling will need a place to write the reports.
We NEED a writable place somewhere.

You can either create a writable volume “target” in your project directory (maven should only write in this directory)
Eg:

$ docker run -it --rm -w "/maven-demo" -v "$(pwd)":"/maven-demo":ro -v /maven-demo/target maven mvn gatling:test -Dgatling.simulationClass=computerdatabase.BasicSimulation

Note the second -v argument.

Or configure a profile for maven to explain where to put this target directory (Manage directories and its maven best practice not to change this in the pom but in a profile only activated for your CI).

Hope that helps!
Cheers!

Hello Sebastien,
Thanks for your reply.
We are running Gatling in kubernetes enabling readOnlyFileSystem=true under securityContext.
As you mentioned a writable place for both maven and gatling, We moved everything to an emptyDir having read, write and execute permission.
When we run the mvn gatling:test again, We faced the same error again.

We tried to trace the error and found the error is coming from the below Class.

Caused by: java.io.IOException: Read-only file system
at java.io.UnixFileSystem.createFileExclusively (Native Method)
at java.io.File.createTempFile (File.java:2129)
at java.io.File.createTempFile (File.java:2175)
at io.gatling.mojo.MojoUtils.createBooterJar (MojoUtils.java:78)
at io.gatling.mojo.Fork.run (Fork.java:146)
at io.gatling.mojo.GatlingMojo.executeCompiler (GatlingMojo.java:279)
at io.gatling.mojo.GatlingMojo.execute (GatlingMojo.java:185)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:566)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)

I am extremely sorry as I cannot give you the whole log file because of our company policies. Could you please check what it is exactly and throwing this error. It would be very helpful.

Kind Regards,
Gaurav

Hi,

Source code of the plugin
Perhaps something about the system /tmp directory?

Cheers!