Skip to content
This repository was archived by the owner on Jul 6, 2021. It is now read-only.

Commit b321825

Browse files
committed
Merge branch 'dmius-k003-rec-repeat-host-fix' into 'master'
fix: show every host only once in conlusion of K003 See merge request postgres-ai/postgres-checkup!380
2 parents 6ff03a4 + 72745ec commit b321825

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

pghrep/src/checkup/k000/k000.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func K000Process(report K000Report) (checkup.ReportResult, error) {
2626

2727
if result.P1 && len(hosts) > 0 {
2828
result.AppendConclusion(K000_EXCESS_QUERY_TOTAL_TIME, MSG_EXCESS_QUERY_TOTAL_TIME_CONCLUSION, MAX_QUERY_TOTAL_TIME,
29-
fmt.Sprintf(english.PluralWord(len(hosts), MSG_NODE, MSG_NODES), english.WordSeries(hosts, "and")),
29+
fmt.Sprintf(english.PluralWord(len(checkup.GetUniques(hosts)), MSG_NODE, MSG_NODES), english.WordSeries(checkup.GetUniques(hosts), "and")),
3030
MAX_QUERY_TOTAL_TIME, MAX_QUERY_TOTAL_TIME)
3131
result.AppendRecommendation(K000_EXCESS_QUERY_TOTAL_TIME, MSG_EXCESS_QUERY_TOTAL_TIME_RECOMMENDATION, MAX_QUERY_TOTAL_TIME)
3232
}

pghrep/src/checkup/k000/k000_test.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package k000
22

33
import (
44
"fmt"
5+
"strings"
56
"testing"
67

78
checkup ".."
@@ -59,7 +60,7 @@ func TestK000TotalExcess(t *testing.T) {
5960
checkup.PrintResultRecommendations(result)
6061
}
6162

62-
func TestK000TotalExcessNodes(t *testing.T) {
63+
func TestK000HostTwice(t *testing.T) {
6364
fmt.Println(t.Name())
6465

6566
var report K000Report
@@ -69,6 +70,9 @@ func TestK000TotalExcessNodes(t *testing.T) {
6970
"1": K00Query{
7071
RatioTotalTime: 40.0,
7172
},
73+
"2": K00Query{
74+
RatioTotalTime: 34.0,
75+
},
7276
},
7377
}
7478

@@ -82,6 +86,14 @@ func TestK000TotalExcessNodes(t *testing.T) {
8286
t.Fatal()
8387
}
8488

89+
conclusion, err2 := checkup.GetResultItem(result.Conclusions, K000_EXCESS_QUERY_TOTAL_TIME)
90+
if err2 != nil || strings.Contains(conclusion.Message, "`test-host-1`, `test-host-1`") ||
91+
strings.Contains(conclusion.Message, "`test-host-2`, `test-host-2`") ||
92+
strings.Contains(conclusion.Message, "`test-host-2` and `test-host-2`") ||
93+
strings.Contains(conclusion.Message, "`test-host-1` and `test-host-1`") {
94+
t.Fatal("Same host twice in conlusion")
95+
}
96+
8597
checkup.PrintResultConclusions(result)
8698
checkup.PrintResultRecommendations(result)
8799
}

0 commit comments

Comments
 (0)