Skip to content

Conversation

@maastha
Copy link
Collaborator

@maastha maastha commented Aug 5, 2025

Description

Updates advanced_cluster migration tests to primarily use TPF. This is a follow-up to #3547

Link to any related issue(s): CLOUDP-334497

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

@maastha maastha changed the base branch from master to CLOUDP-334497-disable_adv_clusterSDKv2-b August 5, 2025 19:49
@maastha maastha changed the title chore: tmp chore: Adds tmp Aug 5, 2025
@maastha maastha changed the title chore: Adds tmp chore: Updates advanced_cluster migration tests to primarily use TPF Aug 6, 2025
package advancedcluster_test

import (
"fmt"
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

internal/service/advancedcluster/resource_advanced_cluster_migration_test.go and internal/service/advancedcluster/resource_advanced_cluster_test.go will be moved to tpf package in follow-up PRs

Comment on lines +831 to +833
Config: configGeoShardedOldSchema(t, projectID, clusterName, 2, 2, false, isSDKv2),
Check: resource.ComposeAggregateTestCheckFunc(
checkGeoShardedOldSchema(usePreviewProvider, clusterName, 2, 2, true, false),
checkGeoShardedOldSchema(isTPF, clusterName, 2, 2, true, false),
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

since migration tests run for both SDK & TPF, I've not updated the check methods but have removed usages of acc.ConvertAdvancedClusterToPreviewProviderV2()

@maastha maastha marked this pull request as ready for review August 6, 2025 11:25
@maastha maastha requested a review from a team as a code owner August 6, 2025 11:25
Copy link
Collaborator

@EspenAlbert EspenAlbert left a comment

Choose a reason for hiding this comment

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

What is the migration testing strategy for 1.x.x --> 2.x.x.
Will we test:

  1. SDKv2 implementation --> v2 implementation
  2. TPF implementation --> v2 implementation

I am assuming both?

Comment on lines +51 to +55
{
ExternalProviders: acc.ExternalProviders(versionBeforeTPFGARelease),
Config: configShardedTransitionOldToNewSchema(t, false, projectID, clusterName, true, false),
Check: checkShardedTransitionOldToNewSchema(false, true),
},
Copy link
Member

Choose a reason for hiding this comment

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

q: Where you able to confirm this intermediate step of removing num_shards is necessary before 2.x upgrade?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I ran TestMigAdvancedCluster_geoShardedMigrationFromOldToNewSchema without the second step & it did work. Should we update the guide or leave it as is?

Copy link
Member

Choose a reason for hiding this comment

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

I would be more inclined to adjusting the guide. Can we bring this up in the technical sync so we align and make sure we are not missing anything?

}

func configShardedNewSchema(t *testing.T, usePreviewProvider bool, orgID, projectName, name string, diskSizeGB int, firstInstanceSize, lastInstanceSize string, firstDiskIOPS, lastDiskIOPS *int, includeMiddleSpec, increaseDiskSizeShard2 bool) string {
func configShardedNewSchema(t *testing.T, orgID, projectName, name string, diskSizeGB int, firstInstanceSize, lastInstanceSize string, firstDiskIOPS, lastDiskIOPS *int, includeMiddleSpec, increaseDiskSizeShard2 bool, useSDKv2 ...bool) string {
Copy link
Member

Choose a reason for hiding this comment

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

why do we pass useSDKv2 as a boolean list?

Copy link
Collaborator Author

@maastha maastha Aug 6, 2025

Choose a reason for hiding this comment

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

to keep it as an optional parameter, so not every caller has to use/specify it, only the migration functions

name = %[3]q
backup_enabled = false
cluster_type = "SHARDED"
dataSourcesConfig := `
Copy link
Member

Choose a reason for hiding this comment

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

Thinking if for cases where we need both SDK v2 and TPF syntax configs (believe it would only be migration tests), we continue leveraging a conversion function similar to ConvertAdvancedClusterToPreviewProviderV2 to avoid duplicating configs. Maybe this is only for select number of tests and not needed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yeah that's why for now I chose to duplicate the configs and handle migration tests separately. If we see a need for much such test cases arising then we can consider a conversion function but at this point I don't think that's required

const versionBeforeISSRelease = "1.17.6"

// last version that supported mongodbatlas_advanced_cluster SDKv2 resource
const versionBeforeTPFGARelease = "1.39.0"
Copy link
Collaborator

Choose a reason for hiding this comment

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

based on the q-plan, we'll still have until 1.41.0

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

updated the workflow to use MONGODB_ATLAS_LAST_1X_VERSION env var instead of hardcoding, lmk WYT

- name: Acceptance Tests
env:
MONGODB_ATLAS_LAST_VERSION: ${{ needs.get-provider-version.outputs.provider_version }}
MONGODB_ATLAS_LAST_1X_VERSION: ${{ inputs.mongodb_atlas_last_1x_version }}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would it make sense to create a advanced_cluster_tpf_mig_from_tpf? This way we will have a clean separation between acc/mig tests?

uses: ./.github/workflows/acceptance-tests.yml
with:
reduced_tests: true
reduced_tests: false
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this for debugging? Shouldn't it be true by default?


resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { mig.PreCheckBasic(t) },
PreCheck: func() { mig.PreCheckBasic(t); mig.PreCheckLast1XVersion(t) },
Copy link
Collaborator

Choose a reason for hiding this comment

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

I see this pre check only in 2 migration tests. Do we plan on using it in more?
I guess, all mig tests will use the latests version, but as soon as we release 2.0 we will only have two tests covering this.
An alternative would be to use a different test group for testing 1.x --> 2.latest and pass LAST_VERSION env-var explicilty using the MONGODB_ATLAS_LAST_1X_VERSION

}

func TestCheckResourceAttrPreviewProviderV2(usePreviewProvider bool, name, key, value string) resource.TestCheckFunc {
func TestCheckResourceAttrTPF(usePreviewProvider bool, name, key, value string) resource.TestCheckFunc {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm struggling a bit to understand this function now.
We are using TPF in the name, but arguments and calls uses previewProvider.
Any way to simplify this? Can we remove previewProvider everywhere?

@maastha maastha merged commit df5313f into CLOUDP-334497-disable_adv_clusterSDKv2-b Aug 8, 2025
72 of 74 checks passed
@maastha maastha deleted the CLOUDP-334497-disable_adv_clusterSDKv2-b-make-tpf-primary branch August 8, 2025 20:38
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.

5 participants