Skip to content

Process only relevant variables in the testing framework#34072

Merged
liamcervante merged 1 commit intomainfrom
liamcervante/34070
Oct 16, 2023
Merged

Process only relevant variables in the testing framework#34072
liamcervante merged 1 commit intomainfrom
liamcervante/34070

Conversation

@liamcervante
Copy link
Copy Markdown
Contributor

@liamcervante liamcervante commented Oct 12, 2023

This PR adds in the concept of "relevant variables" to the testing framework. Previously, each run block would process every available variable and attempt to parse even those they had no need for. This resulted in some edge case behaviour as seen in the linked issue. Now, each run block first calculates the variables it needs, and then exclusively processes the subset of required variables.

In addition, this PR does some refactoring of the variables processing. Previously, the variables were processed in their entirety twice: once for the test itself, and then once again for the assertions after the test has finished. Now, we only process the variables once at the beginning of each run and use mutator functions FilterVariablesToConfig and AddVariablesToConfig to achieve the required configurations for the test and for processing the assertions.

Also, previously we were duplicating the defaults and conversion logic while preparing the variables for assertions. I realised I can push that processing further down the stack into the terraform package, and then reuse the existing prepareFinalInputVariableValue function instead of duplicating that logic.

The refactoring here will make future PRs easier (such as #34069) where we need to pull the variables available to the whole file. We can reuse the new function added here instead of doing this refactor at that point or adding a new function.

Fixes #34070

Target Release

1.6.2

Draft CHANGELOG entry

BUG FIXES

  • terraform test: Fix bug where terraform test was processing and including all available variables for every test rather than only the ones required for that particular test.

@liamcervante liamcervante added the 1.6-backport If you add this label to a PR before merging, backport-assistant will open a new PR once merged label Oct 12, 2023
@liamcervante liamcervante requested a review from a team October 12, 2023 14:34
@liamcervante liamcervante merged commit 5294c2b into main Oct 16, 2023
@liamcervante liamcervante deleted the liamcervante/34070 branch October 16, 2023 14:39
@github-actions
Copy link
Copy Markdown
Contributor

Reminder for the merging maintainer: if this is a user-visible change, please update the changelog on the appropriate release branch.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Dec 7, 2023

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 Dec 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

1.6-backport If you add this label to a PR before merging, backport-assistant will open a new PR once merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

terraform test parses all global variables instead of just what it needs

2 participants