Skip to content

Commit

Permalink
Migrate resource ec_deployment_traffic_filter to terraform-provider-f…
Browse files Browse the repository at this point in the history
…ramework

The behavior of the default_value plan_modifier changes, so
it also applies default values when the value has been explicitly
specified before.

Unit test timeout increased.

Switch to v6 provider in tests.
  • Loading branch information
pascal-hofmann committed Sep 21, 2022
1 parent 6136a1c commit c197f28
Show file tree
Hide file tree
Showing 55 changed files with 1,265 additions and 885 deletions.
2 changes: 1 addition & 1 deletion build/Makefile.test
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ SWEEP_DIR ?= $(TEST_ACC)
SWEEP_CI_RUN_FILTER ?= ec_deployments
TEST ?= ./...
TEST_COUNT ?= 1
TESTUNITARGS ?= -timeout 10s -p 4 -race -cover -coverprofile=reports/c.out
TESTUNITARGS ?= -timeout 30s -p 4 -race -cover -coverprofile=reports/c.out
TEST_ACC ?= github.com/elastic/terraform-provider-ec/ec/acc
TEST_NAME ?= TestAcc
TEST_ACC_PARALLEL = 6
Expand Down
27 changes: 16 additions & 11 deletions ec/acc/acc_prereq.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ import (
"testing"

"github.com/hashicorp/terraform-plugin-framework/providerserver"
"github.com/hashicorp/terraform-plugin-go/tfprotov5"
"github.com/hashicorp/terraform-plugin-mux/tf5muxserver"
"github.com/hashicorp/terraform-plugin-go/tfprotov6"
"github.com/hashicorp/terraform-plugin-mux/tf5to6server"
"github.com/hashicorp/terraform-plugin-mux/tf6muxserver"

"github.com/elastic/cloud-sdk-go/pkg/api"
"github.com/elastic/cloud-sdk-go/pkg/auth"
Expand All @@ -37,16 +38,20 @@ const (
prefix = "terraform_acc_"
)

var testAccProviderFactory = protoV5ProviderFactories()

func protoV5ProviderFactories() map[string]func() (tfprotov5.ProviderServer, error) {
return map[string]func() (tfprotov5.ProviderServer, error){
"ec": func() (tfprotov5.ProviderServer, error) {
return tf5muxserver.NewMuxServer(context.Background(),
func() tfprotov5.ProviderServer {
return ec.LegacyProvider().GRPCProvider()
var testAccProviderFactory = protoV6ProviderFactories()

func protoV6ProviderFactories() map[string]func() (tfprotov6.ProviderServer, error) {
return map[string]func() (tfprotov6.ProviderServer, error){
"ec": func() (tfprotov6.ProviderServer, error) {
return tf6muxserver.NewMuxServer(context.Background(),
func() tfprotov6.ProviderServer {
upgradedSdkProvider, _ := tf5to6server.UpgradeServer(
context.Background(),
ec.LegacyProvider().GRPCProvider,
)
return upgradedSdkProvider
},
providerserver.NewProtocol5(ec.New("acc-tests")),
providerserver.NewProtocol6(ec.New("acc-tests")),
)
},
}
Expand Down
2 changes: 1 addition & 1 deletion ec/acc/datasource_deployment_basic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func TestAccDatasourceDeployment_basic(t *testing.T) {

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProtoV5ProviderFactories: testAccProviderFactory,
ProtoV6ProviderFactories: testAccProviderFactory,
CheckDestroy: testAccDeploymentDestroy,
Steps: []resource.TestStep{
{
Expand Down
4 changes: 2 additions & 2 deletions ec/acc/datasource_stack_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func TestAccDatasourceStack_latest(t *testing.T) {

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProtoV5ProviderFactories: testAccProviderFactory,
ProtoV6ProviderFactories: testAccProviderFactory,
Steps: []resource.TestStep{
{
Config: cfg,
Expand All @@ -54,7 +54,7 @@ func TestAccDatasourceStack_regex(t *testing.T) {

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProtoV5ProviderFactories: testAccProviderFactory,
ProtoV6ProviderFactories: testAccProviderFactory,
Steps: []resource.TestStep{
{
Config: cfg,
Expand Down
2 changes: 1 addition & 1 deletion ec/acc/datasource_tags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func TestAccDatasource_basic_tags(t *testing.T) {

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProtoV5ProviderFactories: testAccProviderFactory,
ProtoV6ProviderFactories: testAccProviderFactory,
CheckDestroy: testAccDeploymentDestroy,
Steps: []resource.TestStep{
{
Expand Down
2 changes: 1 addition & 1 deletion ec/acc/deployment_autoscaling_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func TestAccDeployment_autoscaling(t *testing.T) {

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProtoV5ProviderFactories: testAccProviderFactory,
ProtoV6ProviderFactories: testAccProviderFactory,
CheckDestroy: testAccDeploymentDestroy,
Steps: []resource.TestStep{
{
Expand Down
4 changes: 2 additions & 2 deletions ec/acc/deployment_basic_defaults_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func TestAccDeployment_basic_defaults(t *testing.T) {

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProtoV5ProviderFactories: testAccProviderFactory,
ProtoV6ProviderFactories: testAccProviderFactory,
CheckDestroy: testAccDeploymentDestroy,
Steps: []resource.TestStep{
{
Expand Down Expand Up @@ -162,7 +162,7 @@ func TestAccDeployment_basic_defaults_hw(t *testing.T) {

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProtoV5ProviderFactories: testAccProviderFactory,
ProtoV6ProviderFactories: testAccProviderFactory,
CheckDestroy: testAccDeploymentDestroy,
Steps: []resource.TestStep{
{
Expand Down
2 changes: 1 addition & 1 deletion ec/acc/deployment_basic_tags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func TestAccDeployment_basic_tags(t *testing.T) {

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProtoV5ProviderFactories: testAccProviderFactory,
ProtoV6ProviderFactories: testAccProviderFactory,
CheckDestroy: testAccDeploymentDestroy,
Steps: []resource.TestStep{
{
Expand Down
4 changes: 2 additions & 2 deletions ec/acc/deployment_basic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func TestAccDeployment_basic_tf(t *testing.T) {

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

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProtoV5ProviderFactories: testAccProviderFactory,
ProtoV6ProviderFactories: testAccProviderFactory,
CheckDestroy: testAccDeploymentDestroy,
Steps: []resource.TestStep{
{
Expand Down
2 changes: 1 addition & 1 deletion ec/acc/deployment_ccs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func TestAccDeployment_ccs(t *testing.T) {

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProtoV5ProviderFactories: testAccProviderFactory,
ProtoV6ProviderFactories: testAccProviderFactory,
CheckDestroy: testAccDeploymentDestroy,
Steps: []resource.TestStep{
{
Expand Down
2 changes: 1 addition & 1 deletion ec/acc/deployment_compute_optimized_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func TestAccDeployment_computeOptimized(t *testing.T) {

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProtoV5ProviderFactories: testAccProviderFactory,
ProtoV6ProviderFactories: testAccProviderFactory,
CheckDestroy: testAccDeploymentDestroy,
Steps: []resource.TestStep{
{
Expand Down
4 changes: 2 additions & 2 deletions ec/acc/deployment_dedicated_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func TestAccDeployment_dedicated_coordinating(t *testing.T) {

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProtoV5ProviderFactories: testAccProviderFactory,
ProtoV6ProviderFactories: testAccProviderFactory,
CheckDestroy: testAccDeploymentDestroy,
Steps: []resource.TestStep{
{
Expand Down Expand Up @@ -79,7 +79,7 @@ func TestAccDeployment_dedicated_master(t *testing.T) {

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProtoV5ProviderFactories: testAccProviderFactory,
ProtoV6ProviderFactories: testAccProviderFactory,
CheckDestroy: testAccDeploymentDestroy,
Steps: []resource.TestStep{
{
Expand Down
2 changes: 1 addition & 1 deletion ec/acc/deployment_docker_image_override_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func TestAccDeployment_docker_image_override(t *testing.T) {

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProtoV5ProviderFactories: testAccProviderFactory,
ProtoV6ProviderFactories: testAccProviderFactory,
CheckDestroy: testAccDeploymentDestroy,
Steps: []resource.TestStep{
{
Expand Down
2 changes: 1 addition & 1 deletion ec/acc/deployment_elasticsearch_kesytore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func TestAccDeploymentElasticsearchKeystore_full(t *testing.T) {

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProtoV5ProviderFactories: testAccProviderFactory,
ProtoV6ProviderFactories: testAccProviderFactory,
CheckDestroy: resource.ComposeAggregateTestCheckFunc(
testAccDeploymentDestroy,
testAccDeploymentElasticsearchKeystoreDestroy,
Expand Down
2 changes: 1 addition & 1 deletion ec/acc/deployment_emptyconf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func TestAccDeployment_emptyconfig(t *testing.T) {

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProtoV5ProviderFactories: testAccProviderFactory,
ProtoV6ProviderFactories: testAccProviderFactory,
CheckDestroy: testAccDeploymentDestroy,
Steps: []resource.TestStep{
{
Expand Down
2 changes: 1 addition & 1 deletion ec/acc/deployment_enterprise_search_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func TestAccDeployment_enterpriseSearch(t *testing.T) {

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProtoV5ProviderFactories: testAccProviderFactory,
ProtoV6ProviderFactories: testAccProviderFactory,
CheckDestroy: testAccDeploymentDestroy,
Steps: []resource.TestStep{
{
Expand Down
2 changes: 1 addition & 1 deletion ec/acc/deployment_extension_basic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func TestAccDeploymentExtension_basic(t *testing.T) {

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProtoV5ProviderFactories: testAccProviderFactory,
ProtoV6ProviderFactories: testAccProviderFactory,
CheckDestroy: testAccExtensionDestroy,
Steps: []resource.TestStep{
{
Expand Down
2 changes: 1 addition & 1 deletion ec/acc/deployment_extension_bundle_file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func TestAccDeploymentExtension_bundleFile(t *testing.T) {

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProtoV5ProviderFactories: testAccProviderFactory,
ProtoV6ProviderFactories: testAccProviderFactory,
CheckDestroy: testAccExtensionDestroy,
Steps: []resource.TestStep{
{
Expand Down
2 changes: 1 addition & 1 deletion ec/acc/deployment_extension_plugin_download_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func TestAccDeploymentExtension_pluginDownload(t *testing.T) {

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProtoV5ProviderFactories: testAccProviderFactory,
ProtoV6ProviderFactories: testAccProviderFactory,
CheckDestroy: testAccExtensionDestroy,
Steps: []resource.TestStep{
{
Expand Down
2 changes: 1 addition & 1 deletion ec/acc/deployment_failed_upgrade_retry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func TestAccDeployment_failed_upgrade_retry(t *testing.T) {
resName := "ec_deployment.upgrade_retry"
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProtoV5ProviderFactories: testAccProviderFactory,
ProtoV6ProviderFactories: testAccProviderFactory,
CheckDestroy: testAccDeploymentDestroy,
Steps: []resource.TestStep{
{
Expand Down
2 changes: 1 addition & 1 deletion ec/acc/deployment_hotwarm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func TestAccDeployment_hotwarm(t *testing.T) {

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProtoV5ProviderFactories: testAccProviderFactory,
ProtoV6ProviderFactories: testAccProviderFactory,
CheckDestroy: testAccDeploymentDestroy,
Steps: []resource.TestStep{
{
Expand Down
2 changes: 1 addition & 1 deletion ec/acc/deployment_integrations_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func TestAccDeployment_integrationsServer(t *testing.T) {

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProtoV5ProviderFactories: testAccProviderFactory,
ProtoV6ProviderFactories: testAccProviderFactory,
CheckDestroy: testAccDeploymentDestroy,
Steps: []resource.TestStep{
{
Expand Down
2 changes: 1 addition & 1 deletion ec/acc/deployment_memory_optimized_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func TestAccDeployment_memoryOptimized(t *testing.T) {

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProtoV5ProviderFactories: testAccProviderFactory,
ProtoV6ProviderFactories: testAccProviderFactory,
CheckDestroy: testAccDeploymentDestroy,
Steps: []resource.TestStep{
{
Expand Down
2 changes: 1 addition & 1 deletion ec/acc/deployment_observability_self_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func TestAccDeployment_observability_createWithSelfObservability(t *testing.T) {

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProtoV5ProviderFactories: testAccProviderFactory,
ProtoV6ProviderFactories: testAccProviderFactory,
CheckDestroy: testAccDeploymentDestroy,
Steps: []resource.TestStep{
{
Expand Down
2 changes: 1 addition & 1 deletion ec/acc/deployment_observability_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func TestAccDeployment_observability(t *testing.T) {

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProtoV5ProviderFactories: testAccProviderFactory,
ProtoV6ProviderFactories: testAccProviderFactory,
CheckDestroy: testAccDeploymentDestroy,
Steps: []resource.TestStep{
{
Expand Down
2 changes: 1 addition & 1 deletion ec/acc/deployment_observability_tpl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func TestAccDeployment_observabilityTpl(t *testing.T) {

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProtoV5ProviderFactories: testAccProviderFactory,
ProtoV6ProviderFactories: testAccProviderFactory,
CheckDestroy: testAccDeploymentDestroy,
Steps: []resource.TestStep{
{
Expand Down
2 changes: 1 addition & 1 deletion ec/acc/deployment_post_node_role_upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func TestAccDeployment_post_node_roles(t *testing.T) {

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProtoV5ProviderFactories: testAccProviderFactory,
ProtoV6ProviderFactories: testAccProviderFactory,
CheckDestroy: testAccDeploymentDestroy,
Steps: []resource.TestStep{
{
Expand Down
2 changes: 1 addition & 1 deletion ec/acc/deployment_pre_node_role_migration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func TestAccDeployment_pre_node_roles(t *testing.T) {

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProtoV5ProviderFactories: testAccProviderFactory,
ProtoV6ProviderFactories: testAccProviderFactory,
CheckDestroy: testAccDeploymentDestroy,
Steps: []resource.TestStep{
{
Expand Down
2 changes: 1 addition & 1 deletion ec/acc/deployment_security_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func TestAccDeployment_security(t *testing.T) {

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProtoV5ProviderFactories: testAccProviderFactory,
ProtoV6ProviderFactories: testAccProviderFactory,
CheckDestroy: testAccDeploymentDestroy,
Steps: []resource.TestStep{
{
Expand Down
2 changes: 1 addition & 1 deletion ec/acc/deployment_snapshot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func TestAccDeployment_snapshot_restore(t *testing.T) {
var esCreds creds
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProtoV5ProviderFactories: testAccProviderFactory,
ProtoV6ProviderFactories: testAccProviderFactory,
CheckDestroy: testAccDeploymentDestroy,
Steps: []resource.TestStep{
{
Expand Down
4 changes: 2 additions & 2 deletions ec/acc/deployment_traffic_filter_association_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func TestAccDeploymentTrafficFilterAssociation_basic(t *testing.T) {

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProtoV5ProviderFactories: testAccProviderFactory,
ProtoV6ProviderFactories: testAccProviderFactory,
CheckDestroy: testAccDeploymentTrafficFilterDestroy,
Steps: []resource.TestStep{
{
Expand Down Expand Up @@ -116,7 +116,7 @@ terraform {
},
{
PlanOnly: true,
ProtoV5ProviderFactories: testAccProviderFactory,
ProtoV6ProviderFactories: testAccProviderFactory,
Config: ignoreChangesCfg,
Check: checkBasicDeploymentTrafficFilterAssociationResource(
resName, resAssocName, randomName,
Expand Down
Loading

0 comments on commit c197f28

Please sign in to comment.