Open
Description
SDK version
{
"Path": "github.com/hashicorp/terraform-plugin-sdk/v2",
"Version": "v2.0.3"
}
Relevant provider source code
I implemented a multi-step acceptance test using the hashicups example project. Here is my fork with updated SDK dependency and the implemented acceptance test.
func TestAccResourceOrderCreateMultiStep(t *testing.T) {
steps := []resource.TestStep{}
for i := 0; i < 10; i++ {
steps = append(steps, resource.TestStep{
Config: testAccCheckHashicupsOrderConfigBasic("1", strconv.Itoa(i+1)),
})
}
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Steps: steps,
})
}
Terraform Configuration Files
resource "hashicups_order" "new" {
items {
coffee {
id = 1
}
quantity = 1 # this increments every test step
}
}
Debug Output
Expected Behavior
Tests run successfully.
Actual Behavior
An error similar to following is thrown:
resource_order_test.go:88: Step 3/100 error: Error running second post-apply plan:
Error: Failed to read directory for module
The source directory
../../../../../../../../var/folders/fz/fcd3jr3114xbcjz16cq3ld5m0000gp/T/tftest839129906/work291258601/config225439103
could not be read
Or this one:
resource_order_test.go:88: Step 3/100 error: Error running pre-apply plan:
Error: No configuration files
Plan requires configuration to be present. Planning without a configuration
would mark everything for destruction, which is normally not what is desired.
If you would like to destroy everything, run plan with the -destroy option.
Otherwise, create a Terraform configuration file (.tf file) and try again.
This error seems to occur randomly at different steps (e.g. post-apply refresh).
After further investigation I found that this bug seems to be connected to the default tmp folder (TMPDIR) provided by the OS.
Steps to Reproduce
# 1. clone repo and cd into it
$ git clone https://github.com/gnarlex/terraform-provider-hashicups.git
$ cd terraform-provider-hashicups
# 2. update vendor folder (wanted to keep the commits small)
$ go mod vendor
# 3. start hashicups api in seperate terminal window in current working directory
$ cd docker-compose && docker_compose up
# 4. create example user and export login credentials
$ curl -X POST localhost:19090/signup -d '{"username":"education", "password":"test123"}'
$ export HASHICUPS_USERNAME=education
$ export HASHICUPS_PASSWORD=test123
# 5. run acceptance tests
$ make testacc
# this should fail
# 6. now create a temporary folder for the acc. tests
$ mkdir tmp
# 7. run acc. tests again with TMPDIR env variable set to created folder
$ TMPDIR=$(pwd)/tmp make testacc
# this should run
Additional Information
I don't know if this bug is OS-, machine- or version-specific and I don't have the resources to investigate this further unfortunately.
- OS: MacOS Catalina
- Architecture: amd64
- Terraform Version: v0.13.3