-
Notifications
You must be signed in to change notification settings - Fork 191
chore: Adds import checks to tests #3039
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
Conversation
@@ -53,6 +53,7 @@ var ( | |||
func TestStepImportCluster(resourceName string, ignorePrefixFields ...string) resource.TestStep { | |||
ignorePrefixFields = append(ignorePrefixFields, | |||
"retain_backups_enabled", // This field is TF specific and not returned by Atlas, so Import can't fill it in. | |||
"mongo_db_major_version", // Risks plan change of 8 --> 8.0 (always normalized to `major.minor`) |
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.
Could potentially use a custom type to avoid plan changes, but seems overkill.
Both the apply for retain_backups_enabled
and mongo_db_major_version
are instant
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.
although it's instant, I think it can be confusing for the user to see these plan changes, and think for example that cluster version will change and could lose data / affect cluster config.
we might do something like in Move/Upgrade setOptionalModelAttrs
:
if mongoDBMajorVersion := getAttrFromStateObj[string](stateObj, "mongo_db_major_version"); mongoDBMajorVersion != nil {
model.MongoDBMajorVersion = types.StringPointerValue(mongoDBMajorVersion)
}
in Import we don't have previous state but we can get from Atlas.
Or if we shouldn't call Atlas from Import, then we can set a dummy value in mongo_db_major_version so it's not null and the good value will be set in Read.
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.
Interesting approach. But I don't see how this will solve the problem.
The problem is the support of two different formats in the config:
8
8.0
We cannot know at import time which format they used, so we use what is returned by the API (8.0
)
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.
ah, ok, the problem is only when the user specifies mongo_db_major_version in the config? there are no plan changes if mongo_db_major_version is not in the config?
in that case ok to leave it as it is.
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.
Exactly 👍
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.
I'm good then, thanks!
@@ -965,6 +984,7 @@ func TestAccAdvancedCluster_replicaSetScalingStrategyAndRedactClientLogDataOldSc | |||
Config: configReplicaSetScalingStrategyAndRedactClientLogDataOldSchema(t, true, orgID, projectName, clusterName, "NODE_TYPE", false), | |||
Check: checkReplicaSetScalingStrategyAndRedactClientLogData(true, "NODE_TYPE", false), | |||
}, | |||
acc.TestStepImportCluster(resourceName, "replication_specs"), // Import with old schema will NOT use `num_shards` |
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.
Example of explicit replication_specs
ignore when the old sharding configuration is used
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.
nice to add an explanation
@@ -151,7 +151,7 @@ func getTimeoutFromStateObj(stateObj map[string]tftypes.Value) timeouts.Value { | |||
return timeouts.Value{Object: obj} | |||
} | |||
|
|||
func setOptionalModelAttrs(ctx context.Context, stateObj map[string]tftypes.Value, model *TFModel) { | |||
func setOptionalModelAttrs(stateObj map[string]tftypes.Value, model *TFModel) { |
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.
opportunistic removal of unused param
@@ -166,6 +166,7 @@ func TestAccMockableAdvancedCluster_tenantUpgrade(t *testing.T) { | |||
Config: acc.ConvertAdvancedClusterToSchemaV2(t, true, configTenantUpgraded(projectID, clusterName, defaultZoneName)), | |||
Check: checksTenantUpgraded(projectID, clusterName), | |||
}, | |||
acc.TestStepImportCluster(resourceName), |
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.
nice to add more test checks/steps
* master: doc: Renames env var to `MONGODB_ATLAS_PREVIEW_PROVIDER_V2_ADVANCED_CLUSTER` (#3062) chore: Updates Atlas Go SDK (#3053) test: Tenant clusters with disk_size_gb is always 5 now (#3057) chore: Updates CHANGELOG.md for #3051 fix: Removes `interval_min` plan modifier to avoid error on update (#3051) build(deps): bump go.mongodb.org/atlas-sdk (#3049) doc: Adds pinned_fcv.version as exported attribute in cluster and advanced cluster resource (#3047) update Go to 1.23.6 (#3045) chore: Adds HTTP status check helper methods (#3035) chore: Adds import checks to tests (#3039) chore: Updates CHANGELOG.md header for v1.26.1 release chore: Updates examples link in index.md for v1.26.1 release fix: Adds "state_name" to keepUnknown list to prevent copying volatile attributes from state (#3040)
Description
Adds import checks to tests
Link to any related issue(s): CLOUDP-298071
Type of change:
Required Checklist:
Further comments