Skip to content

helper/resource: compatibility refresh after config mode test step #496

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

bbasata
Copy link
Contributor

@bbasata bbasata commented May 2, 2025

Background: #269

This change is intended to unlock an upgrade path from v1.5.1 to latest v1.13.1.

When RefreshAfterApply is set to non-empty via a build flag, a Config-mode test step will invoke a refresh before successful completion. This is intended as a compatibility measure for test cases that have different -- but semantically-equal -- state representations in their test steps. When comparing two states, the testing framework is not aware of semantic equality or set equality, as that would rely on provider logic.

A Config-mode test step that is followed by a Refresh-mode test step will not incur an extra refresh. This is a backward-compatible way for a provider to eventually remove the compatibility flag – existing tests can be updated to explicitly refresh, incrementally.

cc: @BBBmau: I'd definitely like to get feedback from the provider team before shipping this. And it would be helpful to try this on a feature branch & see if it introduces any test failures.

@bbasata bbasata requested a review from a team as a code owner May 2, 2025 15:19
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.

Yeah, like we chatted about offline, if this can be a stop gap before #327 is actually resolved, I'm on board 👍🏻

Other related issues and the original change:

@bbasata bbasata requested a review from a team as a code owner May 22, 2025 23:06
// semantically-equal -- state representations in their test steps. When
// comparing two states, the testing framework is not aware of semantic
// equality or set equality, as that would rely on provider logic.
var RefreshAfterApply string
Copy link
Contributor Author

@bbasata bbasata May 22, 2025

Choose a reason for hiding this comment

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

This acts as a build-time feature flag. The thought is that you'd add this as an ldflags value in a testacc Make target:

-X github.com/hashicorp/terraform-plugin-testing/helper/resource. RefreshAfterApply=unlocked

The ldflags bit is a weakly-held opinion. I would be receptive to using a TF_* environment variable instead.


package resource

// Deprecated. This is an undocumented compatibility flag. When
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Deprecated

This is about the flexibility to remove this flag some day. There is no timetable or specific urgency for that. If we get feedback that this flag is super effective & we do not come up with a better alternative in the future, then I have no desire to break it 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants