-
Notifications
You must be signed in to change notification settings - Fork 233
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
SDK v2.23.0 provider merging causes duplicate provider test failures #1064
Comments
Hi @dghubble 👋 Thank you for reporting this and sorry the upgrade gave you unexpected issues. Just to confirm things, if you run your testing with the terraform-plugin-sdk/helper/resource/testcase_providers.go Lines 15 to 21 in fa98583
Apparently |
It might be best if we just unilaterally skipped the provider source merge if the terraform or any provider configuration blocks are found in the given configurations. |
Another workaround in your case without any changes in the SDK would be switching from the deprecated |
It doesn't show the exact configuration, but there seem to be two "matchbox" providers. That may be related to the original problem you were solving with hashicorp vs non-hashicorp.
Interesting. Yeah, I can change to |
* Providers was deprecated in favor of ProviderFactories * Workaround an issue with the terraform-plugin-sdk v2.23.0 that causes duplicate provider blocks when UnitTest.Providers is used * Update terraform-plugin-sdk from v2.22.0 to v2.23.0 Rel: hashicorp/terraform-plugin-sdk#1064
* Providers was deprecated in favor of ProviderFactories * Workaround an issue with the terraform-plugin-sdk v2.23.0 that causes duplicate provider blocks when UnitTest.Providers is used * Update terraform-plugin-sdk from v2.22.0 to v2.23.0 Rel: hashicorp/terraform-plugin-sdk#1064
@bflad we are having same issue:
we are using external providers ExternalProviders: map[string]resource.ExternalProvider{
"aws": {
Source: "hashicorp/aws",
VersionConstraint: "~> 4.0",
},
}, and provider "aws" {
region = "eu-central-1"
} switching to |
…estStep merged configuration Reference: #1064 Previously: ``` --- FAIL: TestStepMergedConfig/teststep-externalproviders-config-with-provider-block-unquoted (0.00s) /Users/bflad/src/github.com/hashicorp/terraform-plugin-sdk/helper/resource/teststep_providers_test.go:643: unexpected difference: ( """ ... // 6 identical lines } } - - provider "test" {} - provider test {} ... // 2 identical lines """ ) --- FAIL: TestStepMergedConfig/teststep-externalproviders-config-with-provider-block-quoted (0.00s) /Users/bflad/src/github.com/hashicorp/terraform-plugin-sdk/helper/resource/teststep_providers_test.go:643: unexpected difference: ( """ ... // 6 identical lines } } - - provider "test" {} - provider "test" {} ... // 2 identical lines """ ) ```
Submitted #1092, which should prevent the testing framework from adding its own provider configuration blocks if it detects a |
…estStep merged configuration (#1092) Reference: #1064 Previously: ``` --- FAIL: TestStepMergedConfig/teststep-externalproviders-config-with-provider-block-unquoted (0.00s) /Users/bflad/src/github.com/hashicorp/terraform-plugin-sdk/helper/resource/teststep_providers_test.go:643: unexpected difference: ( """ ... // 6 identical lines } } - - provider "test" {} - provider test {} ... // 2 identical lines """ ) --- FAIL: TestStepMergedConfig/teststep-externalproviders-config-with-provider-block-quoted (0.00s) /Users/bflad/src/github.com/hashicorp/terraform-plugin-sdk/helper/resource/teststep_providers_test.go:643: unexpected difference: ( """ ... // 6 identical lines } } - - provider "test" {} - provider "test" {} ... // 2 identical lines """ ) ```
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. |
SDK version
Upgrading from v2.22.0 to v2.23.0 shows the breakage. See poseidon/terraform-provider-matchbox#114
Relevant provider source code
Here's an example poseidon/terraform-provider-matchbox#114
The
Providers
field is set (required) and an HCL provider block is defined as part of the config. https://github.com/poseidon/terraform-provider-matchbox/blob/main/matchbox/resource_group_test.go#L45The provider block is added to the config by AddProviderConfig to configure the provider with neccessary credentials for testing. Overall, I think its a pretty typical situation.
What changed is that SDK v2.23.0 added merging logic for providers in #1057 (file
helper/resource/teststep_providers.go
) https://github.com/hashicorp/terraform-plugin-sdk/blob/main/helper/resource/teststep_providers.go#L16 that introduces duplication.I've been able to checkout sdk v2.23.0, add a
replace
directive togo.mod
, show it breaks my provider, revert #1057, and show the problem is resolved.Terraform Configuration Files
These details aren't important for repro, but I'll include just since the issue template asks.
Debug Output
Expected Behavior
Tests should continue working on v2.23.0 as they did on v2.22.0
Actual Behavior
SDK tests always see this as duplicated providers (although the SDK is the one adding the duplicate).
Steps to Reproduce
poseidon/terraform-provider-matchbox#114 is a great example. Rollback to v2.22.0 and it works again.
References
#1057 @bflad
The text was updated successfully, but these errors were encountered: