Skip to content
This repository has been archived by the owner on Feb 7, 2022. It is now read-only.

RandomController index calculation can go out of range #9

Closed
robingustafsson opened this issue Feb 22, 2019 · 0 comments
Closed

RandomController index calculation can go out of range #9

robingustafsson opened this issue Feb 22, 2019 · 0 comments

Comments

@robingustafsson
Copy link
Member

The index calculation at https://github.com/loadimpact/jmeter-to-k6/blob/master/src/element/RandomController.js#L82 can go 1 above the max index. It generates the following code for a random controller with 3 sub-elements, which can generate an index value of 3:

const index = Math.floor(Math.random() * (3 + 1));
switch (index) {
  case 0:
    ...
    break;
  case 1:
    ...
    break;
  case 2:
    ...
    break;
  default:
    throw new Error("Unexpected random index: " + index);
}
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant