artilleryio / artillery

The complete load testing platform. Everything you need for production-grade load tests. Serverless & distributed. Load test with Playwright. Load test HTTP APIs, GraphQL, WebSocket, and more. Use any Node.js module.
https://www.artillery.io
Mozilla Public License 2.0
8.04k stars 511 forks source link

console-reporter cannot handle scenerio names greater than 60 characters #1152

Closed adregan closed 3 years ago

adregan commented 3 years ago

Bug:

When running artillery with a scenario with a longer name, you will encounter the following error:

(node:1248) UnhandledPromiseRejectionWarning: RangeError: Invalid count value
    at String.repeat (<anonymous>)
    at padded (/home/node/.npm/_npx/1248/lib/node_modules/artillery/lib/console-reporter.js:165:38)

the padded function calls String.prototype.repeat() which only allows positive integers from 0 to Infinity. In the event a negative number is encountered, a RangeError is thrown.

The padded fn determines the number of times to repeat the . padding by subtracting the length of the string passed in from the default length of 60. This means that when interacting with the padded function directly, any string greater than 60 characters will raise an error. You can confirm in this small proof of concept here.

padded is called 7 times; 5 of those calls have a value hardcoded for str1 that is certainly shorter than 60 chars; 2 of the calls route through trimName.

In those cases (routing through trimName), a scenario will have the the prepended core. stripped leaving the rest. So a scenario name that happens to be a bit longer, such that (s.len - 5) > 60 will lead to the RangeError.

I considered adding a failing test case and submitting a PR, but it appears that the console-reporter isn't covered by any tests.

hassy commented 3 years ago

thank you for the detailed bug report @adregan! would love a PR - no need to create a test suite for console-reporter, a unit test for just the offending function would be great 😄

adregan commented 3 years ago

PR is opened https://github.com/artilleryio/artillery/pull/1157

Let me know if you'd like me to change anything.