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

Merge new dependency handling from terraform core #384

Closed
magodo opened this issue Apr 12, 2020 · 8 comments
Closed

Merge new dependency handling from terraform core #384

magodo opened this issue Apr 12, 2020 · 8 comments
Assignees
Labels
enhancement New feature or request

Comments

@magodo
Copy link

magodo commented Apr 12, 2020

There are some dependency issues are fixed in hashicorp/terraform#23252, while this currently seems not merged into SDK yet. Is there any chance to get it merged so that provider code do not need to introduce workaround for the dependency bugs.

References

@magodo magodo added the enhancement New feature or request label Apr 12, 2020
@paultyng
Copy link
Contributor

The binary testing driver eliminates the need to update TF core logic in the acceptance testing framework in this SDK. v2 eliminates the in process TF approximation entirely to avoid issues like this where the SDK or included version of Terraform drifts from the CLI code. It would be better to work towards using the binary testing driver instead and then you can invoke whatever version of Terraform core you want for testing.

@paultyng paultyng self-assigned this Apr 12, 2020
@paultyng paultyng added the waiting-response Issues or pull requests waiting for an external response label Apr 12, 2020
@magodo
Copy link
Author

magodo commented Apr 13, 2020

@paultyng Thank you for the quick reply! I'm not sure what does "binary testing driver" means? The dependency issues addressed by that PR still exist in other providers (e.g. azurerm), no matter you are using terraform from CLI or running via acceptance test (even with latest SDK version).

@ghost ghost removed waiting-response Issues or pull requests waiting for an external response labels Apr 13, 2020
@paultyng
Copy link
Contributor

paultyng commented Apr 13, 2020

@magodo yeah, sorry I wasn't clear, the documentation is trailing a little here, but I queued up some issues to address it this week. Here is the PR for the original binary test driver: #262 and here is a PR I just created to add some preliminary package docs: #385

The goal with this test driver is to remove all of the "emulation" for Terraform CLI from the SDK testing packages and completely separate this repo from the core repo at a dependency level. This also ensures our testing is much more representative of the real world (we discovered some instances where tests returned false positives that failed in a CLI around importing, for example).

Its backwards compatible, so you don't need to change your test code (although you need to add some code to a TestMain), but instead of using the in module copy of Terraform core code, it:

  1. optionally downloads a Terraform binary (or uses one on path)
  2. writes the test step configs out to a temporary dir
  3. runs plan/apply/import, etc, with the binary, reading state back in as JSON for your checks

So this completely decouples the new acc testing framework from the CLI repo for test running, which means we no longer need to sync these packages (as they are only used during testing here, not during provider runtime). But it can also enable some nice things, like running with pre-release TF versions or a matrix test against TF versions, etc. We plan to hopefully use it to test state migrations and other things over time.

I do see one line of code in here that is reproduced in our shims, but not sure if it matters or not, I will dig in to it with the core team just to clarify: https://github.com/hashicorp/terraform/pull/23252/files#diff-4964cd37aa1c7c8e29a787ee55b086de

@paultyng
Copy link
Contributor

paultyng commented Apr 13, 2020

While this framework is opt-in, we do still maintain duplicates of this core code of course, but in v2 (currently in dev on the version2 branch), it is no longer optional and instead mandatory, as v2 drops all the code dependencies. So while it does look like this code is present in other providers, as they switch to the binary testing driver, its no longer executed.

@magodo
Copy link
Author

magodo commented Apr 14, 2020

@paultyng Thank you so much for the context clarification!
So does it mean the only reason of terraform directory exists in SDK is to support acctest?

@paultyng
Copy link
Contributor

Yes, correct, the majority of the Terraform core code that is replicated here is solely to run acceptance testing.

@magodo
Copy link
Author

magodo commented Apr 21, 2020

Thank you for explaining the details 👏
Close it now.

@ghost
Copy link

ghost commented May 22, 2020

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 May 22, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants