Skip to content

tf5muxserver/tf6muxserver: ValidateProviderConfig PrepareConfig Always Present With terraform-plugin-framework and terraform-plugin-sdk/v2 #51

@bflad

Description

@bflad

terraform-plugin-mux version

v0.5.0

Relevant provider source code

// testAccProtoV6ProviderFactories are used to instantiate a provider during
// acceptance testing. The factory function will be invoked for every Terraform
// CLI command executed to create a provider server to which the CLI can
// reattach.
var testAccProtoV6ProviderFactories = map[string]func() (tfprotov6.ProviderServer, error){
	"topquark": func() (tfprotov6.ProviderServer, error) {
		ctx := context.Background()
		providers := []func() tfprotov6.ProviderServer{
			func() tfprotov6.ProviderServer {
				return tfsdk.NewProtocol6Server(provider1.New("test")())
			},
			func() tfprotov6.ProviderServer {
				return tfsdk.NewProtocol6Server(provider2.New("test")())
			},
		}

		muxServer, err := tf6muxserver.NewMuxServer(ctx, providers...)

		if err != nil {
			return nil, err
		}

		return muxServer, nil
	},
}

func TestAccExampleDataSource(t *testing.T) {
	resource.Test(t, resource.TestCase{
		ProtoV6ProviderFactories: testAccProtoV6ProviderFactories,
		Steps: []resource.TestStep{
			// Read testing
			{
				Config: testAccExampleDataSourceConfig,
				Check: resource.ComposeAggregateTestCheckFunc(
					resource.TestCheckResourceAttr("data.topquark_example1.test", "id", "example-id"),
					resource.TestCheckResourceAttr("data.topquark_example2.test", "id", "example-id"),
				),
			},
		},
	})
}

const testAccExampleDataSourceConfig = `
data "topquark_example1" "test" {
  configurable_attribute = "example"
}

data "topquark_example2" "test" {
  configurable_attribute = "example"
}
`

Expected Behavior

$ TF_ACC=1 go test ./...
...
ok	github.com/bflad/terraform-provider-topquark/internal/muxprovider

Actual Behavior

$ TF_ACC=1 go test ./...
...
--- FAIL: TestAccExampleDataSource (0.52s)
    muxprovider_test.go:43: Step 1/1 error: Error running pre-apply refresh: exit status 1

        Error: Plugin error

        The plugin returned an unexpected error from
        plugin6.(*GRPCProvider).ValidateProviderConfig: rpc error: code = Unknown
        desc = got a ValidateProviderConfig PreparedConfig response from multiple
        servers, not sure which to use

        Error: Invalid provider configuration

        Provider "registry.terraform.io/hashicorp/topquark" requires explicit
        configuration. Add a provider block to the root module and configure the
        provider's required arguments as described in the provider documentation.

terraform-plugin-framework@v0.5.0 always copies the ValidateProviderConfig.Request.Config into ValidateProviderConfig.Response.PreparedConfig, while tf6muxserver only allows up to one response (and cannot perform equality checking).

Steps to Reproduce

  • Use terraform apply with muxed terraform-plugin-framework + terraform-plugin-framework
  • Alternatively, run acceptance testing (TF_ACC=1 go test ./...) with muxed terraform-plugin-framework + terraform-plugin-framework

References

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions