-
Notifications
You must be signed in to change notification settings - Fork 232
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
Make binary testing compatible with Terraform 0.15 #694
Conversation
Terraform 0.15 deprecates a number of CLI arguments, including the [DIR] positional argument used in terraform init and terraform apply. The binary test framework made use of these arguments as a way of working around plugin source limitations in v1. This workaround is no longer needed. The main difference here is that previously we would instantiate one tfexec.Terraform per test config file, but wd.workDir set as the working directory. Since we no longer have to symlink the plugin binary itself in wd.workDir, we can now just use wd.configDir as the Terraform working dir instead. Provider source files (testdata in directories alongside test source files) must still be symlinked into the Terraform working directory. Since this is now wd.configDir, not wd.workDir, and each wd.workDir has several wd.configDirs, this symlinking must unfortunately be carried out more often. Performance should not be impacted as we should still be symlinking only a small number of directories.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This LGTM, not sure if you want @paddycarver to take a look too.
Actually @paddycarver hold on, there seems to be a failure in the DNS provider testing. That provider may have been a bad choice. Sorting it out now. |
In fact I believe this might break certain test flows. Back to draft for now. State needs to be passed between steps more carefully. |
The test framework no longer creates a wd.configDir whenever new test config is set. This change simplifies the test directory structure and allows state to persist from one test step to the next, a fundamental assumption of the test framework.
I believe we can simplify this even further by removing config dirs altogether. This allows for Terraform state to persist automatically between test steps, as it does currently on Either way, this PR is a substantial enough change in the binary test framework that I am running tests on at least one major cloud provider to catch regressions. |
AWS TC run ongoing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
515c542 looks good to me with AWS Provider acceptance testing with Terraform CLI 0.12.30, 0.13.5, 0.14.6, 0.15.0alpha20210127, and HEAD. 🚀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes sense to me and the test runs make me more confident.
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. |
Terraform 0.15 deprecates a number of CLI arguments, including the
[DIR]
positional argument used interraform init
andterraform apply
. The binary test framework made use of these arguments as a way of working around plugin source limitations in v1. This workaround is no longer needed.The main difference here is that previously we would instantiate one
tfexec.Terraform
per test config file, butwd.workDir
set as the working directory. Since we no longer have to symlink the plugin binary itself inwd.workDir
, we can now just usewd.configDir
as the Terraform working dir instead.Provider source files (testdata in directories alongside test source files) must still be symlinked into the Terraform working directory. Since this is now
wd.configDir
, notwd.workDir
, and eachwd.workDir
has severalwd.configDirs
, this symlinking must unfortunately be carried out more often. Performance should not be impacted as we should still be symlinking only a small number of directories.Example test temp directory structure before this change:
Example test temp directory structure after this change:
Update following 515c542
In order to reinstate the automatic persistence of
terraform.tfstate
between test steps, 515c542 simplifies the test temp directory structure by removing config dirs altogether. The structure is now:where
terraform_plugin_test.tf
gets overwritten each time a new test config is set.Testing
Tested this change locally with the following providers:
terraform-provider-random
terraform-provider-archive
terraform-provider-dns
and the following Terraform versions:
master
as of 2nd February 2021 (c8f83e184b67a5f79255b2fffb86524c6c8ef811)fixes #697