Skip to content

Conversation

@EspenAlbert
Copy link
Collaborator

@EspenAlbert EspenAlbert commented Jan 17, 2025

Description

Updates importIgnoredFields function to handle dynamic replication specs

Type of change:

  • Bug fix (non-breaking change which fixes an issue). Please, add the "bug" label to the PR.
  • New feature (non-breaking change which adds functionality). Please, add the "enhancement" label to the PR. A migration guide must be created or updated if the new feature will go in a major version.
  • Breaking change (fix or feature that would cause existing functionality to not work as expected). Please, add the "breaking change" label to the PR. A migration guide must be created or updated.
  • This change requires a documentation update
  • Documentation fix/enhancement

Required Checklist:

  • I have signed the MongoDB CLA
  • I have read the contributing guides
  • I have checked that this change does not generate any credentials and that they are NOT accidentally logged anywhere.
  • I have added tests that prove my fix is effective or that my feature works per HashiCorp requirements
  • I have added any necessary documentation (if appropriate)
  • I have run make fmt and formatted my code
  • If changes include deprecations or removals I have added appropriate changelog entries.
  • If changes include removal or addition of 3rd party GitHub actions, I updated our internal document. Reach out to the APIx Integration slack channel to get access to the internal document.

Further comments

@EspenAlbert EspenAlbert marked this pull request as ready for review January 17, 2025 09:53
@EspenAlbert EspenAlbert requested a review from a team as a code owner January 17, 2025 09:53
func importIgnoredFields() []string {
func importIgnoredFields(replicationSpecs int) []string {
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

"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

}

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

@lantoli lantoli merged commit fd5a9f0 into master Jan 20, 2025
67 of 68 checks passed
@lantoli lantoli deleted the adv_cluster_import_verify_fix branch January 20, 2025 08:31
lantoli added a commit that referenced this pull request Jan 20, 2025
* master:
  build(deps): bump go.mongodb.org/atlas-sdk (#2979)
  test: Updates importIgnoredFields function to handle dynamic replication specs (#2977)

# Conflicts:
#	internal/testutil/acc/advanced_cluster.go
// However, as import doesn't have a previous state to compare with, import will always fill them.
// This will make these fields differ in the state, although the plan change won't be shown to the user as they're computed values.
if !config.AdvancedClusterV2Schema() {
ignorePrefixFields = append(ignorePrefixFields, "replication_specs")
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is quite broad. But I like that you could use the TestStepImportCluster instead of the extra helper

Copy link
Member

@lantoli lantoli Jan 21, 2025

Choose a reason for hiding this comment

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

@EspenAlbert it is for SDKv2 tests, but reality is that any spec that is not in the definition file must be included, so at then it's like playing to exclude the elements that are not in the definition file.

however it's more restrict for TPF now, because some tests had "replication_specs" for SDKv2 and TPF, not this is only for SDKv2 tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants