Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Terraform provider framework #529

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions ec/acc/acc_prereq.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,27 @@
package acc

import (
"github.com/hashicorp/terraform-plugin-framework/providerserver"
"github.com/hashicorp/terraform-plugin-go/tfprotov5"
"net/http"
"os"
"testing"

"github.com/elastic/cloud-sdk-go/pkg/api"
"github.com/elastic/cloud-sdk-go/pkg/auth"
"github.com/elastic/terraform-provider-ec/ec"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

const (
prefix = "terraform_acc_"
)

var testAccProviderFactory = map[string]func() (*schema.Provider, error){
"ec": providerFactory,
}
var testAccProviderFactory = protoV5ProviderFactories()

func providerFactory() (*schema.Provider, error) {
return ec.Provider(), nil
func protoV5ProviderFactories() map[string]func() (tfprotov5.ProviderServer, error) {
return map[string]func() (tfprotov5.ProviderServer, error){
"ec": providerserver.NewProtocol5WithError(ec.New()),
}
}

func testAccPreCheck(t *testing.T) {
Expand Down
6 changes: 3 additions & 3 deletions ec/acc/datasource_deployment_basic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ func TestAccDatasourceDeployment_basic(t *testing.T) {
var namePrefix = secondRandomName[:22]

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: testAccProviderFactory,
CheckDestroy: testAccDeploymentDestroy,
PreCheck: func() { testAccPreCheck(t) },
ProtoV5ProviderFactories: testAccProviderFactory,
CheckDestroy: testAccDeploymentDestroy,
Steps: []resource.TestStep{
{
Config: cfg,
Expand Down
8 changes: 4 additions & 4 deletions ec/acc/datasource_stack_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ func TestAccDatasourceStack_latest(t *testing.T) {
cfg := fixtureAccStackDataSource(t, depCfg, getRegion())

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: testAccProviderFactory,
PreCheck: func() { testAccPreCheck(t) },
ProtoV5ProviderFactories: testAccProviderFactory,
Steps: []resource.TestStep{
{
Config: cfg,
Expand All @@ -53,8 +53,8 @@ func TestAccDatasourceStack_regex(t *testing.T) {
cfg := fixtureAccStackDataSource(t, depCfg, getRegion())

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: testAccProviderFactory,
PreCheck: func() { testAccPreCheck(t) },
ProtoV5ProviderFactories: testAccProviderFactory,
Steps: []resource.TestStep{
{
Config: cfg,
Expand Down
6 changes: 3 additions & 3 deletions ec/acc/datasource_tags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ func TestAccDatasource_basic_tags(t *testing.T) {
cfg := fixtureAccTagsDataSource(t, depCfg, randomName, getRegion(), defaultTemplate, testID)

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: testAccProviderFactory,
CheckDestroy: testAccDeploymentDestroy,
PreCheck: func() { testAccPreCheck(t) },
ProtoV5ProviderFactories: testAccProviderFactory,
CheckDestroy: testAccDeploymentDestroy,
Steps: []resource.TestStep{
{
Config: cfg,
Expand Down
6 changes: 3 additions & 3 deletions ec/acc/deployment_autoscaling_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ func TestAccDeployment_autoscaling(t *testing.T) {
}

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: testAccProviderFactory,
CheckDestroy: testAccDeploymentDestroy,
PreCheck: func() { testAccPreCheck(t) },
ProtoV5ProviderFactories: testAccProviderFactory,
CheckDestroy: testAccDeploymentDestroy,
Steps: []resource.TestStep{
{
Config: cfgF(startCfg),
Expand Down
12 changes: 6 additions & 6 deletions ec/acc/deployment_basic_defaults_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ func TestAccDeployment_basic_defaults(t *testing.T) {
thirdConfigCfg := fixtureAccDeploymentResourceBasicDefaults(t, thirdCfg, randomName, getRegion(), defaultTemplate)

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: testAccProviderFactory,
CheckDestroy: testAccDeploymentDestroy,
PreCheck: func() { testAccPreCheck(t) },
ProtoV5ProviderFactories: testAccProviderFactory,
CheckDestroy: testAccDeploymentDestroy,
Steps: []resource.TestStep{
{
Config: cfg,
Expand Down Expand Up @@ -161,9 +161,9 @@ func TestAccDeployment_basic_defaults_hw(t *testing.T) {
hotWarmCfg := fixtureAccDeploymentResourceBasicDefaults(t, secondCfg, randomName, getRegion(), hotWarmTemplate)

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: testAccProviderFactory,
CheckDestroy: testAccDeploymentDestroy,
PreCheck: func() { testAccPreCheck(t) },
ProtoV5ProviderFactories: testAccProviderFactory,
CheckDestroy: testAccDeploymentDestroy,
Steps: []resource.TestStep{
{
Config: cfg,
Expand Down
6 changes: 3 additions & 3 deletions ec/acc/deployment_basic_tags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ func TestAccDeployment_basic_tags(t *testing.T) {
fourthConfigCfg := fixtureAccDeploymentResourceBasicDefaults(t, fourthCfg, randomName, getRegion(), defaultTemplate)

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: testAccProviderFactory,
CheckDestroy: testAccDeploymentDestroy,
PreCheck: func() { testAccPreCheck(t) },
ProtoV5ProviderFactories: testAccProviderFactory,
CheckDestroy: testAccDeploymentDestroy,
Steps: []resource.TestStep{
{
// Create a deployment with tags.
Expand Down
12 changes: 6 additions & 6 deletions ec/acc/deployment_basic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ func TestAccDeployment_basic_tf(t *testing.T) {
}

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: testAccProviderFactory,
CheckDestroy: testAccDeploymentDestroy,
PreCheck: func() { testAccPreCheck(t) },
ProtoV5ProviderFactories: testAccProviderFactory,
CheckDestroy: testAccDeploymentDestroy,
Steps: []resource.TestStep{
{
Config: cfg,
Expand Down Expand Up @@ -98,9 +98,9 @@ func TestAccDeployment_basic_config(t *testing.T) {
}

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: testAccProviderFactory,
CheckDestroy: testAccDeploymentDestroy,
PreCheck: func() { testAccPreCheck(t) },
ProtoV5ProviderFactories: testAccProviderFactory,
CheckDestroy: testAccDeploymentDestroy,
Steps: []resource.TestStep{
{
Config: settingsConfigCfg,
Expand Down
6 changes: 3 additions & 3 deletions ec/acc/deployment_ccs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ func TestAccDeployment_ccs(t *testing.T) {
secondConfigCfg := fixtureAccDeploymentResourceBasicDefaults(t, secondCfg, ccsRandomName, getRegion(), ccsTemplate)

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: testAccProviderFactory,
CheckDestroy: testAccDeploymentDestroy,
PreCheck: func() { testAccPreCheck(t) },
ProtoV5ProviderFactories: testAccProviderFactory,
CheckDestroy: testAccDeploymentDestroy,
Steps: []resource.TestStep{
{
// Create a CCS deployment with the default settings.
Expand Down
6 changes: 3 additions & 3 deletions ec/acc/deployment_compute_optimized_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ func TestAccDeployment_computeOptimized(t *testing.T) {
secondConfigCfg := fixtureAccDeploymentResourceBasicDefaults(t, secondCfg, randomName, getRegion(), computeOpTemplate)

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: testAccProviderFactory,
CheckDestroy: testAccDeploymentDestroy,
PreCheck: func() { testAccPreCheck(t) },
ProtoV5ProviderFactories: testAccProviderFactory,
CheckDestroy: testAccDeploymentDestroy,
Steps: []resource.TestStep{
{
// Create a Compute Optimized deployment with the default settings.
Expand Down
12 changes: 6 additions & 6 deletions ec/acc/deployment_dedicated_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ func TestAccDeployment_dedicated_coordinating(t *testing.T) {
cfg := fixtureAccDeploymentResourceBasicDefaults(t, startCfg, randomName, getRegion(), hotWarmTemplate)

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: testAccProviderFactory,
CheckDestroy: testAccDeploymentDestroy,
PreCheck: func() { testAccPreCheck(t) },
ProtoV5ProviderFactories: testAccProviderFactory,
CheckDestroy: testAccDeploymentDestroy,
Steps: []resource.TestStep{
{
// Create a deployment with dedicated coordinating.
Expand Down Expand Up @@ -78,9 +78,9 @@ func TestAccDeployment_dedicated_master(t *testing.T) {
cfg := fixtureAccDeploymentResourceBasicDefaults(t, startCfg, randomName, getRegion(), hotWarmTemplate)

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: testAccProviderFactory,
CheckDestroy: testAccDeploymentDestroy,
PreCheck: func() { testAccPreCheck(t) },
ProtoV5ProviderFactories: testAccProviderFactory,
CheckDestroy: testAccDeploymentDestroy,
Steps: []resource.TestStep{
{
// Create a deployment with dedicated master nodes.
Expand Down
6 changes: 3 additions & 3 deletions ec/acc/deployment_docker_image_override_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ func TestAccDeployment_docker_image_override(t *testing.T) {
}

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: testAccProviderFactory,
CheckDestroy: testAccDeploymentDestroy,
PreCheck: func() { testAccPreCheck(t) },
ProtoV5ProviderFactories: testAccProviderFactory,
CheckDestroy: testAccDeploymentDestroy,
Steps: []resource.TestStep{
{
Config: cfgF("testdata/deployment_docker_image_override.tf"),
Expand Down
4 changes: 2 additions & 2 deletions ec/acc/deployment_elasticsearch_kesytore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ func TestAccDeploymentElasticsearchKeystore_full(t *testing.T) {
}

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: testAccProviderFactory,
PreCheck: func() { testAccPreCheck(t) },
ProtoV5ProviderFactories: testAccProviderFactory,
CheckDestroy: resource.ComposeAggregateTestCheckFunc(
testAccDeploymentDestroy,
testAccDeploymentElasticsearchKeystoreDestroy,
Expand Down
6 changes: 3 additions & 3 deletions ec/acc/deployment_emptyconf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ func TestAccDeployment_emptyconfig(t *testing.T) {
}

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: testAccProviderFactory,
CheckDestroy: testAccDeploymentDestroy,
PreCheck: func() { testAccPreCheck(t) },
ProtoV5ProviderFactories: testAccProviderFactory,
CheckDestroy: testAccDeploymentDestroy,
Steps: []resource.TestStep{
{
Config: cfgF(startCfg),
Expand Down
6 changes: 3 additions & 3 deletions ec/acc/deployment_enterprise_search_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ func TestAccDeployment_enterpriseSearch(t *testing.T) {
secondConfigCfg := fixtureAccDeploymentResourceBasicDefaults(t, secondCfg, randomName, getRegion(), enterpriseSearchTemplate)

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: testAccProviderFactory,
CheckDestroy: testAccDeploymentDestroy,
PreCheck: func() { testAccPreCheck(t) },
ProtoV5ProviderFactories: testAccProviderFactory,
CheckDestroy: testAccDeploymentDestroy,
Steps: []resource.TestStep{
{
// Create an Enterprise Search deployment with the default settings.
Expand Down
6 changes: 3 additions & 3 deletions ec/acc/deployment_extension_basic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ func TestAccDeploymentExtension_basic(t *testing.T) {
cfg2 := fixtureAccExtensionBasicWithTF(t, "testdata/extension_basic.tf", randomName, "updated desc")

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: testAccProviderFactory,
CheckDestroy: testAccExtensionDestroy,
PreCheck: func() { testAccPreCheck(t) },
ProtoV5ProviderFactories: testAccProviderFactory,
CheckDestroy: testAccExtensionDestroy,
Steps: []resource.TestStep{
{
Config: cfg,
Expand Down
6 changes: 3 additions & 3 deletions ec/acc/deployment_extension_bundle_file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ func TestAccDeploymentExtension_bundleFile(t *testing.T) {
cfg := fixtureAccExtensionBundleWithTF(t, "testdata/extension_bundle_file.tf", filePath, randomName, "desc")

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: testAccProviderFactory,
CheckDestroy: testAccExtensionDestroy,
PreCheck: func() { testAccPreCheck(t) },
ProtoV5ProviderFactories: testAccProviderFactory,
CheckDestroy: testAccExtensionDestroy,
Steps: []resource.TestStep{
{
PreConfig: func() { writeFile(t, filePath, "extension.txt", "foo") },
Expand Down
6 changes: 3 additions & 3 deletions ec/acc/deployment_extension_plugin_download_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ func TestAccDeploymentExtension_pluginDownload(t *testing.T) {
cfg := fixtureAccExtensionBundleDownloadWithTF(t, "testdata/extension_plugin_download.tf", randomName, downloadURL)

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: testAccProviderFactory,
CheckDestroy: testAccExtensionDestroy,
PreCheck: func() { testAccPreCheck(t) },
ProtoV5ProviderFactories: testAccProviderFactory,
CheckDestroy: testAccExtensionDestroy,
Steps: []resource.TestStep{
{
Config: cfg,
Expand Down
6 changes: 3 additions & 3 deletions ec/acc/deployment_failed_upgrade_retry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ func TestAccDeployment_failed_upgrade_retry(t *testing.T) {
var esCreds creds
resName := "ec_deployment.upgrade_retry"
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: testAccProviderFactory,
CheckDestroy: testAccDeploymentDestroy,
PreCheck: func() { testAccPreCheck(t) },
ProtoV5ProviderFactories: testAccProviderFactory,
CheckDestroy: testAccDeploymentDestroy,
Steps: []resource.TestStep{
{
Config: fixtureDeploymentDefaults(t, "testdata/deployment_upgrade_retry_1.tf"),
Expand Down
6 changes: 3 additions & 3 deletions ec/acc/deployment_hotwarm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ func TestAccDeployment_hotwarm(t *testing.T) {
secondConfigCfg := fixtureAccDeploymentResourceBasic(t, secondCfg, randomName, getRegion(), hotWarmTemplate)

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: testAccProviderFactory,
CheckDestroy: testAccDeploymentDestroy,
PreCheck: func() { testAccPreCheck(t) },
ProtoV5ProviderFactories: testAccProviderFactory,
CheckDestroy: testAccDeploymentDestroy,
Steps: []resource.TestStep{
{
// Create a Hot / Warm deployment with the default settings.
Expand Down
6 changes: 3 additions & 3 deletions ec/acc/deployment_integrations_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ func TestAccDeployment_integrationsServer(t *testing.T) {
secondConfigCfg := fixtureAccDeploymentResourceBasicDefaults(t, secondCfg, randomName, getRegion(), defaultTemplate)

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: testAccProviderFactory,
CheckDestroy: testAccDeploymentDestroy,
PreCheck: func() { testAccPreCheck(t) },
ProtoV5ProviderFactories: testAccProviderFactory,
CheckDestroy: testAccDeploymentDestroy,
Steps: []resource.TestStep{
{
// Create an Integrations Server deployment with the default settings.
Expand Down
6 changes: 3 additions & 3 deletions ec/acc/deployment_memory_optimized_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ func TestAccDeployment_memoryOptimized(t *testing.T) {
secondConfigCfg := fixtureAccDeploymentResourceBasicDefaults(t, secondCfg, randomName, getRegion(), memoryOpTemplate)

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: testAccProviderFactory,
CheckDestroy: testAccDeploymentDestroy,
PreCheck: func() { testAccPreCheck(t) },
ProtoV5ProviderFactories: testAccProviderFactory,
CheckDestroy: testAccDeploymentDestroy,
Steps: []resource.TestStep{
{
// Create a Memory Optimized deployment with the default settings.
Expand Down
6 changes: 3 additions & 3 deletions ec/acc/deployment_observability_self_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ func TestAccDeployment_observability_createWithSelfObservability(t *testing.T) {
config := fixtureAccDeploymentResourceSelfObs(t, configFile, randomName, getRegion(), defaultTemplate)

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: testAccProviderFactory,
CheckDestroy: testAccDeploymentDestroy,
PreCheck: func() { testAccPreCheck(t) },
ProtoV5ProviderFactories: testAccProviderFactory,
CheckDestroy: testAccDeploymentDestroy,
Steps: []resource.TestStep{
{
// Create a deployment with observability-target 'self'
Expand Down
6 changes: 3 additions & 3 deletions ec/acc/deployment_observability_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ func TestAccDeployment_observability(t *testing.T) {
fourthCfg := fixtureAccDeploymentResourceBasicObs(t, removeObsCfg, randomName, getRegion(), defaultTemplate)

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: testAccProviderFactory,
CheckDestroy: testAccDeploymentDestroy,
PreCheck: func() { testAccPreCheck(t) },
ProtoV5ProviderFactories: testAccProviderFactory,
CheckDestroy: testAccDeploymentDestroy,
Steps: []resource.TestStep{
{
Config: cfg,
Expand Down
6 changes: 3 additions & 3 deletions ec/acc/deployment_observability_tpl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ func TestAccDeployment_observabilityTpl(t *testing.T) {
secondConfigCfg := fixtureAccDeploymentResourceBasicDefaults(t, secondCfg, randomName, getRegion(), observabilityTemplate)

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: testAccProviderFactory,
CheckDestroy: testAccDeploymentDestroy,
PreCheck: func() { testAccPreCheck(t) },
ProtoV5ProviderFactories: testAccProviderFactory,
CheckDestroy: testAccDeploymentDestroy,
Steps: []resource.TestStep{
{
// Create an Observability deployment with the default settings.
Expand Down
Loading