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

Add RemoveState option to TestStep #118

Closed
wants to merge 12 commits into from

Conversation

vmanilo
Copy link

@vmanilo vmanilo commented Apr 20, 2023

Resolves #85

@vmanilo vmanilo requested a review from a team as a code owner April 20, 2023 20:49
@vmanilo
Copy link
Author

vmanilo commented Apr 20, 2023

@bflad I've tried to implement 2nd version of your proposal, could you have a look?

@vmanilo
Copy link
Author

vmanilo commented Apr 27, 2023

hey guys, what do you think about this changes?

@bendbennett could you help with review?

@bendbennett
Copy link
Contributor

Hi @vmanilo 👋

I've added the triage label to this PR. We will discuss the changes that you have proposed in an upcoming Team triage meeting.

@frezbo
Copy link

frezbo commented May 11, 2023

anything pending to get this change merged in? Would love to have this to test upgrade suites

@frezbo
Copy link

frezbo commented May 31, 2023

Hi, any plans to get this in?

@bendbennett
Copy link
Contributor

@frezbo apologies but have still to triage this issue. We will provide an update once the team have had a chance to review the proposed changes.

@frezbo
Copy link

frezbo commented Jun 1, 2023

@frezbo apologies but have still to triage this issue. We will provide an update once the team have had a chance to review the proposed changes.

Thank you ❤️

@Budlee
Copy link

Budlee commented Jun 11, 2023

Is there a temporary fix for this as I see the upstream is not being triaged yet

Copy link
Member

@austinvalle austinvalle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi there @vmanilo 👋🏻 , thanks for submitting this change.

Taking a quick high level look at this PR, we'll need a couple things before we can approve:

From #85

In this scenario, the following validation should be performed:

  • RemoveState is not present in the same TestStep as Config: "not empty", ImportState: true, or RefreshState: true
  • RemoveState is not present in the first TestStep of TestCase.Steps, similar to RefreshState

@vmanilo vmanilo requested a review from austinvalle June 18, 2023 21:21
@vmanilo
Copy link
Author

vmanilo commented Jun 18, 2023

hey @austinvalle
thank you for the inputs, I've updated PR

@vmanilo
Copy link
Author

vmanilo commented Jun 27, 2023

hey guys 👋

any updates?

Copy link
Member

@austinvalle austinvalle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for making those updates @vmanilo ! This is looking good so far, two notes:

@@ -476,6 +476,12 @@ type TestStep struct {
// resources in the root module path.
Taint []string

// RemoveState list of resource addresses to be removed from state after
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// RemoveState list of resource addresses to be removed from state after
// RemoveState is a list of resource addresses to be removed from state after

// applying config. Be sure to only include this at a step where the referenced
// address will be present in state, as it will fail the test if the resource
// is missing.
RemoveState []string
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would make sense to move this definition under the comments mentioning Test modes on line 486. As the intention is for this RemoveState option to be it's own "mode".

Maybe also adding to this doc comment that RemoveState is not meant to be used in the same TestStep with other modes like Config or ImportState?

@austinvalle
Copy link
Member

austinvalle commented Jun 28, 2023

Oh! I forgot, a new changelog entry will also be needed for this. We use a tool called changie, you can read about in our contributing docs. I think this falls into the enhancement category, here is a recent PR with some examples of changelogs.

@austinvalle austinvalle added the waiting-response Issues or pull requests waiting for an external response label Jul 10, 2023
@vmanilo vmanilo requested a review from austinvalle July 14, 2023 04:58
@vmanilo
Copy link
Author

vmanilo commented Jul 14, 2023

hey @austinvalle 👋

I've addressed your proposals, please take a look

@github-actions github-actions bot removed the waiting-response Issues or pull requests waiting for an external response label Jul 14, 2023
@vmanilo
Copy link
Author

vmanilo commented Jul 25, 2023

guys, when someone has time, please take a look

Copy link
Member

@austinvalle austinvalle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for making those changes @vmanilo and I appreciate the patience. I made a couple suggestions to change the wording (which I believe I can commit, but wanted to make them as suggestions), but everything else looks good 👍🏻 .

We have a couple other features merging to plugin-testing this week, so I'm hoping to get this merged in alongside or following those.

website/docs/plugin/testing/acceptance-tests/teststep.mdx Outdated Show resolved Hide resolved
website/docs/plugin/testing/acceptance-tests/teststep.mdx Outdated Show resolved Hide resolved
@vmanilo
Copy link
Author

vmanilo commented Jul 25, 2023

thank you @austinvalle, this wording change looks good to me :)

@austinvalle
Copy link
Member

Hi there @vmanilo, sorry about the slow responses, but we've been discussing this PR internally and we've decided that we want to hold off on merging any additional functionality to the TestStep struct in terraform-plugin-testing where we can avoid it. Apologies for the back and forth review process beforehand and for any wasted effort in the development of the PR.

I'll be closing this PR, but will also provide some of our thoughts on state removal in general for testing and what upcoming solutions should help.


State removal is/should be a very exceptional behavior for provider testing. For better or worse, most managed resources that operate as singletons support “import on create” like behavior and automatically do state removal behavior rather than destroying anything.

In the near/medium term (current forecast looks like 1.7, so later this year), terraform will support the ability to unmanage resources (e.g. the equivalent of state rm) by putting something in the configuration and it’ll be part of the plan like everything else, similar to the import block introduced in 1.5. This means it would be feasible to write another Config step that applies the state removal without any testing framework changes.

As for the matter of TestStep and terraform-plugin-testing, we are currently exploring refactoring of this interface as developers are trying to deal with the testing framework’s lack of ability to have a “wrapping” configuration/environment for their test steps (examples: #70, #82). As we design this solution we're trying to reduce the amount of functionality that we need to support in TestStep where possible.

Again, apologies for the back and forth on this PR.

@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 31, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Acceptance testing: Ability to prevent a resource being deleted at the end of a TestCase
5 participants