From 220c8c04e065ad3d9949482cc2d2f65deea35d99 Mon Sep 17 00:00:00 2001 From: Dave Rolsky Date: Mon, 10 Aug 2026 16:41:39 -0500 Subject: [PATCH] TOOLS-4319 Fix `TestReadDumpServerVersionFromArchive` to work when run with all Server builds If we use a Server binary built from an arbitrary git commit, this test will fail because it compares the literal Server version string against the version returned by the Server's `buildInfo` command, e.g. "8.0.16-353-gb19191c" vs `[8, 0, 17, -199]`). --- mongorestore/mongorestore_archive_test.go | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/mongorestore/mongorestore_archive_test.go b/mongorestore/mongorestore_archive_test.go index d2d315023..12f0104bb 100644 --- a/mongorestore/mongorestore_archive_test.go +++ b/mongorestore/mongorestore_archive_test.go @@ -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" @@ -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) + require.NoError(err) + require.Equal( + expectedVersion, + restore.dumpServerVersion, + "dumpServerVersion matches the version reported by the server", + ) }) }