mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-20 02:44:58 +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, ","),
|
OrderBy: strings.Split(DEFAULT_ORDERBY, ","),
|
||||||
SkipCollections: strings.Split(DEFAULT_SKIPCOLLECTIONS, ","),
|
SkipCollections: strings.Split(DEFAULT_SKIPCOLLECTIONS, ","),
|
||||||
AuthDB: DEFAULT_AUTHDB,
|
AuthDB: DEFAULT_AUTHDB,
|
||||||
|
OutputFormat: "text",
|
||||||
}
|
}
|
||||||
|
|
||||||
gop := getopt.New()
|
gop := getopt.New()
|
||||||
@@ -308,8 +309,8 @@ func getOptions() (*options, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if opts.OutputFormat != "json" && opts.OutputFormat != "text" {
|
if opts.OutputFormat != "json" && opts.OutputFormat != "text" {
|
||||||
opts.OutputFormat = "text"
|
|
||||||
log.Infof("Invalid output format '%s'. Using text format", opts.OutputFormat)
|
log.Infof("Invalid output format '%s'. Using text format", opts.OutputFormat)
|
||||||
|
opts.OutputFormat = "text"
|
||||||
}
|
}
|
||||||
|
|
||||||
if gop.IsSet("password") && opts.Password == "" {
|
if gop.IsSet("password") && opts.Password == "" {
|
||||||
|
@@ -18,6 +18,7 @@ import (
|
|||||||
"text/template"
|
"text/template"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/kr/pretty"
|
||||||
"github.com/pborman/getopt/v2"
|
"github.com/pborman/getopt/v2"
|
||||||
"github.com/percona/percona-toolkit/src/go/lib/profiling"
|
"github.com/percona/percona-toolkit/src/go/lib/profiling"
|
||||||
"github.com/percona/percona-toolkit/src/go/lib/tutil"
|
"github.com/percona/percona-toolkit/src/go/lib/tutil"
|
||||||
@@ -235,24 +236,10 @@ func testEmptySystemProfile(t *testing.T, data Data) {
|
|||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
expected := `pt-mongodb-query-digest .+
|
expected := "No queries found in profiler information for database \\\"test\\\""
|
||||||
Host: ` + data.url + `
|
if !strings.Contains(string(output), expected) {
|
||||||
Skipping profiled queries on these collections: \[system\.profile\]
|
t.Errorf("Empty system.profile.\nGot:\n%s\nWant:\n%s\n", string(output), expected)
|
||||||
|
}
|
||||||
|
|
||||||
# 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))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func testAllOperationsTemplate(t *testing.T, data Data) {
|
func testAllOperationsTemplate(t *testing.T, data Data) {
|
||||||
@@ -463,6 +450,9 @@ Skipping profiled queries on these collections: \[system\.profile\]
|
|||||||
|
|
||||||
expected += buf.String()
|
expected += buf.String()
|
||||||
}
|
}
|
||||||
|
fmt.Println("====================================================================================================")
|
||||||
|
pretty.Println(string(output))
|
||||||
|
fmt.Println("====================================================================================================")
|
||||||
|
|
||||||
assertRegexpLines(t, expected, string(output))
|
assertRegexpLines(t, expected, string(output))
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user