From 7157768b4a766c5b501e18092d011bdbda40d037 Mon Sep 17 00:00:00 2001 From: Nurlan Moldomurov Date: Wed, 16 Oct 2024 06:08:36 +0300 Subject: [PATCH] PMM-11180 fix mongodb tests. --- .../internal/profiler/profiler_test.go | 22 +++++++++++++++++-- .../actions/mongodb_explain_action_test.go | 1 + 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/agent/agents/mongodb/internal/profiler/profiler_test.go b/agent/agents/mongodb/internal/profiler/profiler_test.go index b6e044ee02..171c77bc90 100644 --- a/agent/agents/mongodb/internal/profiler/profiler_test.go +++ b/agent/agents/mongodb/internal/profiler/profiler_test.go @@ -221,6 +221,7 @@ func testProfiler(t *testing.T, url string) { Dsn: tests.GetTestMongoDBDSN(t), Query: findBucket.Common.Example, } + client := tests.OpenTestMongoDB(t, params.Dsn) ex, err := actions.NewMongoDBExplainAction(id, 5*time.Second, params, os.TempDir()) require.NoError(t, err) @@ -238,8 +239,25 @@ func testProfiler(t *testing.T, url string) { "$eq": "value_00\ufffd", }, }, - "plannerVersion": map[string]interface{}{"$numberInt": "1"}, - "rejectedPlans": []interface{}{}, + "rejectedPlans": []interface{}{}, + } + mongoDBVersion := tests.MongoDBVersion(t, client) + + switch mongoDBVersion { + case "4.4": + want["plannerVersion"] = map[string]interface{}{"$numberInt": "1"} + case "5.0": + want["maxIndexedAndSolutionsReached"] = false + want["maxIndexedOrSolutionsReached"] = false + want["maxScansToExplodeReached"] = false + case "6.0": + want["maxIndexedAndSolutionsReached"] = false + want["maxIndexedOrSolutionsReached"] = false + want["maxScansToExplodeReached"] = false + case "7.0": + want["maxIndexedAndSolutionsReached"] = false + want["maxIndexedOrSolutionsReached"] = false + want["maxScansToExplodeReached"] = false } explainM := make(map[string]interface{}) diff --git a/agent/runner/actions/mongodb_explain_action_test.go b/agent/runner/actions/mongodb_explain_action_test.go index 15ec35a201..13bee4627a 100644 --- a/agent/runner/actions/mongodb_explain_action_test.go +++ b/agent/runner/actions/mongodb_explain_action_test.go @@ -286,6 +286,7 @@ func TestMongoDBExplain(t *testing.T) { "winningPlan": map[string]interface{}{"stage": "EOF"}, } mongoDBVersion := tests.MongoDBVersion(t, client) + fmt.Printf("MongoDB version: %s\n", mongoDBVersion) switch mongoDBVersion { case "4.4":