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

Intermittent test failures with provider tests: ... text file busy error #429

Open
austinvalle opened this issue Feb 7, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@austinvalle
Copy link
Member

terraform-plugin-testing version

v1.11.0

Behavior

https://github.com/hashicorp/terraform-plugin-sdk/actions/runs/13107424835/job/36564475352?pr=1420#step:7:602

When running provider tests, you may encounter an intermittent error similar to below:

cannot run Terraform provider tests: error calling terraform version command: fork/exec /tmp/plugintest-terraform3455380737/terraform: text file busy

The error is being raised by the testing framework, so it's possible some of Terraform environment setup may not be thread safe, possibly related to hc-install (see referenced issue).

We had a 2nd report of this internally from the HCP provider, again from the terraform version command:
https://github.com/hashicorp/terraform-provider-hcp/actions/runs/13190402272/job/36822133356

References

@austinvalle austinvalle added the bug Something isn't working label Feb 7, 2025
@austinvalle
Copy link
Member Author

austinvalle commented Feb 13, 2025

@SBGoods And I just had an interesting conversation about this bug and I think we have a potential lead on what's causing it, but will need to be verified deeper.

terraform-plugin-testing has default logic that will attempt to find an installed version of Terraform (from your $PATH), and if it doesn't find one, it will automatically install the latest version of Terraform into a temporary directory for that single Go test run. This seems like it would be very susceptible to potential issues with running tests in parallel.

An interesting related thread on why we wouldn't have seen this issue sooner, recently GitHub actions has removed Terraform from the latest version of Ubuntu runners (24.04), which means any providers that don't explicitly setup terraform prior to running their tests would potentially start running into this issue after upgrading their GH runners. A lot of providers already setup terraform prior to running their tests, so they don't have this problem, but every error message we have seen with text file busy, has been on a temporary install of Terraform, like /tmp/plugintest-terraform3455380737/terraform

To further confirm that, the HCP provider tests don't seem to install Terraform prior to running the tests and the SDK/corner tests did not either, however we recently fixed that for an unrelated reason, so I would expect us to no longer run into this issue.


To summarize, I think this issue can be avoided by explicitly installing Terraform prior to running acceptance tests:

      # Install latest version of Terraform
      - uses: hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd # v3.1.2
        with:
          terraform_wrapper: false

Will see if we can figure out a solution to the multiple installs across go tests, but even if we do have a solution, it's unlikely that you'd want to keep re-installing the same version of Terraform / deleting them for every test 😆

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant