-
Notifications
You must be signed in to change notification settings - Fork 167
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
INTMDB-921: [Terraform] Migrate to terraform-plugin-testing #1301
Conversation
mongodbatlas/resource_mongodbatlas_advanced_cluster_migration_test.go
Outdated
Show resolved
Hide resolved
@maastha this PR is ready for review |
@andreaangiolillo PR LGTM, just one question, did we try testing any resources with this change with an existing/old version TF config just to be sure nothing breaks for users? As per HashiCorp we shouldn't expect any impact on customers but would still be good to know. |
I haven't updated any TF configuration of our Acceptance Tests so we are confident enough that this is not a breaking changes. In addition, we were already using |
Right, but the idea of manually testing with existing configs is so that with user's existing state files, no changes are detected when they re-run their configurations. Acceptance tests create new resources and then read new state files which are created with the updated code. |
I will add an update once I tested the changes with a resource where I introduced |
This is the configuration file that I used for the local tests: It creates 1 project (testing resource "mongodbatlas_project" "atlas-project" {
name = "Andrea-Test-2"
org_id = var.atlas_org_id
}
# Create an Atlas Advanced Cluster
resource "mongodbatlas_advanced_cluster" "atlas-cluster" {
project_id = mongodbatlas_project.atlas-project.id
name = "Andrea-Test-2"
cluster_type = "REPLICASET"
backup_enabled = true
pit_enabled = true
mongo_db_major_version = "6.0"
replication_specs {
region_configs {
electable_specs {
instance_size = "M30"
node_count = 3
}
auto_scaling {
compute_enabled = true
compute_max_instance_size = "M30"
compute_min_instance_size = "M10"
compute_scale_down_enabled = true
disk_gb_enabled = true
}
analytics_specs {
instance_size = "M30"
node_count = 1
}
analytics_auto_scaling {
compute_enabled = true
compute_max_instance_size = "M30"
compute_min_instance_size = "M10"
compute_scale_down_enabled = true
disk_gb_enabled = true
}
priority = 7
provider_name = "AWS"
region_name = "US_EAST_1"
}
}
}
data "mongodbatlas_advanced_cluster" "cluster" {
project_id = mongodbatlas_project.atlas-project.id
name = "INTMDB-920-Andrea"
}
data "mongodbatlas_advanced_clusters" "clusters" {
project_id = mongodbatlas_project.atlas-project.id
} Local test steps:
terraform state list
data.mongodbatlas_advanced_cluster.cluster
data.mongodbatlas_advanced_clusters.clusters
mongodbatlas_advanced_cluster.atlas-cluster
mongodbatlas_project.atlas-project terraform state show data.mongodbatlas_advanced_cluster.cluster
# data.mongodbatlas_advanced_cluster.cluster:
data "mongodbatlas_advanced_cluster" "cluster" {
advanced_configuration = [
{
default_read_concern = ""
default_write_concern = ""
fail_index_key_too_long = false
javascript_enabled = true
minimum_enabled_tls_protocol = "TLS1_2"
no_table_scan = false
oplog_min_retention_hours = 0
oplog_size_mb = 0
sample_refresh_interval_bi_connector = 0
sample_size_bi_connector = 0
transaction_lifetime_limit_seconds = 0
},
]
backup_enabled = true
bi_connector_config = [
{
enabled = false
read_preference = "secondary"
},
]
cluster_type = "REPLICASET"
connection_strings = [
{
aws_private_link = {}
aws_private_link_srv = {}
private = ""
private_endpoint = []
private_srv = ""
standard = "mongodb://andrea-test-22-shard-00-00.tfu4f.mongodb-dev.net:27017,andrea-test-22-shard-00-01.tfu4f.mongodb-dev.net:27017,andrea-test-22-shard-00-02.tfu4f.mongodb-dev.net:27017,andrea-test-22-shard-00-03.tfu4f.mongodb-dev.net:27017/?ssl=true&authSource=admin&replicaSet=atlas-xq9g9c-shard-0"
standard_srv = "mongodb+srv://andrea-test-22.tfu4f.mongodb-dev.net"
},
]
create_date = "2023-07-20T06:58:06Z"
disk_size_gb = 40
encryption_at_rest_provider = "NONE"
id = "64b8dafef5f3b93b108bff53"
labels = []
mongo_db_major_version = "6.0"
mongo_db_version = "6.0.8"
name = "Andrea-Test-22"
paused = false
pit_enabled = true
project_id = "64b8d3219c4cdc3f9108e318"
replication_specs = [
{
container_id = {
"AWS:US_EAST_1" = "64b8d3243935461255ecb3c4"
}
id = "64b8dafdf5f3b93b108bff4c"
num_shards = 1
region_configs = [
{
analytics_auto_scaling = [
{
compute_enabled = true
compute_max_instance_size = "M30"
compute_min_instance_size = "M10"
compute_scale_down_enabled = true
disk_gb_enabled = true
},
]
analytics_specs = [
{
disk_iops = 3000
ebs_volume_type = "STANDARD"
instance_size = "M30"
node_count = 1
},
]
auto_scaling = [
{
compute_enabled = true
compute_max_instance_size = "M30"
compute_min_instance_size = "M10"
compute_scale_down_enabled = true
disk_gb_enabled = true
},
]
backing_provider_name = ""
electable_specs = [
{
disk_iops = 3000
ebs_volume_type = "STANDARD"
instance_size = "M30"
node_count = 3
},
]
priority = 7
provider_name = "AWS"
read_only_specs = [
{
disk_iops = 3000
ebs_volume_type = "STANDARD"
instance_size = "M30"
node_count = 0
},
]
region_name = "US_EAST_1"
},
]
zone_name = "ZoneName managed by Terraform"
},
]
root_cert_type = "ISRGROOTX1"
state_name = "IDLE"
termination_protection_enabled = false
version_release_system = "LTS"
} terraform state show data.mongodbatlas_advanced_clusters.clusters
# data.mongodbatlas_advanced_clusters.clusters:
data "mongodbatlas_advanced_clusters" "clusters" {
id = "terraform-20230720071238396200000001"
project_id = "64b8d3219c4cdc3f9108e318"
results = [
{
advanced_configuration = [
{
default_read_concern = ""
default_write_concern = ""
fail_index_key_too_long = false
javascript_enabled = true
minimum_enabled_tls_protocol = "TLS1_2"
no_table_scan = false
oplog_min_retention_hours = 0
oplog_size_mb = 0
sample_refresh_interval_bi_connector = 0
sample_size_bi_connector = 0
transaction_lifetime_limit_seconds = 0
},
]
backup_enabled = true
bi_connector_config = [
{
enabled = false
read_preference = "secondary"
},
]
cluster_type = "REPLICASET"
connection_strings = [
{
aws_private_link = {}
aws_private_link_srv = {}
private = ""
private_endpoint = []
private_srv = ""
standard = "mongodb://andrea-test-22-shard-00-00.tfu4f.mongodb-dev.net:27017,andrea-test-22-shard-00-01.tfu4f.mongodb-dev.net:27017,andrea-test-22-shard-00-02.tfu4f.mongodb-dev.net:27017,andrea-test-22-shard-00-03.tfu4f.mongodb-dev.net:27017/?ssl=true&authSource=admin&replicaSet=atlas-xq9g9c-shard-0"
standard_srv = "mongodb+srv://andrea-test-22.tfu4f.mongodb-dev.net"
},
]
create_date = "2023-07-20T06:58:06Z"
disk_size_gb = 40
encryption_at_rest_provider = "NONE"
labels = [
{
key = "Infrastructure Tool"
value = "MongoDB Atlas Terraform Provider"
},
]
mongo_db_major_version = "6.0"
mongo_db_version = "6.0.8"
name = "Andrea-Test-22"
paused = false
pit_enabled = true
replication_specs = [
{
container_id = {
"AWS:US_EAST_1" = "64b8d3243935461255ecb3c4"
}
id = "64b8dafdf5f3b93b108bff4c"
num_shards = 1
region_configs = [
{
analytics_auto_scaling = [
{
compute_enabled = true
compute_max_instance_size = "M30"
compute_min_instance_size = "M10"
compute_scale_down_enabled = true
disk_gb_enabled = true
},
]
analytics_specs = [
{
disk_iops = 3000
ebs_volume_type = "STANDARD"
instance_size = "M30"
node_count = 1
},
]
auto_scaling = [
{
compute_enabled = true
compute_max_instance_size = "M30"
compute_min_instance_size = "M10"
compute_scale_down_enabled = true
disk_gb_enabled = true
},
]
backing_provider_name = ""
electable_specs = [
{
disk_iops = 3000
ebs_volume_type = "STANDARD"
instance_size = "M30"
node_count = 3
},
]
priority = 7
provider_name = "AWS"
read_only_specs = [
{
disk_iops = 3000
ebs_volume_type = "STANDARD"
instance_size = "M30"
node_count = 0
},
]
region_name = "US_EAST_1"
},
]
zone_name = "ZoneName managed by Terraform"
},
]
root_cert_type = "ISRGROOTX1"
state_name = "IDLE"
termination_protection_enabled = false
version_release_system = "LTS"
},
]
} terraform state show mongodbatlas_advanced_cluster.atlas-cluster
# mongodbatlas_advanced_cluster.atlas-cluster:
resource "mongodbatlas_advanced_cluster" "atlas-cluster" {
backup_enabled = true
cluster_id = "64b8dafef5f3b93b108bff53"
cluster_type = "REPLICASET"
connection_strings = [
{
aws_private_link = {}
aws_private_link_srv = {}
private = ""
private_endpoint = []
private_srv = ""
standard = "mongodb://andrea-test-22-shard-00-00.tfu4f.mongodb-dev.net:27017,andrea-test-22-shard-00-01.tfu4f.mongodb-dev.net:27017,andrea-test-22-shard-00-02.tfu4f.mongodb-dev.net:27017,andrea-test-22-shard-00-03.tfu4f.mongodb-dev.net:27017/?ssl=true&authSource=admin&replicaSet=atlas-xq9g9c-shard-0"
standard_srv = "mongodb+srv://andrea-test-22.tfu4f.mongodb-dev.net"
},
]
create_date = "2023-07-20T06:58:06Z"
disk_size_gb = 40
encryption_at_rest_provider = "NONE"
id = "Y2x1c3Rlcl9pZA==:NjRiOGRhZmVmNWYzYjkzYjEwOGJmZjUz-Y2x1c3Rlcl9uYW1l:QW5kcmVhLVRlc3QtMjI=-cHJvamVjdF9pZA==:NjRiOGQzMjE5YzRjZGMzZjkxMDhlMzE4"
mongo_db_major_version = "6.0"
mongo_db_version = "6.0.8"
name = "Andrea-Test-22"
paused = false
pit_enabled = true
project_id = "64b8d3219c4cdc3f9108e318"
root_cert_type = "ISRGROOTX1"
state_name = "IDLE"
termination_protection_enabled = false
version_release_system = "LTS"
advanced_configuration {
fail_index_key_too_long = false
javascript_enabled = true
minimum_enabled_tls_protocol = "TLS1_2"
no_table_scan = false
oplog_min_retention_hours = 0
oplog_size_mb = 0
sample_refresh_interval_bi_connector = 0
sample_size_bi_connector = 0
transaction_lifetime_limit_seconds = 0
}
bi_connector {
enabled = false
read_preference = "secondary"
}
bi_connector_config {
enabled = false
read_preference = "secondary"
}
replication_specs {
container_id = {
"AWS:US_EAST_1" = "64b8d3243935461255ecb3c4"
}
id = "64b8dafdf5f3b93b108bff4c"
num_shards = 1
zone_name = "ZoneName managed by Terraform"
region_configs {
priority = 7
provider_name = "AWS"
region_name = "US_EAST_1"
analytics_auto_scaling {
compute_enabled = true
compute_max_instance_size = "M30"
compute_min_instance_size = "M10"
compute_scale_down_enabled = true
disk_gb_enabled = true
}
analytics_specs {
disk_iops = 0
instance_size = "M30"
node_count = 1
}
auto_scaling {
compute_enabled = true
compute_max_instance_size = "M30"
compute_min_instance_size = "M10"
compute_scale_down_enabled = true
disk_gb_enabled = true
}
electable_specs {
disk_iops = 0
instance_size = "M30"
node_count = 3
}
}
}
} terraform state show mongodbatlas_project.atlas-project
# mongodbatlas_project.atlas-project:
resource "mongodbatlas_project" "atlas-project" {
cluster_count = 1
created = "2023-07-20T06:24:34Z"
id = "64b8d3219c4cdc3f9108e318"
is_collect_database_specifics_statistics_enabled = true
is_data_explorer_enabled = true
is_extended_storage_sizes_enabled = false
is_performance_advisor_enabled = true
is_realtime_performance_panel_enabled = true
is_schema_advisor_enabled = true
name = "Andrea-Test-2"
org_id = "60ddf55c27a5a20955a707d7"
with_default_alerts_settings = true
api_keys {
api_key_id = "23412312321312312"
role_names = [
"GROUP_OWNER",
]
}
} |
@maastha ready for review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot @andreaangiolillo for this one! LGTM!
Description
Ticket: INTMDB-921
As a pre-requisite to migration to Terraform Plugin Framework, we need to migrate our provider's acceptance testing dependencies from SDKv2 to the plugin testing module. This link gives more information about the migration steps: https://developer.hashicorp.com/terraform/plugin/testing/migrating
Type of change:
Required Checklist:
Further comments