support site perf replication (#4608)
This commit is contained in:
@@ -48,6 +48,7 @@ const (
|
||||
NetPerfTest PerfTestType = 1 << iota
|
||||
DrivePerfTest
|
||||
ObjectPerfTest
|
||||
SiteReplicationPerfTest
|
||||
)
|
||||
|
||||
// Name - returns name of the performance test
|
||||
@@ -59,18 +60,21 @@ func (p PerfTestType) Name() string {
|
||||
return "DrivePerf"
|
||||
case ObjectPerfTest:
|
||||
return "ObjectPerf"
|
||||
case SiteReplicationPerfTest:
|
||||
return "SiteReplication"
|
||||
}
|
||||
return "<unknown>"
|
||||
}
|
||||
|
||||
// PerfTestResult - stores the result of a performance test
|
||||
type PerfTestResult struct {
|
||||
Type PerfTestType `json:"type"`
|
||||
ObjectResult *madmin.SpeedTestResult `json:"object,omitempty"`
|
||||
NetResult *madmin.NetperfResult `json:"network,omitempty"`
|
||||
DriveResult []madmin.DriveSpeedTestResult `json:"drive,omitempty"`
|
||||
Err string `json:"err,omitempty"`
|
||||
Final bool `json:"final,omitempty"`
|
||||
Type PerfTestType `json:"type"`
|
||||
ObjectResult *madmin.SpeedTestResult `json:"object,omitempty"`
|
||||
NetResult *madmin.NetperfResult `json:"network,omitempty"`
|
||||
SiteReplicationResult *madmin.SiteNetPerfResult `json:"siteReplication,omitempty"`
|
||||
DriveResult []madmin.DriveSpeedTestResult `json:"drive,omitempty"`
|
||||
Err string `json:"err,omitempty"`
|
||||
Final bool `json:"final,omitempty"`
|
||||
}
|
||||
|
||||
func initSpeedTestUI() *speedTestUI {
|
||||
@@ -134,6 +138,7 @@ func (m *speedTestUI) View() string {
|
||||
|
||||
ores := m.result.ObjectResult
|
||||
nres := m.result.NetResult
|
||||
sres := m.result.SiteReplicationResult
|
||||
dres := m.result.DriveResult
|
||||
|
||||
trailerIfGreaterThan := func(in string, max int) string {
|
||||
@@ -223,6 +228,57 @@ func (m *speedTestUI) View() string {
|
||||
return data[i][0] < data[j][0]
|
||||
})
|
||||
|
||||
table.AppendBulk(data)
|
||||
table.Render()
|
||||
} else if sres != nil {
|
||||
table.SetHeader([]string{"Endpoint", "RX", "TX", ""})
|
||||
data := make([][]string, 0, len(sres.NodeResults))
|
||||
if len(sres.NodeResults) == 0 {
|
||||
data = append(data, []string{
|
||||
"...",
|
||||
whiteStyle.Render("-- MiB"),
|
||||
whiteStyle.Render("-- MiB"),
|
||||
"",
|
||||
})
|
||||
} else {
|
||||
for _, nodeResult := range sres.NodeResults {
|
||||
if nodeResult.Error != "" {
|
||||
data = append(data, []string{
|
||||
trailerIfGreaterThan(nodeResult.Endpoint, 64),
|
||||
crossTickCell,
|
||||
crossTickCell,
|
||||
"Err: " + nodeResult.Error,
|
||||
})
|
||||
} else {
|
||||
dataItem := []string{}
|
||||
dataError := ""
|
||||
// show endpoint
|
||||
dataItem = append(dataItem, trailerIfGreaterThan(nodeResult.Endpoint, 64))
|
||||
// show RX
|
||||
if uint64(nodeResult.RXTotalDuration.Seconds()) == 0 {
|
||||
dataError += "- RXTotalDuration are zero "
|
||||
dataItem = append(dataItem, crossTickCell)
|
||||
} else {
|
||||
dataItem = append(dataItem, whiteStyle.Render(humanize.IBytes(nodeResult.RX/uint64(nodeResult.RXTotalDuration.Seconds())))+"/s")
|
||||
}
|
||||
// show TX
|
||||
if uint64(nodeResult.TXTotalDuration.Seconds()) == 0 {
|
||||
dataError += "- TXTotalDuration are zero"
|
||||
dataItem = append(dataItem, crossTickCell)
|
||||
} else {
|
||||
dataItem = append(dataItem, whiteStyle.Render(humanize.IBytes(nodeResult.TX/uint64(nodeResult.TXTotalDuration.Seconds())))+"/s")
|
||||
}
|
||||
// show message
|
||||
dataItem = append(dataItem, dataError)
|
||||
data = append(data, dataItem)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sort.Slice(data, func(i, j int) bool {
|
||||
return data[i][0] < data[j][0]
|
||||
})
|
||||
|
||||
table.AppendBulk(data)
|
||||
table.Render()
|
||||
} else if dres != nil {
|
||||
|
||||
@@ -0,0 +1,130 @@
|
||||
// Copyright (c) 2023 MinIO, Inc.
|
||||
//
|
||||
// This file is part of MinIO Object Storage stack
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
tea "github.com/charmbracelet/bubbletea"
|
||||
"github.com/minio/cli"
|
||||
"github.com/minio/madmin-go/v3"
|
||||
"github.com/minio/mc/pkg/probe"
|
||||
)
|
||||
|
||||
func mainAdminSpeedTestSiteReplication(ctx *cli.Context, aliasedURL string, outCh chan<- PerfTestResult) error {
|
||||
client, perr := newAdminClient(aliasedURL)
|
||||
if perr != nil {
|
||||
fatalIf(perr.Trace(aliasedURL), "Unable to initialize admin client.")
|
||||
return nil
|
||||
}
|
||||
|
||||
ctxt, cancel := context.WithCancel(globalContext)
|
||||
defer cancel()
|
||||
|
||||
duration, e := time.ParseDuration(ctx.String("duration"))
|
||||
if e != nil {
|
||||
fatalIf(probe.NewError(e), "Unable to parse duration")
|
||||
return nil
|
||||
}
|
||||
if duration <= 0 {
|
||||
fatalIf(errInvalidArgument(), "duration cannot be 0 or negative")
|
||||
return nil
|
||||
}
|
||||
|
||||
resultCh := make(chan madmin.SiteNetPerfResult)
|
||||
errorCh := make(chan error)
|
||||
go func() {
|
||||
defer close(resultCh)
|
||||
defer close(errorCh)
|
||||
|
||||
result, e := client.SiteReplicationPerf(ctxt, duration)
|
||||
if e != nil {
|
||||
errorCh <- e
|
||||
}
|
||||
resultCh <- result
|
||||
}()
|
||||
|
||||
if globalJSON {
|
||||
select {
|
||||
case e := <-errorCh:
|
||||
printMsg(convertPerfResult(PerfTestResult{
|
||||
Type: SiteReplicationPerfTest,
|
||||
Err: e.Error(),
|
||||
Final: true,
|
||||
}))
|
||||
case result := <-resultCh:
|
||||
printMsg(convertPerfResult(PerfTestResult{
|
||||
Type: SiteReplicationPerfTest,
|
||||
SiteReplicationResult: &result,
|
||||
Final: true,
|
||||
}))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
done := make(chan struct{})
|
||||
|
||||
p := tea.NewProgram(initSpeedTestUI())
|
||||
go func() {
|
||||
if _, e := p.Run(); e != nil {
|
||||
os.Exit(1)
|
||||
}
|
||||
close(done)
|
||||
}()
|
||||
|
||||
go func() {
|
||||
for {
|
||||
select {
|
||||
case e := <-errorCh:
|
||||
r := PerfTestResult{
|
||||
Type: SiteReplicationPerfTest,
|
||||
Err: e.Error(),
|
||||
Final: true,
|
||||
}
|
||||
p.Send(r)
|
||||
if outCh != nil {
|
||||
outCh <- r
|
||||
}
|
||||
return
|
||||
case result := <-resultCh:
|
||||
r := PerfTestResult{
|
||||
Type: SiteReplicationPerfTest,
|
||||
SiteReplicationResult: &result,
|
||||
Final: true,
|
||||
}
|
||||
p.Send(r)
|
||||
if outCh != nil {
|
||||
outCh <- r
|
||||
}
|
||||
return
|
||||
default:
|
||||
p.Send(PerfTestResult{
|
||||
Type: SiteReplicationPerfTest,
|
||||
SiteReplicationResult: &madmin.SiteNetPerfResult{},
|
||||
})
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
<-done
|
||||
|
||||
return nil
|
||||
}
|
||||
+56
-5
@@ -23,6 +23,7 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
humanize "github.com/dustin/go-humanize"
|
||||
"github.com/minio/cli"
|
||||
@@ -112,10 +113,11 @@ EXAMPLES:
|
||||
|
||||
// PerfTestOutput - stores the final output of performance test(s)
|
||||
type PerfTestOutput struct {
|
||||
ObjectResults *ObjTestResults `json:"object,omitempty"`
|
||||
NetResults *NetTestResults `json:"network,omitempty"`
|
||||
DriveResults *DriveTestResults `json:"drive,omitempty"`
|
||||
Error string `json:"error,omitempty"`
|
||||
ObjectResults *ObjTestResults `json:"object,omitempty"`
|
||||
NetResults *NetTestResults `json:"network,omitempty"`
|
||||
SiteReplicationResults *SiteReplicationTestResults `json:"siteReplication,omitempty"`
|
||||
DriveResults *DriveTestResults `json:"drive,omitempty"`
|
||||
Error string `json:"error,omitempty"`
|
||||
}
|
||||
|
||||
// DriveTestResult - result of the drive performance test on a given endpoint
|
||||
@@ -194,6 +196,27 @@ type NetTestResults struct {
|
||||
Results []NetTestResult `json:"servers"`
|
||||
}
|
||||
|
||||
// SiteNetStats - status for siteNet
|
||||
type SiteNetStats struct {
|
||||
TX uint64 `json:"tx"` // transfer rate in bytes
|
||||
TXTotalDuration time.Duration `json:"txTotalDuration"`
|
||||
RX uint64 `json:"rx"` // received rate in bytes
|
||||
RXTotalDuration time.Duration `json:"rxTotalDuration"`
|
||||
TotalConn uint64 `json:"totalConn"`
|
||||
}
|
||||
|
||||
// SiteReplicationTestNodeResult - result of the network performance test for site-replication
|
||||
type SiteReplicationTestNodeResult struct {
|
||||
Endpoint string `json:"endpoint"`
|
||||
Perf SiteNetStats `json:"perf"`
|
||||
Error string `json:"error,omitempty"`
|
||||
}
|
||||
|
||||
// SiteReplicationTestResults - result of the network performance test across all site-replication
|
||||
type SiteReplicationTestResults struct {
|
||||
Results []SiteReplicationTestNodeResult `json:"servers"`
|
||||
}
|
||||
|
||||
func objectTestVerboseResult(result *madmin.SpeedTestResult) (msg string) {
|
||||
msg += "PUT:\n"
|
||||
for _, node := range result.PUTStats.Servers {
|
||||
@@ -247,7 +270,7 @@ func mainSupportPerf(ctx *cli.Context) error {
|
||||
switch len(args) {
|
||||
case 1:
|
||||
// cannot use alias by the name 'drive' or 'net'
|
||||
if args[0] == "drive" || args[0] == "net" || args[0] == "object" {
|
||||
if args[0] == "drive" || args[0] == "net" || args[0] == "object" || args[0] == "site-replication" {
|
||||
showCommandHelpAndExit(ctx, 1)
|
||||
}
|
||||
aliasedURL = args[0]
|
||||
@@ -287,6 +310,30 @@ func convertDriveTestResults(driveResults []madmin.DriveSpeedTestResult) *DriveT
|
||||
return &r
|
||||
}
|
||||
|
||||
func convertSiteReplicationTestResults(netResults *madmin.SiteNetPerfResult) *SiteReplicationTestResults {
|
||||
if netResults == nil {
|
||||
return nil
|
||||
}
|
||||
results := []SiteReplicationTestNodeResult{}
|
||||
for _, nr := range netResults.NodeResults {
|
||||
results = append(results, SiteReplicationTestNodeResult{
|
||||
Endpoint: nr.Endpoint,
|
||||
Error: nr.Error,
|
||||
Perf: SiteNetStats{
|
||||
TX: nr.TX,
|
||||
TXTotalDuration: nr.TXTotalDuration,
|
||||
RX: nr.RX,
|
||||
RXTotalDuration: nr.RXTotalDuration,
|
||||
TotalConn: nr.TotalConn,
|
||||
},
|
||||
})
|
||||
}
|
||||
r := SiteReplicationTestResults{
|
||||
Results: results,
|
||||
}
|
||||
return &r
|
||||
}
|
||||
|
||||
func convertNetTestResults(netResults *madmin.NetperfResult) *NetTestResults {
|
||||
if netResults == nil {
|
||||
return nil
|
||||
@@ -369,6 +416,8 @@ func updatePerfOutput(r PerfTestResult, out *PerfTestOutput) {
|
||||
out.ObjectResults = convertObjTestResults(r.ObjectResult)
|
||||
case NetPerfTest:
|
||||
out.NetResults = convertNetTestResults(r.NetResult)
|
||||
case SiteReplicationPerfTest:
|
||||
out.SiteReplicationResults = convertSiteReplicationTestResults(r.SiteReplicationResult)
|
||||
default:
|
||||
fatalIf(errDummy().Trace(), fmt.Sprintf("Invalid test type %d", r.Type))
|
||||
}
|
||||
@@ -458,6 +507,8 @@ func runPerfTests(ctx *cli.Context, aliasedURL string, perfType string) []PerfTe
|
||||
mainAdminSpeedTestObject(ctx, aliasedURL, resultCh)
|
||||
case "net":
|
||||
mainAdminSpeedTestNetperf(ctx, aliasedURL, resultCh)
|
||||
case "site-replication":
|
||||
mainAdminSpeedTestSiteReplication(ctx, aliasedURL, resultCh)
|
||||
default:
|
||||
showCommandHelpAndExit(ctx, 1) // last argument is exit code
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ require (
|
||||
github.com/gdamore/tcell/v2 v2.6.0
|
||||
github.com/golang-jwt/jwt/v4 v4.5.0
|
||||
github.com/juju/ratelimit v1.0.2
|
||||
github.com/minio/madmin-go/v3 v3.0.4
|
||||
github.com/minio/madmin-go/v3 v3.0.5
|
||||
github.com/muesli/reflow v0.3.0
|
||||
github.com/navidys/tvxwidgets v0.3.0
|
||||
github.com/olekukonko/tablewriter v0.0.5
|
||||
|
||||
@@ -146,8 +146,8 @@ github.com/minio/colorjson v1.0.5 h1:P//d521blE5cKDF5YvsHcpqb9TE8IwCdliSv1naPsgk
|
||||
github.com/minio/colorjson v1.0.5/go.mod h1:Oq6oB83q+sL08u9wx68+91ELf0nV5G4c6l9pQcH5ElI=
|
||||
github.com/minio/filepath v1.0.0 h1:fvkJu1+6X+ECRA6G3+JJETj4QeAYO9sV43I79H8ubDY=
|
||||
github.com/minio/filepath v1.0.0/go.mod h1:/nRZA2ldl5z6jT9/KQuvZcQlxZIMQoFFQPvEXx9T/Bw=
|
||||
github.com/minio/madmin-go/v3 v3.0.4 h1:nINToRlCFRKKINGIvn+RUkYgnQregTEi6xVO6XwSUtA=
|
||||
github.com/minio/madmin-go/v3 v3.0.4/go.mod h1:lPrMoc1aeiIWmmrxBthkDqzMPQwC/Lu9ByuyM2wenJk=
|
||||
github.com/minio/madmin-go/v3 v3.0.5 h1:ynWTsnszHnQVJWRL2OE4ysCvCNG0uHgdTvJpdLazf9c=
|
||||
github.com/minio/madmin-go/v3 v3.0.5/go.mod h1:lPrMoc1aeiIWmmrxBthkDqzMPQwC/Lu9ByuyM2wenJk=
|
||||
github.com/minio/md5-simd v1.1.2 h1:Gdi1DZK69+ZVMoNHRXJyNcxrMA4dSxoYHZSQbirFg34=
|
||||
github.com/minio/md5-simd v1.1.2/go.mod h1:MzdKDxYpY2BT9XQFocsiZf/NKVtR7nkE4RoEpN+20RM=
|
||||
github.com/minio/minio-go/v7 v7.0.57 h1:xsFiOiWjpC1XAGbFEUOzj1/gMXGz7ljfxifwcb/5YXU=
|
||||
|
||||
Reference in New Issue
Block a user