hashicorp / terraform-plugin-sdk

Terraform Plugin SDK enables building plugins (providers) to manage any service providers or custom in-house solutions

Home Page:https://developer.hashicorp.com/terraform/plugin

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Migration to terraform-plugin-testing causes panic in existing test suite

bendbennett opened this issue · comments

SDK version

v2.25.0

Relevant provider source code

// n/a

Terraform Configuration Files

// n/a

Expected Behavior

Following migration to using terraform-plugin-testing all passing tests should continue to pass.

Actual Behavior

panic: /var/folders/23/p8tx31c53rd16t1pjt03zndc0000gq/T/go-build764025451/b443/provider_sdk.test flag redefined: sweep

goroutine 1 [running]:
flag.(*FlagSet).Var(0x14000030240, {0x10132b6d8, 0x140002219c0}, {0x10103ad88, 0x5}, {0x10105d47b, 0x29})
        /usr/local/go/src/flag/flag.go:982 +0x2a4
flag.(*FlagSet).StringVar(...)
        /usr/local/go/src/flag/flag.go:847
flag.(*FlagSet).String(0x1400031fb98?, {0x10103ad88, 0x5}, {0x0, 0x0}, {0x10105d47b, 0x29})
        /usr/local/go/src/flag/flag.go:860 +0x98
flag.String(...)
        /usr/local/go/src/flag/flag.go:867
github.com/hashicorp/terraform-plugin-testing/helper/resource.init()
        /Users/bdb/go/pkg/mod/github.com/hashicorp/terraform-plugin-testing@v1.1.0/helper/resource/testing.go:53 +0x44
FAIL    github.com/bendbennett/terraform-provider-playground/internal/provider_sdk      0.437s
FAIL

Steps to Reproduce

  1. Follow migration guide in any Terraform Provider that uses github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource in any "non-test" files (i.e., any files that are not _test.go).
  2. Run tests

References

thanks for this one @bendbennett ✌️ appreciate you getting to the bottom of it.

i just got around to running this in our test suite and it looks like we've still got issues.

the test suite is running on master @ 53a4ec4 and i've made the update to use the dedicated helper/retry package instead of helper/resource for retryables.

you can see the failed CI run at https://github.com/cloudflare/terraform-provider-cloudflare/actions/runs/4463622325/jobs/7839014466?pr=2272.

is there anything else i'm missing here? or have we still got the bug present?

sorry, you can disregard this 🤦 it looks like there was a bad three way merge that resulted in still using the old packages. removing those made this work as expected 🎉

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.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.