Browse Source

functional/tester: add "printReport"

Signed-off-by: Gyuho Lee <gyuhox@gmail.com>
Gyuho Lee 7 years ago
parent
commit
054721166f
2 changed files with 25 additions and 1 deletions
  1. 3 0
      functional/tester/cluster_run.go
  2. 22 1
      functional/tester/metrics_report.go

+ 3 - 0
functional/tester/cluster_run.go

@@ -31,6 +31,8 @@ const compactQPS = 50000
 
 // Run starts tester.
 func (clus *Cluster) Run() {
+	defer printReport()
+
 	if err := fileutil.TouchDirAll(clus.Tester.DataDir); err != nil {
 		clus.lg.Panic(
 			"failed to create test data directory",
@@ -123,6 +125,7 @@ func (clus *Cluster) doRound() error {
 	for i, fa := range clus.failures {
 		clus.cs = i
 
+		caseTotal[fa.Desc()]++
 		caseTotalCounter.WithLabelValues(fa.Desc()).Inc()
 
 		caseNow := time.Now()

+ 22 - 1
functional/tester/metrics.go → functional/tester/metrics_report.go

@@ -14,9 +14,16 @@
 
 package tester
 
-import "github.com/prometheus/client_golang/prometheus"
+import (
+	"fmt"
+	"sort"
+
+	"github.com/prometheus/client_golang/prometheus"
+)
 
 var (
+	caseTotal = make(map[string]int)
+
 	caseTotalCounter = prometheus.NewCounterVec(
 		prometheus.CounterOpts{
 			Namespace: "etcd",
@@ -60,3 +67,17 @@ func init() {
 	prometheus.MustRegister(roundTotalCounter)
 	prometheus.MustRegister(roundFailedTotalCounter)
 }
+
+func printReport() {
+	rows := make([]string, 0, len(caseTotal))
+	for k, v := range caseTotal {
+		rows = append(rows, fmt.Sprintf("%s: %d", k, v))
+	}
+	sort.Strings(rows)
+
+	println()
+	for _, row := range rows {
+		fmt.Println(row)
+	}
+	println()
+}