Skip to content
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

test: Converting a test case to a migration test #2081

Merged

Conversation

EspenAlbert
Copy link
Collaborator

@EspenAlbert EspenAlbert commented Mar 26, 2024

Description

support converting a test case to a migration test

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

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.
  • Breaking change (fix or feature that would cause existing functionality to not work as expected). Please, add the "breaking change" label to the PR.
  • This change requires a documentation update
  • Documentation fix/enhancement

Required Checklist:

  • I have signed the MongoDB CLA
  • I have read the contribution guidelines
  • 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 defined an isolated PR with a relevant title as it will be used in the auto-generated changelog.
  • 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

Introduces two helper functions:

  1. ConvertToMigrationTest: default way of creating a new test case from an existing basic test
  2. ConvertToMigrationTestUseExternalProvider: when the test case requires a specific version or aws provider
    • e.g., resource_privatelink_endpoint_service_migration_test.go
    • resource_encryption_at_rest_migration_test.go

})
defaultAssertions(test)
})
// ConvertToMigrationTestUseExternalProvider
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Put both unit test for: ConvertToMigrationTest and ConvertToMigrationTestUseExternalProvider in the same test as they are reusing some internal functions.
However, would love to see suggestions of how to make this test cleaner

Copy link
Member

Choose a reason for hiding this comment

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

it's quite a big test, don't know if some nested tests could be extracted to functions, or if a table-based test would help here

@EspenAlbert EspenAlbert marked this pull request as ready for review March 26, 2024 11:46
@EspenAlbert EspenAlbert requested a review from a team as a code owner March 26, 2024 11:46
@@ -11,18 +11,19 @@ import (
"github.com/mongodb/terraform-provider-mongodbatlas/internal/testutil/acc"
)

func TestAccSearchIndex_basic(t *testing.T) {
func basicTestCase(tb testing.TB) *resource.TestCase {
Copy link
Member

@lantoli lantoli Mar 26, 2024

Choose a reason for hiding this comment

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

it's great for this example. In some cases we might want to pass projectID so we get the execution project in acc tests but global project in mig, but that's specific to the tests so no changes needed in the infra

Copy link
Member

@lantoli lantoli left a comment

Choose a reason for hiding this comment

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

great job!

@EspenAlbert EspenAlbert merged commit e8215b2 into master Mar 27, 2024
46 checks passed
@EspenAlbert EspenAlbert deleted the CLOUDP-239310_convert_acceptance_test_case_in_migration_tests branch March 27, 2024 09:14
lantoli added a commit that referenced this pull request Apr 1, 2024
* master:
  test: Introduces shared cluster resource for running search index tests (#2086)
  doc: Generates v1.15.3 (#2095)
  chore: Bump github.com/zclconf/go-cty from 1.14.3 to 1.14.4 (#2089)
  chore: Bump github.com/mongodb-forks/digest from 1.0.5 to 1.1.0 (#2087)
  chore: Bump github.com/hashicorp/hcl/v2 from 2.20.0 to 2.20.1 (#2091)
  chore: Bump tj-actions/verify-changed-files (#2092)
  chore: Bump github.com/aws/aws-sdk-go from 1.51.3 to 1.51.8 (#2088)
  test: Converting a test case to a migration test (#2081)
  chore: Fixes Slack notification button to GH action run text (#2093)
  doc: Specifies that upgrades From Replica Sets to Multi-Sharded Instances of cluster and advanced cluster might lead to error (#2080)
  doc: Fixes import command in third_party_integration doc (#2083)
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.

None yet

4 participants