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

Sleep statement in tests with VCR enabled #20916

Open
wyardley opened this issue Jan 15, 2025 · 4 comments · May be fixed by GoogleCloudPlatform/magic-modules#12785
Open

Sleep statement in tests with VCR enabled #20916

wyardley opened this issue Jan 15, 2025 · 4 comments · May be fixed by GoogleCloudPlatform/magic-modules#12785
Labels

Comments

@wyardley
Copy link

Question

It seems like SleepInSecondsForTest() is enabled for some tests that have VCR enabled. Should there be default or configurable behavior to skip the sleep if IsVcrEnabled() is True? I would imagine most cases where sleeps are needed in tests are related to cases in recording vs. replaying mode?

@slevenick
Copy link
Collaborator

Yeah, it would make sense to skip the sleep if we're in REPLAYING mode. I don't think that would cause any issues

@wyardley
Copy link
Author

I guess my questions were a) whether it makes sense to have a way to do that built in to the function, and also whether this might apply to other uses of it in the codebase?

Or would you suggest just putting a conditional in the check function for this case only?

@slevenick
Copy link
Collaborator

I only see 4 uses of this function in our tests and for 10 seconds or less each time. So not a big deal.

If we want to fix this I'd add the check for REPLAYING within this function to skip the sleep in that case

wyardley added a commit to wyardley/magic-modules that referenced this issue Jan 16, 2025
In `SleepInSecondsForTest()`, skip the sleep when `VCR_MODE` is
`REPLAYING`. This makes the assumption that the sleep is always related
to a condition that's already mitigated by the fact that we're using
prerecorded fixtures, but it could be extended later to override this
behavior if necessary.

Fixes hashicorp/terraform-provider-google#20916
@wyardley
Copy link
Author

@slevenick let me know if the PR I raised is what you had in mind. I just wanted to check first since I don't totally know what decision making was behind those other ~ 4 sleeps in the codebase.

wyardley added a commit to wyardley/magic-modules that referenced this issue Jan 17, 2025
In `SleepInSecondsForTest()`, skip the sleep when `VCR_MODE` is
`REPLAYING`. This makes the assumption that the sleep is always related
to a condition that's already mitigated by the fact that we're using
prerecorded fixtures, but it could be extended later to override this
behavior if necessary.

Fixes hashicorp/terraform-provider-google#20916
wyardley added a commit to wyardley/magic-modules that referenced this issue Jan 17, 2025
In `SleepInSecondsForTest()`, skip the sleep when `VCR_MODE` is
`REPLAYING`. This makes the assumption that the sleep is always related
to a condition that's already mitigated by the fact that we're using
prerecorded fixtures, but it could be extended later to override this
behavior if necessary.

Fixes hashicorp/terraform-provider-google#20916
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants