-
Notifications
You must be signed in to change notification settings - Fork 178
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
feat: Adds new advanced_configuration.0.default_max_time_ms
attribute to mongodbatlas_advanced_cluster
resource and data sources
#2825
Changes from 7 commits
ead56a2
224e10a
78e7a5f
646dd78
f7d3100
667b347
b4b44d7
6ff282f
1be1aba
87ec371
21d9cf0
78c5b23
a3d6327
51b9938
2586a98
a087f24
638c4bf
eb961e5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
```release-note:note | ||
resource/mongodbatlas_advanced_cluster: Adds new `advanced_configuration.0.default_max_time_ms` attribute | ||
``` | ||
|
||
```release-note:note | ||
data-source/mongodbatlas_advanced_cluster: Adds new `advanced_configuration.0.default_max_time_ms` attribute | ||
``` | ||
|
||
```release-note:note | ||
data-source/mongodbatlas_advanced_clusters: Adds new `advanced_configuration.0.default_max_time_ms` attribute | ||
``` | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -117,6 +117,10 @@ func SchemaAdvancedConfigDS() *schema.Schema { | |
Type: schema.TypeInt, | ||
Computed: true, | ||
}, | ||
"default_max_time_ms": { | ||
Type: schema.TypeInt, | ||
Computed: true, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
@@ -262,6 +266,10 @@ func SchemaAdvancedConfig() *schema.Schema { | |
Optional: true, | ||
Default: -1, | ||
}, | ||
"default_max_time_ms": { | ||
Type: schema.TypeInt, | ||
Optional: true, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Confirmed with upstream this is expected to be user-managed, hence keeping optional |
||
}, | ||
}, | ||
}, | ||
} | ||
|
@@ -511,7 +519,12 @@ func flattenProcessArgs(p20240530 *admin20240530.ClusterDescriptionProcessArgs, | |
} else { | ||
flattenedProcessArgs[0]["change_stream_options_pre_and_post_images_expire_after_seconds"] = p.GetChangeStreamOptionsPreAndPostImagesExpireAfterSeconds() | ||
} | ||
|
||
if v := p.DefaultMaxTimeMS; v != nil { | ||
flattenedProcessArgs[0]["default_max_time_ms"] = p.GetDefaultMaxTimeMS() | ||
} | ||
} | ||
|
||
return flattenedProcessArgs | ||
} | ||
|
||
|
@@ -852,6 +865,11 @@ func expandProcessArgs(d *schema.ResourceData, p map[string]any, mongodbMajorVer | |
|
||
res.ChangeStreamOptionsPreAndPostImagesExpireAfterSeconds = conversion.IntPtr(tmpInt) | ||
} | ||
|
||
if _, ok := d.GetOkExists("advanced_configuration.0.default_max_time_ms"); ok { | ||
res.DefaultMaxTimeMS = conversion.Pointer(cast.ToInt(p["default_max_time_ms"])) | ||
} | ||
|
||
return res20240530, res | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -248,10 +248,10 @@ func TestAccClusterAdvancedCluster_pausedToUnpaused(t *testing.T) { | |
func TestAccClusterAdvancedCluster_advancedConfig(t *testing.T) { | ||
acc.SkipIfTPFAdvancedCluster(t) | ||
var ( | ||
projectID = acc.ProjectIDExecution(t) | ||
clusterName = acc.RandomClusterName() | ||
clusterNameUpdated = acc.RandomClusterName() | ||
processArgs = &admin20240530.ClusterDescriptionProcessArgs{ | ||
projectID = acc.ProjectIDExecution(t) | ||
clusterName = acc.RandomClusterName() | ||
clusterNameUpdated = acc.RandomClusterName() | ||
processArgs20240530 = &admin20240530.ClusterDescriptionProcessArgs{ | ||
DefaultReadConcern: conversion.StringPtr("available"), | ||
DefaultWriteConcern: conversion.StringPtr("1"), | ||
FailIndexKeyTooLong: conversion.Pointer(false), | ||
|
@@ -263,7 +263,11 @@ func TestAccClusterAdvancedCluster_advancedConfig(t *testing.T) { | |
SampleSizeBIConnector: conversion.Pointer(110), | ||
TransactionLifetimeLimitSeconds: conversion.Pointer[int64](300), | ||
} | ||
processArgsUpdated = &admin20240530.ClusterDescriptionProcessArgs{ | ||
processArgs = &admin.ClusterDescriptionProcessArgs20240805{ | ||
ChangeStreamOptionsPreAndPostImagesExpireAfterSeconds: conversion.IntPtr(-1), // this will not be set in the TF configuration | ||
} | ||
|
||
processArgs20240530Updated = &admin20240530.ClusterDescriptionProcessArgs{ | ||
DefaultReadConcern: conversion.StringPtr("available"), | ||
DefaultWriteConcern: conversion.StringPtr("0"), | ||
FailIndexKeyTooLong: conversion.Pointer(false), | ||
|
@@ -275,6 +279,10 @@ func TestAccClusterAdvancedCluster_advancedConfig(t *testing.T) { | |
SampleSizeBIConnector: conversion.Pointer(110), | ||
TransactionLifetimeLimitSeconds: conversion.Pointer[int64](300), | ||
} | ||
processArgsUpdated = &admin.ClusterDescriptionProcessArgs20240805{ | ||
DefaultMaxTimeMS: conversion.IntPtr(65), | ||
ChangeStreamOptionsPreAndPostImagesExpireAfterSeconds: conversion.IntPtr(100), | ||
} | ||
) | ||
|
||
resource.ParallelTest(t, resource.TestCase{ | ||
|
@@ -283,12 +291,12 @@ func TestAccClusterAdvancedCluster_advancedConfig(t *testing.T) { | |
CheckDestroy: acc.CheckDestroyCluster, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: configAdvanced(projectID, clusterName, processArgs, nil), | ||
Check: checkAdvanced(clusterName, "TLS1_1", "-1"), | ||
Config: configAdvanced(projectID, clusterName, processArgs20240530, processArgs), | ||
Check: checkAdvanced(clusterName, "TLS1_1", processArgs), | ||
}, | ||
{ | ||
Config: configAdvanced(projectID, clusterNameUpdated, processArgsUpdated, conversion.IntPtr(100)), | ||
Check: checkAdvanced(clusterNameUpdated, "TLS1_2", "100"), | ||
Config: configAdvanced(projectID, clusterNameUpdated, processArgs20240530Updated, processArgsUpdated), | ||
Check: checkAdvanced(clusterNameUpdated, "TLS1_2", processArgsUpdated), | ||
}, | ||
}, | ||
}) | ||
|
@@ -1320,10 +1328,16 @@ func checkSingleProviderPaused(name string, paused bool) resource.TestCheckFunc | |
"paused": strconv.FormatBool(paused)}) | ||
} | ||
|
||
func configAdvanced(projectID, clusterName string, p *admin20240530.ClusterDescriptionProcessArgs, changeStreamOptions *int) string { | ||
func configAdvanced(projectID, clusterName string, p20240530 *admin20240530.ClusterDescriptionProcessArgs, p *admin.ClusterDescriptionProcessArgs20240805) string { | ||
changeStreamOptionsString := "" | ||
if changeStreamOptions != nil { | ||
changeStreamOptionsString = fmt.Sprintf(`change_stream_options_pre_and_post_images_expire_after_seconds = %[1]d`, *changeStreamOptions) | ||
defaultMaxTimeString := "" | ||
if p != nil { | ||
if p.ChangeStreamOptionsPreAndPostImagesExpireAfterSeconds != conversion.IntPtr(-1) { | ||
changeStreamOptionsString = fmt.Sprintf(`change_stream_options_pre_and_post_images_expire_after_seconds = %[1]d`, *p.ChangeStreamOptionsPreAndPostImagesExpireAfterSeconds) | ||
} | ||
if p.DefaultMaxTimeMS != nil { | ||
defaultMaxTimeString = fmt.Sprintf(`default_max_time_ms = %[1]d`, *p.DefaultMaxTimeMS) | ||
} | ||
} | ||
return fmt.Sprintf(` | ||
resource "mongodbatlas_advanced_cluster" "test" { | ||
|
@@ -1357,6 +1371,7 @@ func configAdvanced(projectID, clusterName string, p *admin20240530.ClusterDescr | |
sample_refresh_interval_bi_connector = %[9]d | ||
transaction_lifetime_limit_seconds = %[10]d | ||
%[11]s | ||
%[12]s | ||
} | ||
} | ||
|
||
|
@@ -1369,27 +1384,36 @@ func configAdvanced(projectID, clusterName string, p *admin20240530.ClusterDescr | |
project_id = mongodbatlas_advanced_cluster.test.project_id | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just to a double check from our draft checklist, is the attribute supported in older MongoDB versions? Could be good to try an older MongoDB version and attribute is not defined. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. added validation and acceptance test for this scenario |
||
} | ||
`, projectID, clusterName, | ||
p.GetFailIndexKeyTooLong(), p.GetJavascriptEnabled(), p.GetMinimumEnabledTlsProtocol(), p.GetNoTableScan(), | ||
p.GetOplogSizeMB(), p.GetSampleSizeBIConnector(), p.GetSampleRefreshIntervalBIConnector(), p.GetTransactionLifetimeLimitSeconds(), changeStreamOptionsString) | ||
} | ||
p20240530.GetFailIndexKeyTooLong(), p20240530.GetJavascriptEnabled(), p20240530.GetMinimumEnabledTlsProtocol(), p20240530.GetNoTableScan(), | ||
p20240530.GetOplogSizeMB(), p20240530.GetSampleSizeBIConnector(), p20240530.GetSampleRefreshIntervalBIConnector(), p20240530.GetTransactionLifetimeLimitSeconds(), | ||
changeStreamOptionsString, defaultMaxTimeString) | ||
} | ||
|
||
func checkAdvanced(name, tls string, processArgs *admin.ClusterDescriptionProcessArgs20240805) resource.TestCheckFunc { | ||
advancedConfig := map[string]string{ | ||
"name": name, | ||
"advanced_configuration.0.minimum_enabled_tls_protocol": tls, | ||
"advanced_configuration.0.fail_index_key_too_long": "false", | ||
"advanced_configuration.0.javascript_enabled": "true", | ||
"advanced_configuration.0.no_table_scan": "false", | ||
"advanced_configuration.0.oplog_size_mb": "1000", | ||
"advanced_configuration.0.sample_refresh_interval_bi_connector": "310", | ||
"advanced_configuration.0.sample_size_bi_connector": "110", | ||
"advanced_configuration.0.transaction_lifetime_limit_seconds": "300", | ||
"advanced_configuration.0.change_stream_options_pre_and_post_images_expire_after_seconds": strconv.Itoa(*processArgs.ChangeStreamOptionsPreAndPostImagesExpireAfterSeconds), | ||
} | ||
|
||
if processArgs.DefaultMaxTimeMS != nil { | ||
advancedConfig["advanced_configuration.0.default_max_time_ms"] = strconv.Itoa(*processArgs.DefaultMaxTimeMS) | ||
} | ||
|
||
func checkAdvanced(name, tls, changeStreamOptions string) resource.TestCheckFunc { | ||
return checkAggr( | ||
[]string{"project_id", "replication_specs.#", "replication_specs.0.region_configs.#"}, | ||
map[string]string{ | ||
"name": name, | ||
"advanced_configuration.0.minimum_enabled_tls_protocol": tls, | ||
"advanced_configuration.0.fail_index_key_too_long": "false", | ||
"advanced_configuration.0.javascript_enabled": "true", | ||
"advanced_configuration.0.no_table_scan": "false", | ||
"advanced_configuration.0.oplog_size_mb": "1000", | ||
"advanced_configuration.0.sample_refresh_interval_bi_connector": "310", | ||
"advanced_configuration.0.sample_size_bi_connector": "110", | ||
"advanced_configuration.0.transaction_lifetime_limit_seconds": "300", | ||
"advanced_configuration.0.change_stream_options_pre_and_post_images_expire_after_seconds": changeStreamOptions}, | ||
advancedConfig, | ||
resource.TestCheckResourceAttrSet(dataSourcePluralName, "results.#"), | ||
resource.TestCheckResourceAttrSet(dataSourcePluralName, "results.0.replication_specs.#"), | ||
resource.TestCheckResourceAttrSet(dataSourcePluralName, "results.0.name")) | ||
resource.TestCheckResourceAttrSet(dataSourcePluralName, "results.0.name"), | ||
) | ||
} | ||
|
||
func configAdvancedDefaultWrite(projectID, clusterName string, p *admin20240530.ClusterDescriptionProcessArgs) string { | ||
|
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.