Skip to content

TOOLS-4148 Convert all tests in integration to use the testify suite package#973

Merged
autarch merged 1 commit intomasterfrom
03-31-convert_all_tests_in_integration_to_use_the_testify_suite_package
Apr 9, 2026
Merged

TOOLS-4148 Convert all tests in integration to use the testify suite package#973
autarch merged 1 commit intomasterfrom
03-31-convert_all_tests_in_integration_to_use_the_testify_suite_package

Conversation

@autarch
Copy link
Copy Markdown
Collaborator

@autarch autarch commented Mar 31, 2026

As part of this, I created a new integration/suite package which contains code that is shared between the export/import and dump/restore tests. The helper funcs for the export/import tests are now methods on the ImportExportSuite.

@autarch autarch changed the base branch from 03-30-move_all_existing_round_trip_go_tests_to_integration_ to graphite-base/973 March 31, 2026 16:37
@autarch autarch force-pushed the graphite-base/973 branch from 6c44f53 to efb6f41 Compare April 1, 2026 16:32
@autarch autarch force-pushed the 03-31-convert_all_tests_in_integration_to_use_the_testify_suite_package branch from 86aad88 to 721a4f6 Compare April 1, 2026 16:32
@autarch autarch changed the base branch from graphite-base/973 to 03-30-move_all_existing_round_trip_go_tests_to_integration_ April 1, 2026 16:32
@autarch autarch force-pushed the 03-31-convert_all_tests_in_integration_to_use_the_testify_suite_package branch from 721a4f6 to 5f9bf57 Compare April 1, 2026 18:33
@autarch autarch changed the base branch from 03-30-move_all_existing_round_trip_go_tests_to_integration_ to graphite-base/973 April 1, 2026 19:30
@autarch autarch force-pushed the 03-31-convert_all_tests_in_integration_to_use_the_testify_suite_package branch from 5f9bf57 to 13ba381 Compare April 1, 2026 19:31
@autarch autarch force-pushed the graphite-base/973 branch from efb6f41 to 53ae805 Compare April 1, 2026 19:31
@graphite-app graphite-app bot changed the base branch from graphite-base/973 to master April 1, 2026 19:32
@autarch autarch force-pushed the 03-31-convert_all_tests_in_integration_to_use_the_testify_suite_package branch 5 times, most recently from cc948a7 to 323143c Compare April 1, 2026 20:34
@autarch autarch requested a review from mmcclimon April 1, 2026 21:08
@autarch autarch marked this pull request as ready for review April 1, 2026 21:09
@autarch autarch requested a review from a team as a code owner April 1, 2026 21:09
Copy link
Copy Markdown
Contributor

@mmcclimon mmcclimon left a comment

Choose a reason for hiding this comment

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

I didn't read everything closely here because I noticed enough on the skim that I think we should take another run at this one. Probably you could catch nearly everything by searching for s.T() and removing nearly all of them. (It's probably totally reasonable to make s.Context() which is just a wrapper for s.T().Context(), for example.)

Comment thread integration/dumprestore/roundtrip_test.go Outdated
Comment thread integration/dumprestore/roundtrip_test.go Outdated
Comment thread integration/dumprestore/roundtrip_test.go Outdated
Comment thread integration/importexport/csv_test.go Outdated
@autarch autarch force-pushed the 03-31-convert_all_tests_in_integration_to_use_the_testify_suite_package branch from 323143c to e8844d7 Compare April 3, 2026 22:18
Copy link
Copy Markdown
Collaborator Author

autarch commented Apr 3, 2026

I added an s.Contextmethod. At this point, there are only a few s.T()calls left in the integration tests, and they all seem reasonable.

