From 544ce08227defdd6caeae78222337b23b380f590 Mon Sep 17 00:00:00 2001 From: Marco Suma Date: Wed, 24 Apr 2024 09:25:29 +0200 Subject: [PATCH 1/8] chore: Moves cluster cloud provider to GCP for data lake pipeline tests. --- .../data_source_data_lake_pipeline_test.go | 37 +++++++-------- .../data_source_data_lake_pipelines_test.go | 45 +++++++++---------- 2 files changed, 41 insertions(+), 41 deletions(-) diff --git a/internal/service/datalakepipeline/data_source_data_lake_pipeline_test.go b/internal/service/datalakepipeline/data_source_data_lake_pipeline_test.go index 2e9b9e20e9..d0df18b8c4 100644 --- a/internal/service/datalakepipeline/data_source_data_lake_pipeline_test.go +++ b/internal/service/datalakepipeline/data_source_data_lake_pipeline_test.go @@ -11,11 +11,12 @@ import ( func TestAccDataLakeDS_basic(t *testing.T) { var ( - resourceName = "mongodbatlas_data_lake_pipeline.test" - orgID = os.Getenv("MONGODB_ATLAS_ORG_ID") - projectName = acc.RandomProjectName() - clusterName = acc.RandomClusterName() - name = acc.RandomName() + resourceName = "mongodbatlas_data_lake_pipeline.test" + dataSourceName = "data.mongodbatlas_data_lake_pipeline.testDataSource" + orgID = os.Getenv("MONGODB_ATLAS_ORG_ID") + projectName = acc.RandomProjectName() + clusterName = acc.RandomClusterName() + name = acc.RandomName() ) resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { acc.PreCheckBasic(t) }, @@ -26,9 +27,9 @@ func TestAccDataLakeDS_basic(t *testing.T) { Config: configDS(orgID, projectName, clusterName, name), Check: resource.ComposeTestCheckFunc( checkExists(resourceName), - resource.TestCheckResourceAttrSet(resourceName, "project_id"), - resource.TestCheckResourceAttr(resourceName, "name", name), - resource.TestCheckResourceAttr(resourceName, "state", "ACTIVE"), + resource.TestCheckResourceAttrSet(dataSourceName, "project_id"), + resource.TestCheckResourceAttr(dataSourceName, "name", name), + resource.TestCheckResourceAttr(dataSourceName, "state", "ACTIVE"), ), }, }, @@ -42,21 +43,21 @@ func configDS(orgID, projectName, clusterName, pipelineName string) string { name = %[2]q } - resource "mongodbatlas_advanced_cluster" "aws_conf" { + resource "mongodbatlas_advanced_cluster" "gcp_conf" { project_id = mongodbatlas_project.project.id name = %[3]q cluster_type = "REPLICASET" replication_specs { - region_configs { - electable_specs { - instance_size = "M10" - node_count = 3 + region_configs { + electable_specs { + instance_size = "M10" + node_count = 3 + } + provider_name = "GCP" + priority = 7 + region_name = "NORTH_AMERICA_NORTHEAST_1" } - provider_name = "AWS" - priority = 7 - region_name = "US_EAST_1" - } } backup_enabled = true } @@ -74,7 +75,7 @@ func configDS(orgID, projectName, clusterName, pipelineName string) string { source { type = "ON_DEMAND_CPS" - cluster_name = mongodbatlas_advanced_cluster.aws_conf.name + cluster_name = mongodbatlas_advanced_cluster.gcp_conf.name database_name = "sample_airbnb" collection_name = "listingsAndReviews" } diff --git a/internal/service/datalakepipeline/data_source_data_lake_pipelines_test.go b/internal/service/datalakepipeline/data_source_data_lake_pipelines_test.go index 783752f790..36422d28b1 100644 --- a/internal/service/datalakepipeline/data_source_data_lake_pipelines_test.go +++ b/internal/service/datalakepipeline/data_source_data_lake_pipelines_test.go @@ -45,48 +45,47 @@ func configDSPlural(orgID, projectName, firstClusterName, secondClusterName, fir name = %[2]q } - - resource "mongodbatlas_advanced_cluster" "aws_conf" { + resource "mongodbatlas_advanced_cluster" "gcp_conf" { project_id = mongodbatlas_project.project.id name = %[3]q cluster_type = "REPLICASET" replication_specs { - region_configs { - electable_specs { - instance_size = "M10" - node_count = 3 + region_configs { + electable_specs { + instance_size = "M10" + node_count = 3 + } + provider_name = "GCP" + priority = 7 + region_name = "NORTH_AMERICA_NORTHEAST_1" } - provider_name = "AWS" - priority = 7 - region_name = "US_EAST_1" - } } backup_enabled = true } - resource "mongodbatlas_advanced_cluster" "aws_conf2" { + resource "mongodbatlas_advanced_cluster" "gcp_conf2" { project_id = mongodbatlas_project.project.id name = %[4]q cluster_type = "REPLICASET" replication_specs { - region_configs { - electable_specs { - instance_size = "M10" - node_count = 3 + region_configs { + electable_specs { + instance_size = "M10" + node_count = 3 + } + provider_name = "GCP" + priority = 7 + region_name = "US_EAST_4" } - provider_name = "AWS" - priority = 7 - region_name = "US_EAST_1" - } } backup_enabled = true } resource "mongodbatlas_data_lake_pipeline" "test" { - project_id = mongodbatlas_project.project.id - name = %[5]q + project_id = mongodbatlas_project.project.id + name = %[5]q sink { type = "DLS" partition_fields { @@ -97,7 +96,7 @@ func configDSPlural(orgID, projectName, firstClusterName, secondClusterName, fir source { type = "ON_DEMAND_CPS" - cluster_name = mongodbatlas_advanced_cluster.aws_conf.name + cluster_name = mongodbatlas_advanced_cluster.gcp_conf.name database_name = "sample_airbnb" collection_name = "listingsAndReviews" } @@ -121,7 +120,7 @@ func configDSPlural(orgID, projectName, firstClusterName, secondClusterName, fir source { type = "ON_DEMAND_CPS" - cluster_name = mongodbatlas_advanced_cluster.aws_conf2.name + cluster_name = mongodbatlas_advanced_cluster.gcp_conf2.name database_name = "sample_airbnb" collection_name = "listingsAndReviews" } From 476ae75d113132320f2368d427984edbbfee1126 Mon Sep 17 00:00:00 2001 From: Marco Suma Date: Wed, 24 Apr 2024 14:59:25 +0200 Subject: [PATCH 2/8] moves to azure, select UK_WEST and UK_SOUTH. --- .../data_source_data_lake_pipeline_test.go | 8 ++++---- .../data_source_data_lake_pipelines_test.go | 16 ++++++++-------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/internal/service/datalakepipeline/data_source_data_lake_pipeline_test.go b/internal/service/datalakepipeline/data_source_data_lake_pipeline_test.go index d0df18b8c4..2f524e02c6 100644 --- a/internal/service/datalakepipeline/data_source_data_lake_pipeline_test.go +++ b/internal/service/datalakepipeline/data_source_data_lake_pipeline_test.go @@ -43,7 +43,7 @@ func configDS(orgID, projectName, clusterName, pipelineName string) string { name = %[2]q } - resource "mongodbatlas_advanced_cluster" "gcp_conf" { + resource "mongodbatlas_advanced_cluster" "azure_conf" { project_id = mongodbatlas_project.project.id name = %[3]q cluster_type = "REPLICASET" @@ -54,9 +54,9 @@ func configDS(orgID, projectName, clusterName, pipelineName string) string { instance_size = "M10" node_count = 3 } - provider_name = "GCP" + provider_name = "AZURE" priority = 7 - region_name = "NORTH_AMERICA_NORTHEAST_1" + region_name = "UK_WEST" } } backup_enabled = true @@ -75,7 +75,7 @@ func configDS(orgID, projectName, clusterName, pipelineName string) string { source { type = "ON_DEMAND_CPS" - cluster_name = mongodbatlas_advanced_cluster.gcp_conf.name + cluster_name = mongodbatlas_advanced_cluster.azure_conf.name database_name = "sample_airbnb" collection_name = "listingsAndReviews" } diff --git a/internal/service/datalakepipeline/data_source_data_lake_pipelines_test.go b/internal/service/datalakepipeline/data_source_data_lake_pipelines_test.go index 36422d28b1..925691ffde 100644 --- a/internal/service/datalakepipeline/data_source_data_lake_pipelines_test.go +++ b/internal/service/datalakepipeline/data_source_data_lake_pipelines_test.go @@ -45,7 +45,7 @@ func configDSPlural(orgID, projectName, firstClusterName, secondClusterName, fir name = %[2]q } - resource "mongodbatlas_advanced_cluster" "gcp_conf" { + resource "mongodbatlas_advanced_cluster" "azure_conf" { project_id = mongodbatlas_project.project.id name = %[3]q cluster_type = "REPLICASET" @@ -56,15 +56,15 @@ func configDSPlural(orgID, projectName, firstClusterName, secondClusterName, fir instance_size = "M10" node_count = 3 } - provider_name = "GCP" + provider_name = "AZURE" priority = 7 - region_name = "NORTH_AMERICA_NORTHEAST_1" + region_name = "UK_SOUTH" } } backup_enabled = true } - resource "mongodbatlas_advanced_cluster" "gcp_conf2" { + resource "mongodbatlas_advanced_cluster" "azure_conf2" { project_id = mongodbatlas_project.project.id name = %[4]q cluster_type = "REPLICASET" @@ -75,9 +75,9 @@ func configDSPlural(orgID, projectName, firstClusterName, secondClusterName, fir instance_size = "M10" node_count = 3 } - provider_name = "GCP" + provider_name = "AZURE" priority = 7 - region_name = "US_EAST_4" + region_name = "UK_WEST" } } backup_enabled = true @@ -96,7 +96,7 @@ func configDSPlural(orgID, projectName, firstClusterName, secondClusterName, fir source { type = "ON_DEMAND_CPS" - cluster_name = mongodbatlas_advanced_cluster.gcp_conf.name + cluster_name = mongodbatlas_advanced_cluster.azure_conf.name database_name = "sample_airbnb" collection_name = "listingsAndReviews" } @@ -120,7 +120,7 @@ func configDSPlural(orgID, projectName, firstClusterName, secondClusterName, fir source { type = "ON_DEMAND_CPS" - cluster_name = mongodbatlas_advanced_cluster.gcp_conf2.name + cluster_name = mongodbatlas_advanced_cluster.azure_conf2.name database_name = "sample_airbnb" collection_name = "listingsAndReviews" } From c896a89cd7bfbcfb88a2de25c4eb9c4f03bacc5a Mon Sep 17 00:00:00 2001 From: Marco Suma Date: Wed, 24 Apr 2024 15:45:07 +0200 Subject: [PATCH 3/8] use UK_WEST only. --- .../datalakepipeline/data_source_data_lake_pipelines_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/service/datalakepipeline/data_source_data_lake_pipelines_test.go b/internal/service/datalakepipeline/data_source_data_lake_pipelines_test.go index 925691ffde..d7bf76a943 100644 --- a/internal/service/datalakepipeline/data_source_data_lake_pipelines_test.go +++ b/internal/service/datalakepipeline/data_source_data_lake_pipelines_test.go @@ -58,7 +58,7 @@ func configDSPlural(orgID, projectName, firstClusterName, secondClusterName, fir } provider_name = "AZURE" priority = 7 - region_name = "UK_SOUTH" + region_name = "UK_WEST" } } backup_enabled = true From 6f2a0579e4e0518be754cfc78e8eb147783d34f4 Mon Sep 17 00:00:00 2001 From: Marco Suma Date: Wed, 24 Apr 2024 15:46:16 +0200 Subject: [PATCH 4/8] use US_EAST_2 only. --- .../datalakepipeline/data_source_data_lake_pipeline_test.go | 2 +- .../datalakepipeline/data_source_data_lake_pipelines_test.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/service/datalakepipeline/data_source_data_lake_pipeline_test.go b/internal/service/datalakepipeline/data_source_data_lake_pipeline_test.go index 2f524e02c6..c67a5d0cc0 100644 --- a/internal/service/datalakepipeline/data_source_data_lake_pipeline_test.go +++ b/internal/service/datalakepipeline/data_source_data_lake_pipeline_test.go @@ -56,7 +56,7 @@ func configDS(orgID, projectName, clusterName, pipelineName string) string { } provider_name = "AZURE" priority = 7 - region_name = "UK_WEST" + region_name = "US_EAST_2" } } backup_enabled = true diff --git a/internal/service/datalakepipeline/data_source_data_lake_pipelines_test.go b/internal/service/datalakepipeline/data_source_data_lake_pipelines_test.go index d7bf76a943..e908dfb9f1 100644 --- a/internal/service/datalakepipeline/data_source_data_lake_pipelines_test.go +++ b/internal/service/datalakepipeline/data_source_data_lake_pipelines_test.go @@ -58,7 +58,7 @@ func configDSPlural(orgID, projectName, firstClusterName, secondClusterName, fir } provider_name = "AZURE" priority = 7 - region_name = "UK_WEST" + region_name = "US_EAST_2" } } backup_enabled = true @@ -77,7 +77,7 @@ func configDSPlural(orgID, projectName, firstClusterName, secondClusterName, fir } provider_name = "AZURE" priority = 7 - region_name = "UK_WEST" + region_name = "US_EAST_2" } } backup_enabled = true From dc70d5e0be389fbc59be87d06d7546c9852fef0b Mon Sep 17 00:00:00 2001 From: Marco Suma Date: Wed, 24 Apr 2024 16:59:50 +0200 Subject: [PATCH 5/8] aggregates singular and plural data source. --- .../data_source_data_lake_pipeline_test.go | 94 ------------------- .../data_source_data_lake_pipelines_test.go | 22 +++-- 2 files changed, 13 insertions(+), 103 deletions(-) delete mode 100644 internal/service/datalakepipeline/data_source_data_lake_pipeline_test.go diff --git a/internal/service/datalakepipeline/data_source_data_lake_pipeline_test.go b/internal/service/datalakepipeline/data_source_data_lake_pipeline_test.go deleted file mode 100644 index c67a5d0cc0..0000000000 --- a/internal/service/datalakepipeline/data_source_data_lake_pipeline_test.go +++ /dev/null @@ -1,94 +0,0 @@ -package datalakepipeline_test - -import ( - "fmt" - "os" - "testing" - - "github.com/hashicorp/terraform-plugin-testing/helper/resource" - "github.com/mongodb/terraform-provider-mongodbatlas/internal/testutil/acc" -) - -func TestAccDataLakeDS_basic(t *testing.T) { - var ( - resourceName = "mongodbatlas_data_lake_pipeline.test" - dataSourceName = "data.mongodbatlas_data_lake_pipeline.testDataSource" - orgID = os.Getenv("MONGODB_ATLAS_ORG_ID") - projectName = acc.RandomProjectName() - clusterName = acc.RandomClusterName() - name = acc.RandomName() - ) - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { acc.PreCheckBasic(t) }, - ProtoV6ProviderFactories: acc.TestAccProviderV6Factories, - CheckDestroy: checkDestroy, - Steps: []resource.TestStep{ - { - Config: configDS(orgID, projectName, clusterName, name), - Check: resource.ComposeTestCheckFunc( - checkExists(resourceName), - resource.TestCheckResourceAttrSet(dataSourceName, "project_id"), - resource.TestCheckResourceAttr(dataSourceName, "name", name), - resource.TestCheckResourceAttr(dataSourceName, "state", "ACTIVE"), - ), - }, - }, - }) -} - -func configDS(orgID, projectName, clusterName, pipelineName string) string { - return fmt.Sprintf(` - resource "mongodbatlas_project" "project" { - org_id = %[1]q - name = %[2]q - } - - resource "mongodbatlas_advanced_cluster" "azure_conf" { - project_id = mongodbatlas_project.project.id - name = %[3]q - cluster_type = "REPLICASET" - - replication_specs { - region_configs { - electable_specs { - instance_size = "M10" - node_count = 3 - } - provider_name = "AZURE" - priority = 7 - region_name = "US_EAST_2" - } - } - backup_enabled = true - } - - resource "mongodbatlas_data_lake_pipeline" "test" { - project_id = mongodbatlas_project.project.id - name = %[4]q - sink { - type = "DLS" - partition_fields { - field_name = "access" - order = 0 - } - } - - source { - type = "ON_DEMAND_CPS" - cluster_name = mongodbatlas_advanced_cluster.azure_conf.name - database_name = "sample_airbnb" - collection_name = "listingsAndReviews" - } - - transformations { - field = "test" - type = "EXCLUDE" - } - } - - data "mongodbatlas_data_lake_pipeline" "testDataSource" { - project_id = mongodbatlas_data_lake_pipeline.test.project_id - name = mongodbatlas_data_lake_pipeline.test.name - } - `, orgID, projectName, clusterName, pipelineName) -} diff --git a/internal/service/datalakepipeline/data_source_data_lake_pipelines_test.go b/internal/service/datalakepipeline/data_source_data_lake_pipelines_test.go index e908dfb9f1..3cb8edee91 100644 --- a/internal/service/datalakepipeline/data_source_data_lake_pipelines_test.go +++ b/internal/service/datalakepipeline/data_source_data_lake_pipelines_test.go @@ -11,14 +11,15 @@ import ( func TestAccDataLakeDSPlural_basic(t *testing.T) { var ( - resourceName = "mongodbatlas_data_lake_pipeline.test" - dataSourceName = "data.mongodbatlas_data_lake_pipelines.testDataSource" - orgID = os.Getenv("MONGODB_ATLAS_ORG_ID") - firstClusterName = acc.RandomClusterName() - secondClusterName = acc.RandomClusterName() - firstPipelineName = acc.RandomName() - secondPipelineName = acc.RandomName() - projectName = acc.RandomProjectName() + resourceName = "mongodbatlas_data_lake_pipeline.test" + dataSourceName = "data.mongodbatlas_data_lake_pipeline.testDataSource" + pluralDataSourceName = "data.mongodbatlas_data_lake_pipelines.testDataSource" + orgID = os.Getenv("MONGODB_ATLAS_ORG_ID") + firstClusterName = acc.RandomClusterName() + secondClusterName = acc.RandomClusterName() + firstPipelineName = acc.RandomName() + secondPipelineName = acc.RandomName() + projectName = acc.RandomProjectName() ) resource.ParallelTest(t, resource.TestCase{ @@ -30,7 +31,10 @@ func TestAccDataLakeDSPlural_basic(t *testing.T) { Config: configDSPlural(orgID, projectName, firstClusterName, secondClusterName, firstPipelineName, secondPipelineName), Check: resource.ComposeTestCheckFunc( checkExists(resourceName), - resource.TestCheckResourceAttrSet(dataSourceName, "results.#"), + resource.TestCheckResourceAttrSet(dataSourceName, "project_id"), + resource.TestCheckResourceAttr(dataSourceName, "name", firstPipelineName), + resource.TestCheckResourceAttr(dataSourceName, "state", "ACTIVE"), + resource.TestCheckResourceAttrSet(pluralDataSourceName, "results.#"), ), }, }, From 3b82a6fc2abbe78569df70cba8a0f87c05cad136 Mon Sep 17 00:00:00 2001 From: Marco Suma Date: Wed, 24 Apr 2024 17:26:27 +0200 Subject: [PATCH 6/8] missing data source. --- .../datalakepipeline/data_source_data_lake_pipelines_test.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/internal/service/datalakepipeline/data_source_data_lake_pipelines_test.go b/internal/service/datalakepipeline/data_source_data_lake_pipelines_test.go index 3cb8edee91..1c8a52bc26 100644 --- a/internal/service/datalakepipeline/data_source_data_lake_pipelines_test.go +++ b/internal/service/datalakepipeline/data_source_data_lake_pipelines_test.go @@ -135,6 +135,10 @@ func configDSPlural(orgID, projectName, firstClusterName, secondClusterName, fir } } + data "mongodbatlas_data_lake_pipeline" "testDataSource" { + project_id = mongodbatlas_data_lake_pipeline.test.project_id + } + data "mongodbatlas_data_lake_pipelines" "testDataSource" { project_id = mongodbatlas_data_lake_pipeline.test.project_id } From 65fe91f8aba39f4d0e359409bc48e6ca950ef17f Mon Sep 17 00:00:00 2001 From: Marco Suma Date: Mon, 29 Apr 2024 18:48:14 +0200 Subject: [PATCH 7/8] fixes bug. --- .../datalakepipeline/data_source_data_lake_pipelines_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/internal/service/datalakepipeline/data_source_data_lake_pipelines_test.go b/internal/service/datalakepipeline/data_source_data_lake_pipelines_test.go index 1c8a52bc26..3757d25ca1 100644 --- a/internal/service/datalakepipeline/data_source_data_lake_pipelines_test.go +++ b/internal/service/datalakepipeline/data_source_data_lake_pipelines_test.go @@ -137,6 +137,7 @@ func configDSPlural(orgID, projectName, firstClusterName, secondClusterName, fir data "mongodbatlas_data_lake_pipeline" "testDataSource" { project_id = mongodbatlas_data_lake_pipeline.test.project_id + name = mongodbatlas_data_lake_pipeline.test.name } data "mongodbatlas_data_lake_pipelines" "testDataSource" { From 5699f4ff24079ab68c77426360e425b7ba5a262b Mon Sep 17 00:00:00 2001 From: Marco Suma Date: Tue, 30 Apr 2024 12:25:29 +0200 Subject: [PATCH 8/8] aggregates plura DS test with resource one. --- .../data_source_data_lake_pipelines_test.go | 147 ------------------ .../resource_data_lake_pipeline_test.go | 82 +++++++++- 2 files changed, 75 insertions(+), 154 deletions(-) delete mode 100644 internal/service/datalakepipeline/data_source_data_lake_pipelines_test.go diff --git a/internal/service/datalakepipeline/data_source_data_lake_pipelines_test.go b/internal/service/datalakepipeline/data_source_data_lake_pipelines_test.go deleted file mode 100644 index 3757d25ca1..0000000000 --- a/internal/service/datalakepipeline/data_source_data_lake_pipelines_test.go +++ /dev/null @@ -1,147 +0,0 @@ -package datalakepipeline_test - -import ( - "fmt" - "os" - "testing" - - "github.com/hashicorp/terraform-plugin-testing/helper/resource" - "github.com/mongodb/terraform-provider-mongodbatlas/internal/testutil/acc" -) - -func TestAccDataLakeDSPlural_basic(t *testing.T) { - var ( - resourceName = "mongodbatlas_data_lake_pipeline.test" - dataSourceName = "data.mongodbatlas_data_lake_pipeline.testDataSource" - pluralDataSourceName = "data.mongodbatlas_data_lake_pipelines.testDataSource" - orgID = os.Getenv("MONGODB_ATLAS_ORG_ID") - firstClusterName = acc.RandomClusterName() - secondClusterName = acc.RandomClusterName() - firstPipelineName = acc.RandomName() - secondPipelineName = acc.RandomName() - projectName = acc.RandomProjectName() - ) - - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { acc.PreCheckBasic(t) }, - ProtoV6ProviderFactories: acc.TestAccProviderV6Factories, - CheckDestroy: checkDestroy, - Steps: []resource.TestStep{ - { - Config: configDSPlural(orgID, projectName, firstClusterName, secondClusterName, firstPipelineName, secondPipelineName), - Check: resource.ComposeTestCheckFunc( - checkExists(resourceName), - resource.TestCheckResourceAttrSet(dataSourceName, "project_id"), - resource.TestCheckResourceAttr(dataSourceName, "name", firstPipelineName), - resource.TestCheckResourceAttr(dataSourceName, "state", "ACTIVE"), - resource.TestCheckResourceAttrSet(pluralDataSourceName, "results.#"), - ), - }, - }, - }) -} - -func configDSPlural(orgID, projectName, firstClusterName, secondClusterName, firstPipelineName, secondPipelineName string) string { - return fmt.Sprintf(` - - resource "mongodbatlas_project" "project" { - org_id = %[1]q - name = %[2]q - } - - resource "mongodbatlas_advanced_cluster" "azure_conf" { - project_id = mongodbatlas_project.project.id - name = %[3]q - cluster_type = "REPLICASET" - - replication_specs { - region_configs { - electable_specs { - instance_size = "M10" - node_count = 3 - } - provider_name = "AZURE" - priority = 7 - region_name = "US_EAST_2" - } - } - backup_enabled = true - } - - resource "mongodbatlas_advanced_cluster" "azure_conf2" { - project_id = mongodbatlas_project.project.id - name = %[4]q - cluster_type = "REPLICASET" - - replication_specs { - region_configs { - electable_specs { - instance_size = "M10" - node_count = 3 - } - provider_name = "AZURE" - priority = 7 - region_name = "US_EAST_2" - } - } - backup_enabled = true - } - - resource "mongodbatlas_data_lake_pipeline" "test" { - project_id = mongodbatlas_project.project.id - name = %[5]q - sink { - type = "DLS" - partition_fields { - field_name = "access" - order = 0 - } - } - - source { - type = "ON_DEMAND_CPS" - cluster_name = mongodbatlas_advanced_cluster.azure_conf.name - database_name = "sample_airbnb" - collection_name = "listingsAndReviews" - } - - transformations { - field = "test" - type = "EXCLUDE" - } - } - - resource "mongodbatlas_data_lake_pipeline" "test2" { - project_id = mongodbatlas_project.project.id - name = %[6]q - sink { - type = "DLS" - partition_fields { - field_name = "access" - order = 0 - } - } - - source { - type = "ON_DEMAND_CPS" - cluster_name = mongodbatlas_advanced_cluster.azure_conf2.name - database_name = "sample_airbnb" - collection_name = "listingsAndReviews" - } - - transformations { - field = "test" - type = "EXCLUDE" - } - } - - data "mongodbatlas_data_lake_pipeline" "testDataSource" { - project_id = mongodbatlas_data_lake_pipeline.test.project_id - name = mongodbatlas_data_lake_pipeline.test.name - } - - data "mongodbatlas_data_lake_pipelines" "testDataSource" { - project_id = mongodbatlas_data_lake_pipeline.test.project_id - } - `, orgID, projectName, firstClusterName, secondClusterName, firstPipelineName, secondPipelineName) -} diff --git a/internal/service/datalakepipeline/resource_data_lake_pipeline_test.go b/internal/service/datalakepipeline/resource_data_lake_pipeline_test.go index 72ea2a1ea6..b83a96f5f2 100644 --- a/internal/service/datalakepipeline/resource_data_lake_pipeline_test.go +++ b/internal/service/datalakepipeline/resource_data_lake_pipeline_test.go @@ -14,11 +14,15 @@ import ( func TestAccDataLakePipeline_basic(t *testing.T) { var ( - resourceName = "mongodbatlas_data_lake_pipeline.test" - orgID = os.Getenv("MONGODB_ATLAS_ORG_ID") - projectName = acc.RandomProjectName() - clusterName = acc.RandomClusterName() - name = acc.RandomName() + resourceName = "mongodbatlas_data_lake_pipeline.test" + dataSourceName = "data.mongodbatlas_data_lake_pipeline.testDataSource" + pluralDataSourceName = "data.mongodbatlas_data_lake_pipelines.testDataSource" + orgID = os.Getenv("MONGODB_ATLAS_ORG_ID") + firstClusterName = acc.RandomClusterName() + secondClusterName = acc.RandomClusterName() + firstPipelineName = acc.RandomName() + secondPipelineName = acc.RandomName() + projectName = acc.RandomProjectName() ) resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { acc.PreCheckBasic(t) }, @@ -26,12 +30,17 @@ func TestAccDataLakePipeline_basic(t *testing.T) { CheckDestroy: checkDestroy, Steps: []resource.TestStep{ { - Config: configBasic(orgID, projectName, clusterName, name), + Config: configBasicWithPluralDS(orgID, projectName, firstClusterName, secondClusterName, firstPipelineName, secondPipelineName), Check: resource.ComposeTestCheckFunc( checkExists(resourceName), resource.TestCheckResourceAttrSet(resourceName, "project_id"), - resource.TestCheckResourceAttr(resourceName, "name", name), + resource.TestCheckResourceAttr(resourceName, "name", firstPipelineName), resource.TestCheckResourceAttr(resourceName, "state", "ACTIVE"), + + resource.TestCheckResourceAttrSet(dataSourceName, "project_id"), + resource.TestCheckResourceAttr(dataSourceName, "name", firstPipelineName), + resource.TestCheckResourceAttr(dataSourceName, "state", "ACTIVE"), + resource.TestCheckResourceAttrSet(pluralDataSourceName, "results.#"), ), }, { @@ -142,3 +151,62 @@ func configBasic(orgID, projectName, clusterName, pipelineName string) string { } `, orgID, projectName, clusterName, pipelineName) } + +func configBasicWithPluralDS(orgID, projectName, firstClusterName, secondClusterName, firstPipelineName, secondPipelineName string) string { + config := configBasic(orgID, projectName, firstClusterName, firstPipelineName) + return fmt.Sprintf(` + %[1]s + + resource "mongodbatlas_advanced_cluster" "azure_conf2" { + project_id = mongodbatlas_project.project.id + name = %[2]q + cluster_type = "REPLICASET" + + replication_specs { + region_configs { + electable_specs { + instance_size = "M10" + node_count = 3 + } + provider_name = "AZURE" + priority = 7 + region_name = "US_EAST_2" + } + } + backup_enabled = true + } + + resource "mongodbatlas_data_lake_pipeline" "test2" { + project_id = mongodbatlas_project.project.id + name = %[3]q + sink { + type = "DLS" + partition_fields { + field_name = "access" + order = 0 + } + } + + source { + type = "ON_DEMAND_CPS" + cluster_name = mongodbatlas_advanced_cluster.azure_conf2.name + database_name = "sample_airbnb" + collection_name = "listingsAndReviews" + } + + transformations { + field = "test" + type = "EXCLUDE" + } + } + + data "mongodbatlas_data_lake_pipeline" "testDataSource" { + project_id = mongodbatlas_data_lake_pipeline.test.project_id + name = mongodbatlas_data_lake_pipeline.test.name + } + + data "mongodbatlas_data_lake_pipelines" "testDataSource" { + project_id = mongodbatlas_data_lake_pipeline.test.project_id + } + `, config, secondClusterName, secondPipelineName) +}