From 02fca0db6a606174917e74df2a0debab45225290 Mon Sep 17 00:00:00 2001 From: Espen Albert Date: Wed, 18 Sep 2024 11:54:38 +0100 Subject: [PATCH] fix: Supports using decimal in cluster+adv_cluster advanced_configuration `oplog_min_retention_hours` (#2604) * feat: supports using decimal in cluster+adv_cluster advanced_configuration `oplog_min_retention_hours` * doc: add changelog entry * chore: fix changelog file --- .changelog/2604.txt | 7 +++++++ .../advancedcluster/model_advanced_cluster.go | 4 ++-- ...esource_advanced_cluster_migration_test.go | 19 ++++++++++++++----- .../resource_advanced_cluster_test.go | 4 ++++ 4 files changed, 27 insertions(+), 7 deletions(-) create mode 100644 .changelog/2604.txt diff --git a/.changelog/2604.txt b/.changelog/2604.txt new file mode 100644 index 0000000000..9b5e165bf3 --- /dev/null +++ b/.changelog/2604.txt @@ -0,0 +1,7 @@ +```release-note:bug +resource/mongodbatlas_advanced_cluster: Supports using decimal in advanced_configuration `oplog_min_retention_hours` +``` + +```release-note:bug +resource/mongodbatlas_cluster: Supports using decimal in advanced_configuration `oplog_min_retention_hours` +``` diff --git a/internal/service/advancedcluster/model_advanced_cluster.go b/internal/service/advancedcluster/model_advanced_cluster.go index 5433768200..5523c35b89 100644 --- a/internal/service/advancedcluster/model_advanced_cluster.go +++ b/internal/service/advancedcluster/model_advanced_cluster.go @@ -104,7 +104,7 @@ func SchemaAdvancedConfigDS() *schema.Schema { Computed: true, }, "oplog_min_retention_hours": { - Type: schema.TypeInt, + Type: schema.TypeFloat, Computed: true, }, "transaction_lifetime_limit_seconds": { @@ -237,7 +237,7 @@ func SchemaAdvancedConfig() *schema.Schema { Computed: true, }, "oplog_min_retention_hours": { - Type: schema.TypeInt, + Type: schema.TypeFloat, Optional: true, }, "sample_size_bi_connector": { diff --git a/internal/service/advancedcluster/resource_advanced_cluster_migration_test.go b/internal/service/advancedcluster/resource_advanced_cluster_migration_test.go index 980d385c66..77e15b3c4c 100644 --- a/internal/service/advancedcluster/resource_advanced_cluster_migration_test.go +++ b/internal/service/advancedcluster/resource_advanced_cluster_migration_test.go @@ -154,12 +154,18 @@ func TestMigAdvancedCluster_partialAdvancedConf(t *testing.T) { var ( projectID = acc.ProjectIDExecution(t) clusterName = acc.RandomClusterName() - extraArgs = ` + // necessary to test oplog_min_retention_hours + autoScalingConfigured = ` + auto_scaling { + disk_gb_enabled = true + }` + extraArgs = ` advanced_configuration { fail_index_key_too_long = false javascript_enabled = true minimum_enabled_tls_protocol = "TLS1_1" no_table_scan = false + oplog_min_retention_hours = 4 } bi_connector_config { @@ -181,8 +187,8 @@ func TestMigAdvancedCluster_partialAdvancedConf(t *testing.T) { enabled = false read_preference = "secondary" }` - config = configPartialAdvancedConfig(projectID, clusterName, extraArgs) - configUpdated = configPartialAdvancedConfig(projectID, clusterName, extraArgsUpdated) + config = configPartialAdvancedConfig(projectID, clusterName, extraArgs, autoScalingConfigured) + configUpdated = configPartialAdvancedConfig(projectID, clusterName, extraArgsUpdated, "") ) resource.ParallelTest(t, resource.TestCase{ @@ -198,6 +204,7 @@ func TestMigAdvancedCluster_partialAdvancedConf(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "advanced_configuration.0.javascript_enabled", "true"), resource.TestCheckResourceAttr(resourceName, "advanced_configuration.0.minimum_enabled_tls_protocol", "TLS1_1"), resource.TestCheckResourceAttr(resourceName, "advanced_configuration.0.no_table_scan", "false"), + resource.TestCheckResourceAttr(resourceName, "advanced_configuration.0.oplog_min_retention_hours", "4"), resource.TestCheckResourceAttr(resourceName, "bi_connector_config.0.enabled", "true"), ), }, @@ -217,11 +224,12 @@ func TestMigAdvancedCluster_partialAdvancedConf(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "bi_connector_config.0.read_preference", "secondary"), ), }, + mig.TestStepCheckEmptyPlan(configUpdated), }, }) } -func configPartialAdvancedConfig(projectID, clusterName, extraArgs string) string { +func configPartialAdvancedConfig(projectID, clusterName, extraArgs, autoScaling string) string { return fmt.Sprintf(` resource "mongodbatlas_advanced_cluster" "test" { project_id = %[1]q @@ -241,9 +249,10 @@ func configPartialAdvancedConfig(projectID, clusterName, extraArgs string) strin provider_name = "AWS" priority = 7 region_name = "US_WEST_2" + %[4]s } } %[3]s } - `, projectID, clusterName, extraArgs) + `, projectID, clusterName, extraArgs, autoScaling) } diff --git a/internal/service/advancedcluster/resource_advanced_cluster_test.go b/internal/service/advancedcluster/resource_advanced_cluster_test.go index a9d0655493..935a34e5d2 100644 --- a/internal/service/advancedcluster/resource_advanced_cluster_test.go +++ b/internal/service/advancedcluster/resource_advanced_cluster_test.go @@ -385,6 +385,7 @@ func TestAccClusterAdvancedClusterConfig_replicationSpecsAutoScaling(t *testing. resource.TestCheckResourceAttr(resourceName, "name", clusterName), resource.TestCheckResourceAttrSet(resourceName, "replication_specs.0.region_configs.#"), resource.TestCheckResourceAttr(resourceName, "replication_specs.0.region_configs.0.auto_scaling.0.compute_enabled", "false"), + resource.TestCheckResourceAttr(resourceName, "advanced_configuration.0.oplog_min_retention_hours", "5.5"), ), }, { @@ -1400,6 +1401,9 @@ func configReplicationSpecsAutoScaling(projectID, clusterName string, p *admin.A region_name = "US_WEST_2" } } + advanced_configuration { + oplog_min_retention_hours = 5.5 + } } `, projectID, clusterName, p.Compute.GetEnabled(), p.DiskGB.GetEnabled(), p.Compute.GetMaxInstanceSize()) }