Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1190,7 +1190,7 @@ func TestAccMockableAdvancedCluster_replicasetAdvConfigUpdate(t *testing.T) {
Config: configBasicReplicaset(t, projectID, clusterName, fullUpdate),
Check: checksUpdate,
},
acc.TestStepImportCluster(resourceName, importIgnoredFields()...),
acc.TestStepImportCluster(resourceName, importIgnoredFields(1)...),
},
})
}
Expand Down Expand Up @@ -1233,7 +1233,7 @@ func TestAccMockableAdvancedCluster_shardedAddAnalyticsAndAutoScaling(t *testing
Config: configSharded(t, projectID, clusterName, true),
Check: checksUpdated,
},
acc.TestStepImportCluster(resourceName, importIgnoredFields()...),
acc.TestStepImportCluster(resourceName, importIgnoredFields(2)...),
},
})
}
Expand Down Expand Up @@ -2782,13 +2782,17 @@ func configFCVPinning(t *testing.T, orgID, projectName, clusterName string, pinn
`, orgID, projectName, clusterName, mongoDBMajorVersion, pinnedFCVAttr)) + dataSourcesTFNewSchema
}

func importIgnoredFields() []string {
func importIgnoredFields(replicationSpecs int) []string {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why these ignored methods and why adding now the int?

I am not seeing a lot of documentation and this code is going to be very hard to follow and understand why in few months

Copy link
Member

@lantoli lantoli Jan 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note that it has a AdvancedClusterV2Schema clause. It's because SDKv2 doesn't fill those fields (we talked about this in yesterday's meeting) so we don't want to check those attributes only for TPF. Maybe a better param name would be replicationSpecCount, to specify how many replicationSpecs are, so we want to ignore those attribute changes in import tests, as we know they happen because SDKv2 and TPF fill them differently.

these attribute checks are new to TPF, were not being done in SDKv2

Copy link
Member

@lantoli lantoli Jan 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doc added and refactor, please see the latest code

if config.AdvancedClusterV2Schema() {
return []string{}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: i think you can just return nil here

}
return []string{
"replication_specs.0.region_configs.0.read_only_specs",
"replication_specs.0.region_configs.0.analytics_specs",
"replication_specs.0.region_configs.0.electable_specs.0.ebs_volume_type",
ignored := []string{}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: similarly, you don't need to initialize, can just do:

var ignored []string

nil slices are in general equivalent to empy (non-nil) ones

for i := range replicationSpecs {
ignored = append(ignored,
fmt.Sprintf("replication_specs.%d.region_configs.0.read_only_specs", i),
fmt.Sprintf("replication_specs.%d.region_configs.0.analytics_specs", i),
fmt.Sprintf("replication_specs.%d.region_configs.0.electable_specs.0.ebs_volume_type", i),
)
}
return ignored
}
Loading