Skip to content

Commit

Permalink
add "warp-client-file" hosts file
Browse files Browse the repository at this point in the history
  • Loading branch information
harshavardhana committed Jan 26, 2024
1 parent 1723cdb commit 73c14b4
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
4 changes: 4 additions & 0 deletions cli/benchmark.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ var benchFlags = []cli.Flag{
EnvVar: "",
Value: "",
},
cli.StringFlag{
Name: "warp-client-file",
Usage: "Connect to warp clients from a file",
},
}

// runBench will run the supplied benchmark and save/print the analysis.
Expand Down
24 changes: 21 additions & 3 deletions cli/benchserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package cli

import (
"bufio"
"context"
"errors"
"fmt"
Expand Down Expand Up @@ -88,11 +89,27 @@ type serverRequest struct {
// runServerBenchmark will run a benchmark server if requested.
// Returns a bool whether clients were specified.
func runServerBenchmark(ctx *cli.Context, b bench.Benchmark) (bool, error) {
if ctx.String("warp-client") == "" {
return false, nil
warpClient := ctx.String("warp-client")
var hosts []string
if warpClient == "" {
file := ctx.String("warp-client-file")
if file == "" {
return false, nil
}
f, err := os.Open(file)
if err != nil {
return false, err
}
scn := bufio.NewScanner(f)
for scn.Scan() {
hosts = append(hosts, scn.Text())
}
f.Close()
} else {
hosts = parseHosts(warpClient, false)
}

conns := newConnections(parseHosts(ctx.String("warp-client"), false))
conns := newConnections(hosts)
if len(conns.hosts) == 0 {
return true, errors.New("no hosts")
}
Expand All @@ -110,6 +127,7 @@ func runServerBenchmark(ctx *cli.Context, b bench.Benchmark) (bool, error) {
// Serialize parameters
excludeFlags := map[string]struct{}{
"warp-client": {},
"warp-client-file": {},
"warp-client-server": {},
"serverprof": {},
"autocompletion": {},
Expand Down

0 comments on commit 73c14b4

Please sign in to comment.