Skip to content

Commit

Permalink
fix: Supports using decimal in cluster+adv_cluster advanced_configura…
Browse files Browse the repository at this point in the history
…tion `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
  • Loading branch information
EspenAlbert authored Sep 18, 2024
1 parent 9562d48 commit 02fca0d
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 7 deletions.
7 changes: 7 additions & 0 deletions .changelog/2604.txt
Original file line number Diff line number Diff line change
@@ -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`
```
4 changes: 2 additions & 2 deletions internal/service/advancedcluster/model_advanced_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down Expand Up @@ -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": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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{
Expand All @@ -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"),
),
},
Expand All @@ -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
Expand All @@ -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)
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
),
},
{
Expand Down Expand Up @@ -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())
}
Expand Down

0 comments on commit 02fca0d

Please sign in to comment.