mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-13 14:39:28 +00:00
Fixed pt-mongodb-query-digest tests
This commit is contained in:
@@ -255,6 +255,7 @@ func getOptions() (*options, error) {
|
||||
OrderBy: strings.Split(DEFAULT_ORDERBY, ","),
|
||||
SkipCollections: strings.Split(DEFAULT_SKIPCOLLECTIONS, ","),
|
||||
AuthDB: DEFAULT_AUTHDB,
|
||||
OutputFormat: "text",
|
||||
}
|
||||
|
||||
gop := getopt.New()
|
||||
@@ -308,8 +309,8 @@ func getOptions() (*options, error) {
|
||||
}
|
||||
|
||||
if opts.OutputFormat != "json" && opts.OutputFormat != "text" {
|
||||
opts.OutputFormat = "text"
|
||||
log.Infof("Invalid output format '%s'. Using text format", opts.OutputFormat)
|
||||
opts.OutputFormat = "text"
|
||||
}
|
||||
|
||||
if gop.IsSet("password") && opts.Password == "" {
|
||||
|
@@ -18,6 +18,7 @@ import (
|
||||
"text/template"
|
||||
"time"
|
||||
|
||||
"github.com/kr/pretty"
|
||||
"github.com/pborman/getopt/v2"
|
||||
"github.com/percona/percona-toolkit/src/go/lib/profiling"
|
||||
"github.com/percona/percona-toolkit/src/go/lib/tutil"
|
||||
@@ -235,24 +236,10 @@ func testEmptySystemProfile(t *testing.T, data Data) {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
expected := `pt-mongodb-query-digest .+
|
||||
Host: ` + data.url + `
|
||||
Skipping profiled queries on these collections: \[system\.profile\]
|
||||
|
||||
|
||||
# Totals
|
||||
# Ratio 0.00 \(docs scanned/returned\)
|
||||
# Attribute pct total min max avg 95% stddev median
|
||||
# ================== === ======== ======== ======== ======== ======== ======= ========
|
||||
# Count \(docs\) 0\s
|
||||
# Exec Time ms 0 NaN NaN NaN NaN NaN NaN NaN\s
|
||||
# Docs Scanned 0 NaN NaN NaN NaN NaN NaN NaN\s
|
||||
# Docs Returned 0 NaN NaN NaN NaN NaN NaN NaN\s
|
||||
# Bytes sent 0 NaN NaN NaN NaN NaN NaN NaN\s
|
||||
#\s
|
||||
`
|
||||
|
||||
assertRegexpLines(t, expected, string(output))
|
||||
expected := "No queries found in profiler information for database \\\"test\\\""
|
||||
if !strings.Contains(string(output), expected) {
|
||||
t.Errorf("Empty system.profile.\nGot:\n%s\nWant:\n%s\n", string(output), expected)
|
||||
}
|
||||
}
|
||||
|
||||
func testAllOperationsTemplate(t *testing.T, data Data) {
|
||||
@@ -463,6 +450,9 @@ Skipping profiled queries on these collections: \[system\.profile\]
|
||||
|
||||
expected += buf.String()
|
||||
}
|
||||
fmt.Println("====================================================================================================")
|
||||
pretty.Println(string(output))
|
||||
fmt.Println("====================================================================================================")
|
||||
|
||||
assertRegexpLines(t, expected, string(output))
|
||||
}
|
||||
|
Reference in New Issue
Block a user