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

Adding test coverage for changes to ignore data sources in imported state #1077

Merged
merged 3 commits into from
Oct 13, 2022

Conversation

bendbennett
Copy link
Contributor

@bendbennett bendbennett commented Oct 10, 2022

References: #1074

Closes: #1066
Closes: #1074

Changes in this PR are to accompany changes in #1074.
@gdavison feel free to pull these changes into your PR and we can merge it all in together.

Tests in this PR fail as expected, require changes in #1074 to pass.

I've cherry-picked @gdavison's changes from #1074 into this PR.

@bendbennett bendbennett marked this pull request as ready for review October 12, 2022 16:08
@bendbennett bendbennett requested a review from a team as a code owner October 12, 2022 16:08
Copy link
Contributor

@bflad bflad left a comment

Choose a reason for hiding this comment

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

Overall looks good, just one minor bit about how we pinpoint specific resource instances in the testing framework. 👍

@@ -1738,43 +1923,41 @@ func composeImportStateCheck(fs ...ImportStateCheckFunc) ImportStateCheckFunc {
}
}

func testExtractResourceAttrInstanceState(attributeName string, attributeValue *string) ImportStateCheckFunc {
func testExtractResourceAttrInstanceState(id, attributeName string, attributeValue *string) ImportStateCheckFunc {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Instead of fetching via the internal identifier (typically the id attribute, but not necessarily guaranteed) can we instead use the resource address string? e.g. random_string.example Reasons being:

  • This is how other testing framework "check" functions generally work
  • Resources such as this one may have duplicate resource instances with the same id
  • We're looking at making id less special in #1072

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure how we use resource address when we're using a type ImportStateCheckFunc func([]*terraform.InstanceState) error as *terraform.InstanceState just has the ID and Attributes and doesn't appear to have any reference to the resource address.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sigh, more trouble than its worth then (e.g. mapping those instance states with the resource addresses). We'll be removing these terraform bits when we take a look at the next iteration of the test framework and this isn't exported, so fine for now.

@bflad
Copy link
Contributor

bflad commented Oct 12, 2022

Please note this also needs a changelog entry before merge.

@bflad bflad added this to the v2.24.0 milestone Oct 12, 2022
@bflad bflad added bug Something isn't working subsystem/tests Issues and feature requests related to the testing framework. labels Oct 12, 2022
@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 Nov 13, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working subsystem/tests Issues and feature requests related to the testing framework.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Validation of imported resources fails in integrated test
3 participants