K6: Write files

Created on 6 Jun 2018  路  4Comments  路  Source: loadimpact/k6

I am trying to determine why certain login tests are failing. To do so I need to examine the HTML that has been returned. While I realize that I can output this to the screen via console.log, it is cleaner and easier to read if it is output to a file. Is there anyway to write to the filesystem with k6?

Thanks

Most helpful comment

Unfortunately there's no way to write directly to the filesystem. That's mostly because of security and portability concerns when dealing with the distributed cluster and cloud execution.

For easier debugging, we recently added a --logformat=raw option that doesn't output debug information in the logs. If you run k6 run --logformat=raw script.js 2> debug.html, you'd get only the things you output via console.log() in the newly created debug.html

All 4 comments

Unfortunately there's no way to write directly to the filesystem. That's mostly because of security and portability concerns when dealing with the distributed cluster and cloud execution.

For easier debugging, we recently added a --logformat=raw option that doesn't output debug information in the logs. If you run k6 run --logformat=raw script.js 2> debug.html, you'd get only the things you output via console.log() in the newly created debug.html

Thanks for the reply, I will look towards that for debugging. I guess I could also setup a collector server to record html/data as well.

Yes, it would probably be easier for debugging more complicated scenarios. Another possibility is passing things through JSON.stringify() before logging them and then parsing the resulting log with something like jq.

Closing this for now, since we don't currently plan to introduce support for writing files or other potentially unsafe operations. Logging with the --logformat=raw and --logformat=json options and the --httpdebug flag should cover most debug needs, though we can potentially reopen this issue if there's enough user demand and we decide to add some unsafe local debug execution mode in the future.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

athoune picture athoune  路  3Comments

ppcano picture ppcano  路  3Comments

Jonne picture Jonne  路  4Comments

StephenRadachy picture StephenRadachy  路  3Comments

gushengyuan picture gushengyuan  路  3Comments