Acceptance Test Error: Failed to read module directory

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?

It might be the case that parallel execution creates some sort of race condition and things get deleted.

All of the large codebases i’ve worked on didn’t have parallel integration tests, because dependency on webservice you have no full control of makes isolation extremely difficult and not worth it.