@autarch autarch changed the base branch from master to graphite-base/973 April 8, 2026 16:03
@autarch autarch force-pushed the 03-31-convert_all_tests_in_integration_to_use_the_testify_suite_package branch from e8844d7 to 9842ff5 Compare April 8, 2026 16:03
@autarch autarch changed the base branch from graphite-base/973 to 04-03-tools-4148_pass_the_errgroup_created_in_streamdocuments_to_dosequentialstreaming_ April 8, 2026 16:03
@autarch autarch force-pushed the 03-31-convert_all_tests_in_integration_to_use_the_testify_suite_package branch from 9842ff5 to 4af151d Compare April 8, 2026 16:05
@autarch autarch closed this Apr 8, 2026
@autarch autarch reopened this Apr 8, 2026
@autarch autarch marked this pull request as draft April 8, 2026 17:27
@autarch autarch marked this pull request as ready for review April 8, 2026 17:27
@autarch autarch requested a review from mmcclimon April 8, 2026 17:27
@autarch autarch changed the base branch from 04-03-tools-4148_pass_the_errgroup_created_in_streamdocuments_to_dosequentialstreaming_ to graphite-base/973 April 8, 2026 19:53
@autarch autarch force-pushed the graphite-base/973 branch from 4f5e086 to 4c3fdbb Compare April 8, 2026 20:39
@autarch autarch force-pushed the 03-31-convert_all_tests_in_integration_to_use_the_testify_suite_package branch from 4af151d to b907c8a Compare April 8, 2026 20:40
@autarch autarch changed the base branch from graphite-base/973 to 04-03-tools-4148_pass_the_errgroup_created_in_streamdocuments_to_dosequentialstreaming_ April 8, 2026 20:40
@autarch autarch changed the base branch from 04-03-tools-4148_pass_the_errgroup_created_in_streamdocuments_to_dosequentialstreaming_ to graphite-base/973 April 8, 2026 21:08
@autarch autarch force-pushed the 03-31-convert_all_tests_in_integration_to_use_the_testify_suite_package branch from b907c8a to fb5a1b5 Compare April 8, 2026 21:11
@autarch autarch force-pushed the graphite-base/973 branch from 4c3fdbb to 5d5ee94 Compare April 8, 2026 21:11
@graphite-app graphite-app bot changed the base branch from graphite-base/973 to master April 8, 2026 21:12
@autarch autarch force-pushed the 03-31-convert_all_tests_in_integration_to_use_the_testify_suite_package branch from fb5a1b5 to 098c623 Compare April 8, 2026 21:12
@autarch autarch changed the title Convert all tests in integration to use the testify suite package TOOLS-4148 Convert all tests in integration to use the testify suite package Apr 8, 2026
Copy link
Copy Markdown
Contributor

@mmcclimon mmcclimon left a comment

Choose a reason for hiding this comment

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

Ok. These tests are all still sort of weird, but I guess they're getting less weird over time, which is the goal.

Comment thread integration/importexport/suite_test.go Outdated
"github.com/mongodb/mongo-tools/common/testtype"
"github.com/mongodb/mongo-tools/common/testutil"
"github.com/mongodb/mongo-tools/common/wcwrapper"
integrationSuite "github.com/mongodb/mongo-tools/integration/suite"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should we name this package something that's not suite so that we don't have to alias it like this?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Renamed to sharedsuite.

Comment thread integration/importexport/suite_test.go Outdated
Comment on lines +81 to +84
sessionProvider, _, err := testutil.GetBareSessionProvider()
s.Require().NoError(err, "should create session provider")
client, err := sessionProvider.GetSession()
s.Require().NoError(err, "should get session")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This should just use s.Client().

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed.

Comment thread integration/importexport/suite_test.go Outdated
}

func (s *ImportExportSuite) recreateWithValidator(coll *mongo.Collection, validator any) {
s.Require().NoError(coll.Database().Drop(context.Background()))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
s.Require().NoError(coll.Database().Drop(context.Background()))
s.Require().NoError(coll.Database().Drop(s.Context()))

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done

Comment thread integration/importexport/suite_test.go Outdated
s.Require().NoError(coll.Database().Drop(context.Background()))
s.Require().NoError(
coll.Database().CreateCollection(
context.Background(), coll.Name(), mopt.CreateCollection().SetValidator(validator),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
context.Background(), coll.Name(), mopt.CreateCollection().SetValidator(validator),
s.Context(), coll.Name(), mopt.CreateCollection().SetValidator(validator),

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done


func runBSONMongodumpForCollection(
t *testing.T,
func (s *DumpRestoreSuite) runBSONMongodumpForCollection(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It's a little weird that this package defines all these helpers in this main test file, while the exportimport package defines them in the suite helpers file.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I moved the helpers.

Comment on lines +704 to +705
s.Run("If --dumpUsersAndRoles was not used with the target", func() {
s.Run("Restoring from db directory should not be allowed", func() {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

(These subtest names are still extremely convey-coded.)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I modified several other subtest names.

Comment on lines +85 to +87
s.T().Cleanup(func() {
_ = client.Database(dbName).Drop(context.Background())
})
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is super weird, but probably (I hope) this goes away in the next PR to run a BeforeTest cleanup thing.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yes, it goes away.

@autarch autarch force-pushed the 03-31-convert_all_tests_in_integration_to_use_the_testify_suite_package branch from 098c623 to 2331e2c Compare April 9, 2026 17:08
@autarch autarch force-pushed the 03-31-convert_all_tests_in_integration_to_use_the_testify_suite_package branch from 2331e2c to 30988fd Compare April 9, 2026 20:21
Copy link
Copy Markdown
Collaborator Author

autarch commented Apr 9, 2026

Merge activity

  • Apr 9, 9:08 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Apr 9, 9:08 PM UTC: @autarch merged this pull request with Graphite.

@autarch autarch merged commit b2c8c06 into master Apr 9, 2026
40 checks passed
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.

2 participants