-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
helper/resource: Refresh during plan rather than separately and remov…
…e state shimming when possible (#223) Reference: hashicorp/terraform-plugin-sdk#515 Reference: #194 Reference: #222 Reference: https://developer.hashicorp.com/terraform/cli/commands/refresh This change replaces the usage of explicit refresh commands by instead calling the next command with the relevant refresh flags. Separating the refresh from plan was previously done with the idea that the testing logic may introduce further assertion hooks based on that explicit refresh. Over time though, the Terraform recommendations for refreshing and planning have solidified around always recommending to use a plan with behavior changing flags as necessary. Even the Terraform CLI implementation of the refresh command itself has been shifted to call a plan with special flags. This should reduce testing times decently as it means that the testing logic will skip spinning up and tearing down any relevant providers two times per `TestStep` and whatever time would be associated with Terraform CLI loading for those commands. Comparing the testing performed across this Go module: Prior: `TF_ACC=1 go test -count=1 ./... 111.07s user 59.37s system 233% cpu 1:12.99 total` Now: `TF_ACC=1 go test -count=1 ./... 90.81s user 48.25s system 229% cpu 1:00.54 total` The separated refresh also prevented `PreApply` plan checks from catching certain situations because the refreshed state could cause the plan to be missing changes.
- Loading branch information
Showing
3 changed files
with
68 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
kind: ENHANCEMENTS | ||
body: 'helper/resource: Removed separate refresh commands, which increases testing | ||
performance' | ||
time: 2023-11-22T11:54:02.542726-05:00 | ||
custom: | ||
Issue: "223" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters