Terraform Acceptance Tests: "Error: Failed to read file"

Viewed 647

I started writing acceptance tests for a terraform provider plugin.

Whenever I run them with TF_ACC=1 go test ./... -v -parallel=4, I randomly get errors like following:

Step i/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

Running these tests subsequently throws similar errors at different steps.

The resources are correctly created, updated and destroyed during the test though.

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?

EDIT:

I also recreated the problem with the hashicups example plugin, adding the following acceptance test:

func TestAccResourceOrderCreateMultiStep(t *testing.T) {
    steps := []resource.TestStep{}
    for i := 0; i < 100; i++ {
        steps = append(steps, resource.TestStep{
            Config: testAccCheckHashicupsOrderConfigBasic(i + 1, 1),
        })
    }

    resource.ParallelTest(t, resource.TestCase{
        PreCheck:  func() { testAccPreCheck(t) },
        Providers: testAccProviders,
        Steps:     steps,
    })
}
0 Answers
Related