-
Notifications
You must be signed in to change notification settings - Fork 233
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/resource: Support Expected/Unexpected Diff Changes in TestStep #222
Comments
I was exploring how to implement a solution for hashicorp/terraform-plugin-testing#61, then found this issue, and they look very similar. As already stated in both issues, this would be much needed to detect unexpected recreations of resources, in my case to address issues like hashicorp/terraform-provider-kubernetes#769 (comment) I too like your |
Hey @bflad, as @pdecat mentioned, I think this is a duplicate of hashicorp/terraform-plugin-testing#61. I'm going to close it out to try and consolidate tracking on this, but definitely subscribe to hashicorp/terraform-plugin-testing#61 for updates. If you think these issues are distinct, let me know in a comment to this issue and we can reopen it while we investigate. |
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. |
In the resource acceptance testing framework, we run into cases where we need to test the update behaviors of a resource, however the framework does not have a method to ensure the resource update is not actually a create/destroy (
forces new resource
), which may or may not be expected.Expected Behavior
When we have acceptance testing that should only be an update, that it performs an update, not create/destroy.
Actual Behavior
Silently always passes as this is not supported at the moment. We need to manually check for create/destroy actions on update in the acceptance test debug logs to ensure we are not recreating resources.
Steps to Reproduce
e.g. in the AWS provider repository:
make testacc TEST=./aws TESTARGS='-run=TestAccAwsXXX_MyUpdateTest'
Additional Context
I'm linking to the latest reference of this issue in the AWS provider, but I have assuredly run into this myself in the past.
References
Implementation Proposal
(Sorry if this looks incorrect, its my first time diving into the diff code 😄 )
Option(s) are available on the
resource.TestStep
struct for either expected or unexpected diff actions. A few competing ideas:ExpectedDiffChanges []string
for testing all resources in theTestStep
, e.g.terraform.DiffUpdate
ExpectedDiffChanges map[string]string
for targeted diff behavior at the resource layer, e.g."resource.name": terraform.DiffUpdate
I think I lean towards the latter since it more succinctly captures what you are concerned about and could ignore other resources that are undefined in the map.
These will in turn add logic inside a test step to ensure the Terraform diff for the/all resource match, or fails the test step.
The text was updated successfully, but these errors were encountered: