This commit will make `mc support perf <alias>` to execute all performance tests, networking, drive and object speed tests. perf will only have --duration and --verbose flags. The user can still test with 'drive', 'object', and 'net' but they will be hidden for now along with their flags.
178 lines
4.6 KiB
Go
178 lines
4.6 KiB
Go
// Copyright (c) 2015-2021 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 (
|
|
"fmt"
|
|
|
|
humanize "github.com/dustin/go-humanize"
|
|
"github.com/minio/cli"
|
|
json "github.com/minio/colorjson"
|
|
"github.com/minio/mc/pkg/probe"
|
|
)
|
|
|
|
var supportPerfFlags = []cli.Flag{
|
|
cli.StringFlag{
|
|
Name: "duration",
|
|
Usage: "duration the entire perf tests are run",
|
|
Value: "10s",
|
|
},
|
|
cli.BoolFlag{
|
|
Name: "verbose, v",
|
|
Usage: "display per-server stats",
|
|
},
|
|
cli.StringFlag{
|
|
Name: "size",
|
|
Usage: "size of the object used for uploads/downloads",
|
|
Value: "64MiB",
|
|
Hidden: true,
|
|
},
|
|
cli.IntFlag{
|
|
Name: "concurrent",
|
|
Usage: "number of concurrent requests per server",
|
|
Value: 32,
|
|
Hidden: true,
|
|
},
|
|
cli.StringFlag{
|
|
Name: "bucket",
|
|
Usage: "provide a custom bucket name to use (NOTE: bucket must be created prior)",
|
|
Hidden: true, // Hidden for now.
|
|
},
|
|
// Drive test specific flags.
|
|
cli.StringFlag{
|
|
Name: "filesize",
|
|
Usage: "total amount of data read/written to each drive",
|
|
Value: "1GiB",
|
|
Hidden: true,
|
|
},
|
|
cli.StringFlag{
|
|
Name: "blocksize",
|
|
Usage: "read/write block size",
|
|
Value: "4MiB",
|
|
Hidden: true,
|
|
},
|
|
cli.BoolFlag{
|
|
Name: "serial",
|
|
Usage: "run tests on drive(s) one-by-one",
|
|
Hidden: true,
|
|
},
|
|
}
|
|
|
|
var supportPerfCmd = cli.Command{
|
|
Name: "perf",
|
|
Usage: "analyze object, network and drive performance",
|
|
Action: mainSupportPerf,
|
|
OnUsageError: onUsageError,
|
|
Before: setGlobalsFromContext,
|
|
Flags: append(supportPerfFlags, globalFlags...),
|
|
HideHelpCommand: true,
|
|
CustomHelpTemplate: `NAME:
|
|
{{.HelpName}} - {{.Usage}}
|
|
|
|
USAGE:
|
|
{{.HelpName}} [COMMAND] [FLAGS] TARGET
|
|
|
|
FLAGS:
|
|
{{range .VisibleFlags}}{{.}}
|
|
{{end}}
|
|
|
|
EXAMPLES:
|
|
1. Run performance tests on 'myminio' cluster: networking, drive speed and:
|
|
{{.Prompt}} {{.HelpName}} myminio/
|
|
|
|
`,
|
|
}
|
|
|
|
func (s speedTestResult) StringVerbose() (msg string) {
|
|
result := s.result
|
|
if globalPerfTestVerbose {
|
|
msg += "\n\n"
|
|
msg += "PUT:\n"
|
|
for _, node := range result.PUTStats.Servers {
|
|
msg += fmt.Sprintf(" * %s: %s/s %s objs/s", node.Endpoint, humanize.IBytes(node.ThroughputPerSec), humanize.Comma(int64(node.ObjectsPerSec)))
|
|
if node.Err != "" {
|
|
msg += " Err: " + node.Err
|
|
}
|
|
msg += "\n"
|
|
}
|
|
|
|
msg += "GET:\n"
|
|
for _, node := range result.GETStats.Servers {
|
|
msg += fmt.Sprintf(" * %s: %s/s %s objs/s", node.Endpoint, humanize.IBytes(node.ThroughputPerSec), humanize.Comma(int64(node.ObjectsPerSec)))
|
|
if node.Err != "" {
|
|
msg += " Err: " + node.Err
|
|
}
|
|
msg += "\n"
|
|
}
|
|
|
|
}
|
|
return msg
|
|
}
|
|
|
|
func (s speedTestResult) String() (msg string) {
|
|
result := s.result
|
|
msg += fmt.Sprintf("MinIO %s, %d servers, %d drives, %s objects, %d threads",
|
|
result.Version, result.Servers, result.Disks,
|
|
humanize.IBytes(uint64(result.Size)), result.Concurrent)
|
|
|
|
return msg
|
|
}
|
|
|
|
func (s speedTestResult) JSON() string {
|
|
JSONBytes, e := json.MarshalIndent(s.result, "", " ")
|
|
fatalIf(probe.NewError(e), "Unable to marshal into JSON.")
|
|
return string(JSONBytes)
|
|
}
|
|
|
|
var globalPerfTestVerbose bool
|
|
|
|
func mainSupportPerf(ctx *cli.Context) error {
|
|
args := ctx.Args()
|
|
|
|
// the alias parameter from cli
|
|
aliasedURL := ""
|
|
switch len(args) {
|
|
case 1:
|
|
// cannot use alias by the name 'drive' or 'net'
|
|
if args[0] == "drive" || args[0] == "net" || args[0] == "object" {
|
|
cli.ShowCommandHelpAndExit(ctx, "perf", 1)
|
|
}
|
|
aliasedURL = args[0]
|
|
|
|
mainAdminSpeedTestNetperf(ctx, aliasedURL)
|
|
mainAdminSpeedTestDrive(ctx, aliasedURL)
|
|
mainAdminSpeedTestObject(ctx, aliasedURL)
|
|
case 2:
|
|
aliasedURL := args[1]
|
|
switch args[0] {
|
|
case "drive":
|
|
return mainAdminSpeedTestDrive(ctx, aliasedURL)
|
|
case "object":
|
|
return mainAdminSpeedTestObject(ctx, aliasedURL)
|
|
case "net":
|
|
return mainAdminSpeedTestNetperf(ctx, aliasedURL)
|
|
default:
|
|
cli.ShowCommandHelpAndExit(ctx, "perf", 1) // last argument is exit code
|
|
}
|
|
default:
|
|
cli.ShowCommandHelpAndExit(ctx, "perf", 1) // last argument is exit code
|
|
}
|
|
|
|
return nil
|
|
}
|