hashicorp / hashicorp/terraform-plugin-testing

Report "Dangling resources may exist" Error When Acceptance Testing Panics

Open
#80 0 comments 1 reaction 0 assignees View on GitHub
enhancement
Dominant language
Go
Stars
68
Forks
22
Avg merge
2d 12h
Merged PRs (30d)
1

Description

### SDK version

```
1.12.0 / 2.0.0-rc.1
```

### Use-cases

When the acceptance testing framework isn't able to properly destroy resources that were created during the test, it helpfully returns an error message notifying the developer that resources could be leftover:

```
--- FAIL: TestAccExampleThing_basic (123.45s)
testing.go:630: Error destroying resource! WARNING: Dangling resources
may exist. The full state and error is shown below.

Error: errors during refresh: (actual error here)
```

However during a panic of actual resource/SDK/Terraform code, the panic is immediately returned with no warning to the developer about potentially leftover infrastructure, which can cost real money or cause quota issues if unhandled.

### Proposal

Capture a panic in the acceptance testing of a resource (e.g. `recover()`/`panicwrap`/`grep panic:`) and return the wrapped message:

```
--- FAIL: TestAccExampleThing_basic (123.45s)
testing.go:630: Panic detected. WARNING: Dangling resources
may exist. The stacktrace is shown below.

Panic:
(panic stacktrace)
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.