Skip to content
Merged
Changes from all commits
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
17 changes: 15 additions & 2 deletions mongorestore/mongorestore_archive_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"testing"

"github.com/mongodb/mongo-tools/common/archive"
"github.com/mongodb/mongo-tools/common/db"
"github.com/mongodb/mongo-tools/common/log"
"github.com/mongodb/mongo-tools/common/options"
"github.com/mongodb/mongo-tools/common/testtype"
Expand Down Expand Up @@ -174,8 +175,20 @@ func TestReadDumpServerVersionFromArchive(t *testing.T) {
defer restore.Close()

_ = restore.Restore()
expectedVersion, _ := sessionProvider.ServerVersionArray()
require.Equal(restore.dumpServerVersion, expectedVersion)

// The prelude records the server's version *string*, so compare against
// that same source. buildInfo.versionArray reports the next, unreleased
// version for source builds (8.0.16-353-gb19191c has a versionArray of
// [8, 0, 17, -100]), which would not match.
serverVersionStr, err := sessionProvider.ServerVersion()
require.NoError(err)
expectedVersion, err := db.StrToVersion(serverVersionStr)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This test is checking this error but L379 in mongorestore.go has restore.dumpServerVersion, _ = db.StrToVersion(dumpServerVersionStr) - shouldn't that follow the same pattern and at least check the error rather than discard it?

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.

It probably should, but that's much earlier work. @FGasper It looks like you wrote that. Do you remember why this doesn't check the error, by any chance?

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.

Felipe is out until next week, and I don't think this needs to block merging this test change.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Commenting just to postpone this at least until the release process for tools is complete.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Bumping this comment & adding Felipe as reviewer.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@autarch @mattb-mdb Actually, the non-checked error comes from commit f944818, which was from @shyam12860.

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 still don't think we need to solve this in order to merge this PR.

require.NoError(err)
require.Equal(
expectedVersion,
restore.dumpServerVersion,
"dumpServerVersion matches the version reported by the server",
)
})
}

Expand Down