diff --git a/src/go/mongolib/explain/explain_test.go b/src/go/mongolib/explain/explain_test.go index 47bc9d28..70ecfa92 100644 --- a/src/go/mongolib/explain/explain_test.go +++ b/src/go/mongolib/explain/explain_test.go @@ -109,7 +109,7 @@ func TestExplain(t *testing.T) { for _, v := range versions { // For versions < 3.4 parsing "getmore" is not supported and returns error if ok, _ := Constraint("< 3.4", v); ok { - expectError["getmore_"+v] = "Cannot explain cmd: getMore" + expectError["getmore_"+v] = "Explain failed due to unknown command: getmore" } } diff --git a/src/go/mongolib/proto/system.profile.go b/src/go/mongolib/proto/system.profile.go index 6b2784ac..979d7b43 100644 --- a/src/go/mongolib/proto/system.profile.go +++ b/src/go/mongolib/proto/system.profile.go @@ -224,9 +224,20 @@ func (self ExampleQuery) ExplainCmd() bson.D { case "getmore": if self.OriginatingCommand.Len() > 0 { cmd = self.OriginatingCommand + for i := range cmd { + // drop $db param as it is not supported in MongoDB 3.0 + if cmd[i].Name == "$db" { + if len(cmd)-1 == i { + cmd = cmd[:i] + } else { + cmd = append(cmd[:i], cmd[i+1:]...) + } + break + } + } } else { cmd = BsonD{ - {Name: "getMore", Value: ""}, + {Name: "getmore", Value: ""}, } } case "command": diff --git a/src/go/pt-mongodb-query-digest/main_test.go b/src/go/pt-mongodb-query-digest/main_test.go index a2f76f39..f1260176 100644 --- a/src/go/pt-mongodb-query-digest/main_test.go +++ b/src/go/pt-mongodb-query-digest/main_test.go @@ -413,8 +413,7 @@ func testAllOperationsTemplate(t *testing.T, data Data) { }, } - ndocs := "165" - expected := `Profiler is disabled for the "test" database but there are ` + ndocs + ` documents in the system.profile collection. + expected := `Profiler is disabled for the "test" database but there are \s*[0-9]+ documents in the system.profile collection. Using those documents for the stats pt-mongodb-query-digest .+ Host: ` + data.url + ` @@ -425,7 +424,7 @@ Skipping profiled queries on these collections: \[system\.profile\] # Ratio [0-9\.]+ \(docs scanned/returned\) # Attribute pct total min max avg 95% stddev median # ================== === ======== ======== ======== ======== ======== ======= ======== -# Count \(docs\) ` + ndocs + `\s +# Count \(docs\) (\s*[0-9]+)\s # Exec Time ms (\s*[0-9]+){8}\s # Docs Scanned (\s*[0-9\.]+){8}\s # Docs Returned (\s*[0-9\.]+){8}\s