I wrote some acceptance tests for my terraform provider plugin. Running them with the following command worked perfectly:
TF_ACC=1 go test ./... -v -parallel=4
Recently I updated my project to use the new v2 of the Terraform-Plugin-SDK. Now whenever I run my acceptance tests I get the following errors (I simplified the output):
Step 1/n error: Error running second post-apply plan: Error: Failed to read file The file "$(TMPDIR)/tftest443/work874/config340/terraform_plugin_test.tf" could not be read Error: Failed to read directory for module The source directory $(TMPDIR)/tftest443/work874/config340 could not be read
It also seems to be somewhat random where it fails. Running the same tests again I sometimes it says the same error occurred during “running post-apply refresh”:
Step 1/n error: Error running post-apply refresh: Error: Failed to read module directory Module directory $(TMPDIR)/tftest178/work507/config547 does not exist or cannot be read.
The most confusing part: The resources are correctly created, updated and destroyed during the test.
Why do my tests keep throwing these errors although they succeed in creating the test resources? And what do I need to change to make them work again?