-
Notifications
You must be signed in to change notification settings - Fork 232
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
Validation of imported resources fails in integrated test #1066
Labels
bug
Something isn't working
Comments
This was referenced Oct 4, 2022
Closed
bendbennett
added a commit
that referenced
this issue
Oct 10, 2022
bendbennett
added a commit
that referenced
this issue
Oct 12, 2022
bendbennett
added a commit
that referenced
this issue
Oct 13, 2022
bendbennett
added a commit
that referenced
this issue
Oct 13, 2022
…tate (#1077) * Adding test coverage for changes in #1074 (#1066) * Skips data sources from both original state and imported state * Adding changelog entry (#1066) Co-authored-by: Graham Davison <[email protected]>
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I am one of the maintainers of vmware/terraform-provider-vcd. We are evaluating terraform v1.3.0 with SDK v2.23.0, and we have seen that with the updated tool many tests in our suite fail with an error as described in this issue.
With terraform up to 1.2.9, the tests run fine.
SDK version
Relevant provider source code
The problem arises when testing import , like in the test snippet here
Full test code available from datasource_vcd_catalog_test.go
Terraform Configuration Files
The kind of test that fails is the one that has a few data sources followed by one resource, usually created as a data source clone, like in the snippet below.
Debug Output
Skipped: see Root cause and fix below.
Expected Behavior
The imported fields should be validated.
Actual Behavior
All tests that use this paradigm fail with this kind of error
Steps to Reproduce
The error only happens during the import test with this kind of configuration:
See datasource_vcd_catalog_test.go for a full example.
References
N/A
Root cause and fix
I followed the code and found where the problem arises. When testing imports, the validation happens in testing_new_import_source starting at line 164.
What happens here is that, when comparing the new set with the old set, the code skips the data sources from the old set (lines 172-174) but doesn't do so for the new set.
The result is that it tries to compare the first item in the new set (which is a data source) with the only remaining non-data-source item in the old set; the comparison fails, and the validation concludes that the imported set does not contain the wanted resource.
Here is a patch that solves this particular problem:
By skipping the data sources in the new set, we only compare resources with resources, and the validation works.
The text was updated successfully, but these errors were encountered: