From 36a6493cc402669a8358d7944fa160906efab83d Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Fri, 27 Sep 2024 03:30:38 -0700 Subject: [PATCH] update all help, cleanup some typos etc --- .gitignore | 3 ++ .goreleaser.yml | 3 +- README.md | 11 ++++++ cmd/cli/get.go | 62 --------------------------------- cmd/{cli => hperf}/bandwidth.go | 54 +++++++++++++--------------- cmd/{cli => hperf}/delete.go | 37 +++++++++----------- cmd/{cli => hperf}/latency.go | 37 +++++++++----------- cmd/{cli => hperf}/list.go | 36 +++++++++---------- cmd/{cli => hperf}/listen.go | 37 +++++++++----------- cmd/{cli => hperf}/main.go | 45 ++++++++++++------------ cmd/{cli => hperf}/requests.go | 42 ++++++++++------------ cmd/{cli => hperf}/server.go | 44 +++++++++++------------ cmd/{cli => hperf}/stop.go | 35 +++++++++---------- server/server.go | 11 +++--- shared/shared.go | 4 +++ 15 files changed, 191 insertions(+), 270 deletions(-) delete mode 100644 cmd/cli/get.go rename cmd/{cli => hperf}/bandwidth.go (55%) rename cmd/{cli => hperf}/delete.go (66%) rename cmd/{cli => hperf}/latency.go (66%) rename cmd/{cli => hperf}/list.go (74%) rename cmd/{cli => hperf}/listen.go (67%) rename cmd/{cli => hperf}/main.go (85%) rename cmd/{cli => hperf}/requests.go (61%) rename cmd/{cli => hperf}/server.go (63%) rename cmd/{cli => hperf}/stop.go (66%) diff --git a/.gitignore b/.gitignore index e9b9e73..64c5adc 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,4 @@ ./hperf +dist +hperf +cmd/hperf/hperf diff --git a/.goreleaser.yml b/.goreleaser.yml index f63789b..d1d07b8 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -32,8 +32,7 @@ builds: - --tags=kqueue ldflags: - "-s -w -X main.version={{.Version}}" - dir: . - main: ./cmd/cli + main: ./cmd/hperf archives: - diff --git a/README.md b/README.md index ba01119..3045f82 100644 --- a/README.md +++ b/README.md @@ -11,19 +11,30 @@ a long period of time. ### Download [Download Binary Releases](https://github.com/minio/hperf/releases) for various platforms. +You can also install via source + +``` +go install github.com/minio/hperf/cmd/hperf@latest +``` + ### Server 1. Download hperf and place it in a directory of your choosing - This can be automated with deployment tools, hperf is just a single binary + 2. Run hperf help to see a list of available server commands flags and example + ```bash $ ./hperf server --help ``` + 3. Run the server with your preferred settings ### Client 1. Download hperf + 2. Run hperf help to see available commands, flags and examples - The `--hosts` and `--id` flags are especially important to understand + ```bash $ ./hperf --help $ ./hperf [command] --help diff --git a/cmd/cli/get.go b/cmd/cli/get.go deleted file mode 100644 index bb31314..0000000 --- a/cmd/cli/get.go +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright (c) 2015-2024 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 . - -package main - -import ( - "github.com/minio/cli" - "github.com/minio/hperf/client" -) - -var getTestsCMD = cli.Command{ - Name: "get", - HelpName: "get", - Prompt: "hperf", - Usage: "Get and print a test from the selected hosts", - Action: runGetCMD, - Flags: []cli.Flag{ - dnsServerFlag, - hostsFlag, - portFlag, - testIDFlag, - }, - CustomHelpTemplate: ` - NAME: {{.HelpName}} - - {{.Usage}} - - FLAGS: - {{range .VisibleFlags}}{{.}} - {{end}} - EXAMPLES: - - 01. Get test by ID on hosts .1 and .2 - - {{.Prompt}} {{.HelpName}} --hosts 10.10.10.1,10.10.10.2 --id my_test_id - -`, -} - -func runGetCMD(ctx *cli.Context) error { - config, err := parseConfig(ctx) - if err != nil { - return err - } - - client.GetTest(GlobalContext, *config) - return nil -} diff --git a/cmd/cli/bandwidth.go b/cmd/hperf/bandwidth.go similarity index 55% rename from cmd/cli/bandwidth.go rename to cmd/hperf/bandwidth.go index 091a52a..ab79260 100644 --- a/cmd/cli/bandwidth.go +++ b/cmd/hperf/bandwidth.go @@ -24,53 +24,49 @@ import ( ) var bandwidthCMD = cli.Command{ - Name: "bandwidth", - HelpName: "bandwidth", - Prompt: "hperf", - Usage: "A test which focuses on measuring bandwidth, It will open up a single socket(x --concurrency) and write as much data as possible for the configured --duration", - Action: runBandwidthCMD, + Name: "bandwidth", + Usage: "start a test to measure bandwidth, open --concurrency number of sockets, write data upto --duration", + Action: runBandwidth, Flags: []cli.Flag{ - dnsServerFlag, hostsFlag, portFlag, - testIDFlag, - insecureFlag, concurrencyFlag, durationFlag, + testIDFlag, bufferSizeFlag, payloadSizeFlag, + insecureFlag, restartOnErrorFlag, + dnsServerFlag, saveTestFlag, }, - CustomHelpTemplate: ` - NAME: {{.HelpName}} - - {{.Usage}} - - FLAGS: - {{range .VisibleFlags}}{{.}} - {{end}} - EXAMPLES: - - 01. Run a basic test - - {{.Prompt}} {{.HelpName}} --hosts 10.10.10.1,10.10.10.2 + CustomHelpTemplate: `NAME: + {{.HelpName}} - {{.Usage}} - 02. Run a test with custom concurrency - - Matching concurrency with your thread count can often lead to improved performance - - Sometimes it's even better to run concurrency at thread_count/2 +USAGE: + {{.HelpName}} [FLAGS] - {{.Prompt}} {{.HelpName}} --hosts 10.10.10.1,10.10.10.2 --concurrency 24 +NOTE: + Matching concurrency with your thread count can often lead to + improved performance, it is even better to run concurrency at + 50% of the GOMAXPROCS. - 03. Run a test with custom buffer sizes - - This can be handy when testing MTU and other parameters for optimizations +FLAGS: + {{range .VisibleFlags}}{{.}} + {{end}} +EXAMPLES: + 1. Run a basic test: + {{.Prompt}} {{.HelpName}} --hosts 10.10.10.1,10.10.10.2 - {{.Prompt}} {{.HelpName}} --hosts 10.10.10.1,10.10.10.2 --bufferSize 8192 --payloadSize 8192 + 2. Run a test with custom concurrency: + {{.Prompt}} {{.HelpName}} --hosts 10.10.10.1,10.10.10.2 --concurrency 24 + 3. Run a test with custom buffer sizes, for MTU specific testing: + {{.Prompt}} {{.HelpName}} --hosts 10.10.10.1,10.10.10.2 --bufferSize 9000 --payloadSize 9000 `, } -func runBandwidthCMD(ctx *cli.Context) error { +func runBandwidth(ctx *cli.Context) error { config, err := parseConfig(ctx) if err != nil { return err diff --git a/cmd/cli/delete.go b/cmd/hperf/delete.go similarity index 66% rename from cmd/cli/delete.go rename to cmd/hperf/delete.go index 2672cf8..d10a85e 100644 --- a/cmd/cli/delete.go +++ b/cmd/hperf/delete.go @@ -23,39 +23,34 @@ import ( ) var deleteCMD = cli.Command{ - Name: "delete", - HelpName: "delete", - Prompt: "hperf", - Usage: "Deletes one or all tests on the selected hosts", - Action: runDeleteCMD, + Name: "delete", + Usage: "deletes one or all tests on the selected hosts", + Action: runDelete, Flags: []cli.Flag{ dnsServerFlag, hostsFlag, portFlag, testIDFlag, }, - CustomHelpTemplate: ` - NAME: {{.HelpName}} + CustomHelpTemplate: `NAME: + {{.HelpName}} - {{.Usage}} - {{.Usage}} +USAGE: + {{.HelpName}} [FLAGS] - FLAGS: - {{range .VisibleFlags}}{{.}} - {{end}} - EXAMPLES: - - 01. Delete all tests on hosts .1 and .2 - - {{.Prompt}} {{.HelpName}} --hosts 10.10.10.1,10.10.10.2 - - 02. Delete test by ID on hosts .1 and .2 - - {{.Prompt}} {{.HelpName}} --hosts 10.10.10.1,10.10.10.2 --id my_test_id +FLAGS: + {{range .VisibleFlags}}{{.}} + {{end}} +EXAMPLES: + 1. Delete all tests on hosts '10.10.10.1' and '10.10.10.2': + {{.Prompt}} {{.HelpName}} --hosts 10.10.10.1,10.10.10.2 + 2. Delete test by ID on hosts '10.10.10.1' and '10.10.10.2': + {{.Prompt}} {{.HelpName}} --hosts 10.10.10.1,10.10.10.2 --id my_test_id `, } -func runDeleteCMD(ctx *cli.Context) error { +func runDelete(ctx *cli.Context) error { config, err := parseConfig(ctx) if err != nil { return err diff --git a/cmd/cli/latency.go b/cmd/hperf/latency.go similarity index 66% rename from cmd/cli/latency.go rename to cmd/hperf/latency.go index 4330106..a503e60 100644 --- a/cmd/cli/latency.go +++ b/cmd/hperf/latency.go @@ -24,11 +24,9 @@ import ( ) var latencyCMD = cli.Command{ - Name: "latency", - HelpName: "latency", - Prompt: "hperf", - Usage: "A test to measure latency at the application level, it will send 1*Request*(--concurrency) waiting for (--delay) between requests, until the end of (--duration)", - Action: runLatencyCMD, + Name: "latency", + Usage: "start a test to measure latency at the application level", + Action: runLatency, Flags: []cli.Flag{ hostsFlag, portFlag, @@ -43,28 +41,25 @@ var latencyCMD = cli.Command{ saveTestFlag, dnsServerFlag, }, - CustomHelpTemplate: ` - NAME: {{.HelpName}} - - {{.Usage}} + CustomHelpTemplate: `NAME: + {{.HelpName}} - {{.Usage}} - FLAGS: - {{range .VisibleFlags}}{{.}} - {{end}} - EXAMPLES: +USAGE: + {{.HelpName}} [FLAGS] - 01. Run a basic test - - {{.Prompt}} {{.HelpName}} --hosts 10.10.10.1,10.10.10.2 - - 02. Run a slow moving test to probe latency - - {{.Prompt}} {{.HelpName}} --hosts 10.10.10.1,10.10.10.2 --delay 100 +FLAGS: + {{range .VisibleFlags}}{{.}} + {{end}} +EXAMPLES: + 1. Run a basic test: + {{.Prompt}} {{.HelpName}} --hosts 10.10.10.1,10.10.10.2 + 2. Run a slow moving test to probe latency: + {{.Prompt}} {{.HelpName}} --hosts 10.10.10.1,10.10.10.2 --delay 100 `, } -func runLatencyCMD(ctx *cli.Context) error { +func runLatency(ctx *cli.Context) error { config, err := parseConfig(ctx) if err != nil { return err diff --git a/cmd/cli/list.go b/cmd/hperf/list.go similarity index 74% rename from cmd/cli/list.go rename to cmd/hperf/list.go index e9d9a0d..6d497ae 100644 --- a/cmd/cli/list.go +++ b/cmd/hperf/list.go @@ -23,35 +23,31 @@ import ( ) var listTestsCMD = cli.Command{ - Name: "list", - HelpName: "list", - Prompt: "hperf", - Usage: "List all tests on the selected hosts", - Action: runListCMD, + Name: "list", + Usage: "list all tests on the selected hosts", + Action: runList, Flags: []cli.Flag{ dnsServerFlag, hostsFlag, portFlag, testIDFlag, }, - CustomHelpTemplate: ` - NAME: {{.HelpName}} - - {{.Usage}} - - FLAGS: - {{range .VisibleFlags}}{{.}} - {{end}} - EXAMPLES: - - 01. List all test on the server - - {{.Prompt}} {{.HelpName}} --hosts 1.1.1.1 - + CustomHelpTemplate: `NAME: + {{.HelpName}} - {{.Usage}} + +USAGE: + {{.HelpName}} [FLAGS] + +FLAGS: + {{range .VisibleFlags}}{{.}} + {{end}} +EXAMPLES: + 1. List all test on the '10.10.10.1': + {{.Prompt}} {{.HelpName}} --hosts 10.10.10.1 `, } -func runListCMD(ctx *cli.Context) error { +func runList(ctx *cli.Context) error { config, err := parseConfig(ctx) if err != nil { return err diff --git a/cmd/cli/listen.go b/cmd/hperf/listen.go similarity index 67% rename from cmd/cli/listen.go rename to cmd/hperf/listen.go index f6d15c5..859e92e 100644 --- a/cmd/cli/listen.go +++ b/cmd/hperf/listen.go @@ -23,39 +23,34 @@ import ( ) var listenCMD = cli.Command{ - Name: "listen", - HelpName: "listen", - Prompt: "hperf", - Usage: "Receive live data from one or all active tests on the selected hosts", - Action: runListenCMD, + Name: "listen", + Usage: "receive live data from one or all active tests on the selected hosts", + Action: runListen, Flags: []cli.Flag{ dnsServerFlag, hostsFlag, portFlag, testIDFlag, }, - CustomHelpTemplate: ` - NAME: {{.HelpName}} + CustomHelpTemplate: `NAME: + {{.HelpName}} - {{.Usage}} - {{.Usage}} +USAGE: + {{.HelpName}} [FLAGS] - FLAGS: - {{range .VisibleFlags}}{{.}} - {{end}} - EXAMPLES: - - 01. Listen to a specific test - - {{.Prompt}} {{.HelpName}} --hosts 10.10.10.1,10.10.10.2 --id my_test_id - - 02. Listen to all active tests - - {{.Prompt}} {{.HelpName}} --hosts 10.10.10.1,10.10.10.2 +FLAGS: + {{range .VisibleFlags}}{{.}} + {{end}} +EXAMPLES: + 1. Listen to a specific test on specific hosts: + {{.Prompt}} {{.HelpName}} --hosts 10.10.10.1,10.10.10.2 --id my_test_id + 2. Listen to all active tests: + {{.Prompt}} {{.HelpName}} --hosts 10.10.10.1,10.10.10.2 `, } -func runListenCMD(ctx *cli.Context) error { +func runListen(ctx *cli.Context) error { config, err := parseConfig(ctx) if err != nil { return err diff --git a/cmd/cli/main.go b/cmd/hperf/main.go similarity index 85% rename from cmd/cli/main.go rename to cmd/hperf/main.go index 2b4f3df..3f37875 100644 --- a/cmd/cli/main.go +++ b/cmd/hperf/main.go @@ -79,72 +79,72 @@ var ( hostsFlag = cli.StringFlag{ Name: "hosts", EnvVar: "HPERF_HOSTS", - Usage: "Hosts that will used for the current command", + Usage: "list of hosts for the current command", } portFlag = cli.StringFlag{ Name: "port", Value: "9010", EnvVar: "HPERF_PORT", - Usage: "Port used to communicate with hosts", + Usage: "port used to communicate with hosts", } insecureFlag = cli.BoolTFlag{ Name: "insecure", EnvVar: "HPERF_INSECURE", - Usage: "Use http instead of https", + Usage: "use http instead of https", } debugFlag = cli.BoolFlag{ Name: "debug", EnvVar: "HPERF_DEBUG", - Usage: "Enable debug output in the client and on the servers for the particular command", + Usage: "enable debug output logs for client and server for a command", } concurrencyFlag = cli.IntFlag{ Name: "concurrency", EnvVar: "HPERF_CONCURRENCY", - Value: runtime.NumCPU() * 2, - Usage: "This flags controls how many concurrent requests we run between each host, the default is (number of cpus)x2", + Value: runtime.GOMAXPROCS(0) * 2, + Usage: "this flags controls how many concurrent requests to run per host", } delayFlag = cli.IntFlag{ - Name: "requestDelay", + Name: "request-delay", Value: 0, EnvVar: "HPERF_REQUEST_DELAY", - Usage: "Creates a delay (in Milliseconds) before sending http requests from host to host", + Usage: "adds a delay (in milliseconds) before sending http requests from host to host", } durationFlag = cli.IntFlag{ Name: "duration", Value: 30, EnvVar: "HPERF_DURATION", - Usage: "Controls how long the test will be ran", + Usage: "controls how long a test will run", } bufferSizeFlag = cli.IntFlag{ - Name: "bufferSize", + Name: "buffer-size", Value: 32000, EnvVar: "HPERF_BUFFER_SIZE", - Usage: "Buffer size in Bytes", + Usage: "buffer size in bytes", } payloadSizeFlag = cli.IntFlag{ - Name: "payloadSize", + Name: "payload-size", Value: 1000000, EnvVar: "HPERF_PAYLOAD_SIZE", - Usage: "Payload size in Bytes", + Usage: "payload size in bytes", } restartOnErrorFlag = cli.BoolTFlag{ - Name: "restartOnError", + Name: "restart-on-error", EnvVar: "HPERF_RESTART_ON_ERROR", - Usage: "restart tests/clients if an error occures", + Usage: "restart tests/clients upon error", } testIDFlag = cli.StringFlag{ Name: "id", - Usage: "The id is a tag you can use to label tests which run on the servers", + Usage: "specify custom ID per test", } saveTestFlag = cli.BoolTFlag{ Name: "save", EnvVar: "HPERF_SAVE", - Usage: "Save tests results on the server for querying later", + Usage: "save tests results on the server for retrieve later", } dnsServerFlag = cli.StringFlag{ - Name: "dnsServer", + Name: "dns-server", EnvVar: "HPERF_DNS_SERVER", - Usage: "Hperf will use this DNS server to resolve hosts which are not in an IP format", + Usage: "use a custom DNS server to resolve hosts", } ) @@ -154,14 +154,12 @@ var ( } Commands = []cli.Command{ serverCMD, - bandwidthCMD, requestsCMD, latencyCMD, listenCMD, - listTestsCMD, - getTestsCMD, + statTestsCMD, stopCMD, deleteCMD, } @@ -186,10 +184,11 @@ func CreateApp() *cli.App { } app.Name = "hperf" - app.HideHelpCommand = false + app.HideHelpCommand = true app.Usage = "MinIO network performance test utility for infrastructure at scale" app.Commands = Commands app.Author = "MinIO, Inc." + app.Copyright = "(c) 2021-2024 MinIO, Inc." app.Version = VERSION app.Flags = baseFlags app.CustomAppHelpTemplate = mcHelpTemplate diff --git a/cmd/cli/requests.go b/cmd/hperf/requests.go similarity index 61% rename from cmd/cli/requests.go rename to cmd/hperf/requests.go index 135947b..5b12048 100644 --- a/cmd/cli/requests.go +++ b/cmd/hperf/requests.go @@ -24,11 +24,9 @@ import ( ) var requestsCMD = cli.Command{ - Name: "requests", - HelpName: "requests", - Prompt: "hperf", - Usage: "A test to measure http/s throughput at the application level, it will send 1*Request*(--concurrency) containing (--payload) waiting for (--delay) between requests, until the end of (--duration)", - Action: runRequestsCMD, + Name: "requests", + Usage: "start a test to measure http(s) throughput at the application level", + Action: runRequests, Flags: []cli.Flag{ hostsFlag, portFlag, @@ -43,32 +41,28 @@ var requestsCMD = cli.Command{ saveTestFlag, dnsServerFlag, }, - CustomHelpTemplate: ` - NAME: {{.HelpName}} - - {{.Usage}} + CustomHelpTemplate: `NAME: + {{.HelpName}} - {{.Usage}} - FLAGS: - {{range .VisibleFlags}}{{.}} - {{end}} - EXAMPLES: +USAGE: + {{.HelpName}} [FLAGS] - 01. Run a basic test +FLAGS: + {{range .VisibleFlags}}{{.}} + {{end}} +EXAMPLES: + 1. Run a basic test: + {{.Prompt}} {{.HelpName}} --hosts 10.10.10.1,10.10.10.2 - {{.Prompt}} {{.HelpName}} --hosts 10.10.10.1,10.10.10.2 - - 02. Run a test with reduced throughput - - {{.Prompt}} {{.HelpName}} --hosts 10.10.10.1,10.10.10.2 --delay 100 - - 03. Run a test with reduced concurrency and throughput - - {{.Prompt}} {{.HelpName}} --hosts 10.10.10.1,10.10.10.2 --delay 100 --concurrency 1 + 2. Run a test with reduced throughput: + {{.Prompt}} {{.HelpName}} --hosts 10.10.10.1,10.10.10.2 --delay 100 + 3. Run a test with reduced concurrency and throughput: + {{.Prompt}} {{.HelpName}} --hosts 10.10.10.1,10.10.10.2 --delay 100 --concurrency 1 `, } -func runRequestsCMD(ctx *cli.Context) error { +func runRequests(ctx *cli.Context) error { config, err := parseConfig(ctx) if err != nil { return err diff --git a/cmd/cli/server.go b/cmd/hperf/server.go similarity index 63% rename from cmd/cli/server.go rename to cmd/hperf/server.go index b7a3d09..c7c0124 100644 --- a/cmd/cli/server.go +++ b/cmd/hperf/server.go @@ -35,43 +35,39 @@ var ( Name: "address", EnvVar: "HPERF_ADDRESS", Value: "0.0.0.0:9010", - Usage: "Hperf will bind to the specified address", + Usage: "bind to the specified address", } storagePathFlag = cli.StringFlag{ Name: "storage-path", EnvVar: "HPERF_STORAGE_PATH", Value: getPWD(), - Usage: "All test results will be saved in this directory", + Usage: "all test results will be saved in this directory", } serverCMD = cli.Command{ - Name: "server", - HelpName: "server", - Prompt: "hperf", - Usage: "Run hperf server, you can interact with this server using the client", - Action: runServer, - Flags: []cli.Flag{addressFlag, storagePathFlag, debugFlag}, - CustomHelpTemplate: ` - NAME: {{.HelpName}} - {{.Usage}} + Name: "server", + Usage: "start an interactive server", + Action: runServer, + Flags: []cli.Flag{addressFlag, storagePathFlag, debugFlag}, + CustomHelpTemplate: `NAME: + {{.HelpName}} - {{.Usage}} - FLAGS: - {{range .VisibleFlags}}{{.}} - {{end}} - EXAMPLES: - - 01. Run HPerf server with defaults - - {{.Prompt}} {{.HelpName}} +USAGE: + {{.HelpName}} [FLAGS] - 02. Run HPerf server with custom file path +FLAGS: + {{range .VisibleFlags}}{{.}} + {{end}} +EXAMPLES: + 1. Run HPerf server with defaults: + {{.Prompt}} {{.HelpName}} - {{.Prompt}} {{.HelpName}} --storage-path /path/on/disk - - 03. Run HPerf server with custom file path and custom address - - {{.Prompt}} {{.HelpName}} --storage-path /path/on/disk --address 0.0.0.0:9000 + 2. Run HPerf server with custom file path + {{.Prompt}} {{.HelpName}} --storage-path /path/on/disk + 3. Run HPerf server with custom file path and custom address + {{.Prompt}} {{.HelpName}} --storage-path /path/on/disk --address 0.0.0.0:9000 `, } ) diff --git a/cmd/cli/stop.go b/cmd/hperf/stop.go similarity index 66% rename from cmd/cli/stop.go rename to cmd/hperf/stop.go index 767f20a..a2546cc 100644 --- a/cmd/cli/stop.go +++ b/cmd/hperf/stop.go @@ -23,37 +23,34 @@ import ( ) var stopCMD = cli.Command{ - Name: "stop", - HelpName: "stop", - Prompt: "hperf", - Usage: "Stop a specific test or all test on the selected hosts", - Action: runStopCMD, + Name: "stop", + Usage: "stop a specific test or all test on the selected hosts", + Action: runStop, Flags: []cli.Flag{ dnsServerFlag, hostsFlag, portFlag, testIDFlag, }, - CustomHelpTemplate: ` - NAME: {{.HelpName}} - {{.Usage}} + CustomHelpTemplate: `NAME: + {{.HelpName}} - {{.Usage}} - FLAGS: - {{range .VisibleFlags}}{{.}} - {{end}} - EXAMPLES: +USAGE: + {{.HelpName}} [FLAGS] - 01. Stop all tests on hosts .1 and .2 - - {{.Prompt}} {{.HelpName}} --hosts 10.10.10.1,10.10.10.2 - - 02. Stop test by ID on hosts .1 and .2 - - {{.Prompt}} {{.HelpName}} --hosts 10.10.10.1,10.10.10.2 --id my_test_id +FLAGS: + {{range .VisibleFlags}}{{.}} + {{end}} +EXAMPLES: + 1. Stop all tests on hosts '10.10.10.1' and '10.10.10.2': + {{.Prompt}} {{.HelpName}} --hosts 10.10.10.1,10.10.10.2 + 2. Stop test by ID on hosts '10.10.10.1' and '10.10.10.2': + {{.Prompt}} {{.HelpName}} --hosts 10.10.10.1,10.10.10.2 --id my_test_id `, } -func runStopCMD(ctx *cli.Context) error { +func runStop(ctx *cli.Context) error { config, err := parseConfig(ctx) if err != nil { return err diff --git a/server/server.go b/server/server.go index 13d919c..a4bef59 100644 --- a/server/server.go +++ b/server/server.go @@ -45,9 +45,12 @@ import ( var ( httpServer = fiber.New(fiber.Config{ - StreamRequestBody: true, - ReadBufferSize: 1000000, - WriteBufferSize: 1000000, + StreamRequestBody: true, + ServerHeader: "hperf", + AppName: "hperf", + DisableStartupMessage: true, + ReadBufferSize: 1000000, + WriteBufferSize: 1000000, }) bindAddress = "0.0.0.0:9000" testFolderSuffix = "hperf-tests" @@ -117,7 +120,7 @@ func RunServer(ctx context.Context, address string, storagePath string) (err err } bindAddress = address - shared.DEBUG("Bind address:", bindAddress) + shared.INFO("starting 'hperf' server on:", bindAddress) err = startAPIandWS(cancelContext) if err != nil { return diff --git a/shared/shared.go b/shared/shared.go index ce3f716..347c40e 100644 --- a/shared/shared.go +++ b/shared/shared.go @@ -157,6 +157,10 @@ type Config struct { ResolveHosts string `json:"-"` } +func INFO(items ...any) { + fmt.Println(items...) +} + func DEBUG(items ...any) { if DebugEnabled { fmt.Println(items...)