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

chore: Tries to reduce OUT_OF_CAPACITY during tests by moving cluster creation to other cloud providers #2206

Merged
merged 8 commits into from
May 2, 2024
Merged
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

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,33 @@ 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) },
ProtoV6ProviderFactories: acc.TestAccProviderV6Factories,
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.#"),
),
},
{
Expand Down Expand Up @@ -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 {
Copy link
Member

@lantoli lantoli Apr 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

function name is misleading as it adds not only plural ds but a cluster resource and a singular ds.

can't it be the same configBasic function creating all resources needed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd avoid that because configBasic is also called for the migration test, and it wouldn't be basic anymore because it actually creates two clusters and two data lakes in order to test the plural part of it.

Would you suggest a different name perhaps?

Copy link
Collaborator Author

@marcosuma marcosuma May 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lantoli I am going to go ahead with this so I can get unblocked (since it's public holiday for you). Sorry about that, we can always change it in a follow-up PR.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, that's fine

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)
}