Skip to content
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

Add terraform-plugin-mux@v0.5.0 testing providers #44

Merged
merged 5 commits into from
Feb 22, 2022

Conversation

bflad
Copy link
Contributor

@bflad bflad commented Feb 15, 2022

Closes #42
Reference: hashicorp/terraform-plugin-mux#50
Reference: hashicorp/terraform-plugin-mux#51

This adds integration testing providers for the following terraform-plugin-mux packages:

  • tf5muxserver
  • tf5to6server
  • tf6muxserver
  • tf6to5server

The underlying providers are mainly decoupled duplicates of the existing frameworkprovider and sdkv2provider to prevent unintended changes across all the tests.

Dependencies updated via:

# required for latest terraform-plugin-go usage until terraform-plugin-framework v0.6.0 is released
# and to include fix https://github.com/hashicorp/terraform-plugin-framework/pull/263
go get github.com/hashicorp/terraform-plugin-framework@bflad-UpgradeResourceState-Msgpack

Reference: #42
Reference: hashicorp/terraform-plugin-mux#50
Reference: hashicorp/terraform-plugin-mux#51

This adds integration testing providers for the following terraform-plugin-mux packages:

- tf5muxserver
- tf5to6server
- tf6muxserver
- tf6to5server

The underlying providers are mainly decoupled duplicates of the existing frameworkprovider and sdkv2provider to prevent unintended changes across all the tests.

The `tf5muxserver` and `tf6muxserver` testing currently highlights the issue reported in hashicorp/terraform-plugin-mux#51:

```
--- FAIL: TestAccResourceUser (0.42s)
    provider_test.go:11: Step 1/1 error: Error running pre-apply refresh: exit status 1

        Error: Invalid provider configuration

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

        Error: Plugin error

          with provider["registry.terraform.io/hashicorp/tf5muxprovider"],
          on <empty> line 0:
          (source code not available)

        The plugin returned an unexpected error from
        plugin.(*GRPCProvider).ValidateProviderConfig: rpc error: code = Unknown desc
        = got a PrepareProviderConfig PreparedConfig response from multiple servers,
        not sure which to use
FAIL
FAIL    github.com/hashicorp/terraform-provider-corner/internal/tf5muxprovider  0.859s

--- FAIL: TestAccResourceUser (0.51s)
    provider_test.go:11: 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/tf6muxprovider" requires explicit
        configuration. Add a provider block to the root module and configure the
        provider's required arguments as described in the provider documentation.

FAIL
FAIL    github.com/hashicorp/terraform-provider-corner/internal/tf6muxprovider  2.914s
```

Which will require upstream updates in terraform-plugin-mux before it will pass.

Dependencies updated via:

```shell
# required for latest terraform-plugin-go usage until v0.6.0 is released
go get github.com/hashicorp/terraform-plugin-framework@main
go get github.com/hashicorp/terraform-plugin-mux@v0.5.0
```
Temporarily point at github.com/hashicorp/terraform-plugin-mux@bflad-PreparedConfig to fix tf5muxprovider and tf6muxprovider tests. Can wait to merge this until after pointing at the published terraform-plugin-mux@v0.5.1 release.
go.mod Outdated Show resolved Hide resolved
@bflad
Copy link
Contributor Author

bflad commented Feb 16, 2022

The broken tests are dependent now on some form of resolution for hashicorp/terraform-plugin-framework#262.

bflad added a commit to hashicorp/terraform-plugin-framework that referenced this pull request Feb 17, 2022
…pgradeResourceState RPC

Reference: #42
Reference: #262
Reference: hashicorp/terraform-provider-corner#44

Terraform CLI version 0.12 through 0.14 support protocol version 5 and require the `UpgradeResourceStateResponse` type `UpgradedState` type `Msgpack` field. To support downgraded framework providers via terraform-plugin-mux `tf6to5server`, the `RawState` type `JSON` field cannot simply be passed through like the previous implementation. This change will parse the `RawState` and output it via the `tfprotov6.NewDynamicValue()` function, which will always set the `Msgpack` field.

Similar logic would have already been required as part of the larger effort to support resource versioning and upgrading resource state over time.

Passthrough of the same state of an invalid resource type should not have been previously allowed, since the provider did not implement the resource type. Regardless, Terraform CLI should not have reached this point since `GetProviderSchema` would not have returned the resource type anyways for other resource operations.

Verified via integration testing of terraform-plugin-mux `tf6to5server`, which previously returned a non-descript `EOF` error.
@bflad bflad marked this pull request as ready for review February 17, 2022 18:16
@bflad bflad requested a review from a team as a code owner February 17, 2022 18:16
@bflad bflad removed their assignment Feb 17, 2022
@bflad bflad merged commit 507647c into main Feb 22, 2022
@bflad bflad deleted the bflad-mux-v0.5.0-testing branch February 22, 2022 12:48
bflad added a commit to hashicorp/terraform-plugin-framework that referenced this pull request Feb 22, 2022
…pgradeResourceState RPC (#263)

Reference: #42
Reference: #262
Reference: hashicorp/terraform-provider-corner#44

Terraform CLI version 0.12 through 0.14 support protocol version 5 and require the `UpgradeResourceStateResponse` type `UpgradedState` type `Msgpack` field. To support downgraded framework providers via terraform-plugin-mux `tf6to5server`, the `RawState` type `JSON` field cannot simply be passed through like the previous implementation. This change will parse the `RawState` and output it via the `tfprotov6.NewDynamicValue()` function, which will always set the `Msgpack` field.

Similar logic would have already been required as part of the larger effort to support resource versioning and upgrading resource state over time.

Passthrough of the same state of an invalid resource type should not have been previously allowed, since the provider did not implement the resource type. Regardless, Terraform CLI should not have reached this point since `GetProviderSchema` would not have returned the resource type anyways for other resource operations.

Verified via integration testing of terraform-plugin-mux `tf6to5server`, which previously returned a non-descript `EOF` error.
Copy link

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 May 25, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Consider Adding terraform-plugin-mux Providers for Integration Testing
2 participants