Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

helper/acctest: Fix RandIntRange function #17438

Closed
wants to merge 1 commit into from
Closed

helper/acctest: Fix RandIntRange function #17438

wants to merge 1 commit into from

Conversation

aeriff
Copy link

@aeriff aeriff commented Feb 26, 2018

RandIntRange should return integers within the range of min...max, not within the range of 0...(max - min).

I ran into this while working on hashicorp/terraform-provider-aws#2861. As far as I can tell all other uses within at least the AWS provider are not affected by this bug because any random integer is acceptable in those resources, however for the linked PR, it must be within a specific range.

RandIntRange should return integers within the range of min-max, not within
the range of 0-(max - min).
@ewbankkit
Copy link
Contributor

Strictly, this change would break backwards-compatibility.
It may be better to use acctest.RandIntRange(min, max) + min in code that needs this functionality.
I agree that RandIntRange is a confusing name for what the function does currently.

@mildwonkey mildwonkey requested a review from a team August 1, 2019 19:46
@teamterraform
Copy link
Contributor

Hi @aeriff
while we agree that this is a bug, fixing it would require breaking backwards-compatibility, as @ewbankkit mentioned.

The SDK, including the test framework with this function is due for some bigger changes and a window of opportunity may open in the future to introduce breaking changes in more transparent way. We will share more details about this project 🔜.

Thank you for your understanding in the meantime and sorry for any inconvenience caused by this.

We also filed an issue, so we don't forget to address this when the time comes.
https://github.com/hashicorp/terraform/issues/22394

@ghost
Copy link

ghost commented Sep 8, 2019

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Sep 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants