hashicorp / terraform-plugin-testing

Module for testing Terraform providers
Mozilla Public License 2.0
45 stars 11 forks source link

Ability to Pre-provision Resources for Acceptance Tests #70

Open KyloRilo opened 2 years ago

KyloRilo commented 2 years ago

SDK version

v2.10.1

Use-cases

I'm working on acceptance tests on a TF provider for an application that leverages aws resources. I'm trying to provision ephemeral aws resources prior to my TF provider's acceptance tests running against my service. These resources would be destroyed at the end of the testing cycle.

Attempted Solutions

Common solution appears to be writing terraform, applying it, then running the acceptance testing. For ex: https://github.com/hashicorp/terraform-provider-kubernetes/tree/main/kubernetes/test-infra

Proposal

Given that we can add ExternalProviders to acceptance testing, would we also be able to leverage these to create external resources? Much like how you can PreCheck dependencies for acceptance tests, I'd like to be able to PreCheck or PreProvision cloud dependencies that would allow for my acceptance tests to run. Here we would get the ability to keep test infrastructure localized in one testing suite, while being able to perform validation or pass along data regarding infrastructure to your acceptance testing.

References

bflad commented 1 year ago

Hi folks 👋

With the introduction of the terraform-plugin-testing module (migration guide), we are transferring feature requests relating to the helper/resource "testing framework" in the terraform-plugin-sdk repository over to the new terraform-plugin-testing repository.

Thanks again for this feature request.