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

"Failed to read state plan" during acc tests using terraform-plugin-test #742

Closed
kmoe opened this issue Apr 15, 2021 · 6 comments
Closed
Labels
bug Something isn't working

Comments

@kmoe
Copy link
Member

kmoe commented Apr 15, 2021

The following issue appears in terraform-provider-kubernetes-alpha, which uses the archived terraform-plugin-test repo. It is not yet known whether this issue is reproducible with the SDKv2 plugintest package.

The following acceptance test run fails with an error:

https://github.com/hashicorp/terraform-provider-kubernetes-alpha/runs/2345992263

customresourcedefinition_test.go:41: failed to read state plan: invalid character 'c' looking for beginning of value

The failed to read state plan error text comes from RequireState() in terraform-plugin-test, which calls tf.Show(). This runs the terraform show -json command and attempts to deserialise the resultant JSON, which seems to have failed due to the command output not being valid JSON.

@kmoe kmoe added the bug Something isn't working label Apr 15, 2021
@kmoe
Copy link
Member Author

kmoe commented Apr 15, 2021

We need to look into whether github.com/hashicorp/setup-terraform, used to install Terraform to the PATH in GitHub Actions steps, causes issues if terraform_wrapper is not set to false. I suspect there may be some issues with tfexec/reattach/binary testing if the wrapper is used.

Is the invalid character 'c' error caused by the setup-terraform wrapper outputting command not found?

@phillbaker
Copy link

phillbaker commented Jul 5, 2021

I came across this issue when upgrading a separate provider that uses github actions. It looks like the default ubuntu image used by github actions has already upgraded to terraform 1.x, in my case, I needed to use hashicorp/setup-terraform to install a version less than 1.x for the tests to run.

@bflad
Copy link
Contributor

bflad commented Aug 12, 2021

@phillbaker do very recent versions of Terraform CLI work if you upgrade terraform-plugin-sdk to version 2.7.0? The terraform-exec 0.14.0 upgrade was specifically for supporting for Terraform CLI 1.0.1 and later.

@phillbaker
Copy link

I'll take a look, thanks for the hint @bflad. I was trying to avoid debugging too many things by jumping from SDK 1.x to a much higher 2.x, but that changelog certainly looks relevant 😀 .

@bflad
Copy link
Contributor

bflad commented Mar 15, 2022

Hey @kmoe 👋 Indeed when using hashicorp/setup-terraform in GitHub Actions, terraform_wrapper must be explicitly disabled at the moment. It is very likely that the next major version of that GitHub Action will no longer require that input, since it has been very confusing for practitioners expecting Terraform CLI to "just work like normal" after the installation. (The wrapper does have its own benefits so it'd likely just be flipping the default, or potentially splitting the action into separate install and optional "enhanced use case" actions.)

Relatedly, the acceptance testing documentation was very recently enhanced with GitHub Actions Workflow instructions, so hopefully developers can use that information to correctly test providers using the acceptance testing framework. 👍

@bflad bflad closed this as completed Mar 15, 2022
@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants