expose --header-timeout option on featurebase backup

This commit is contained in:
Matthew Jaffee 2022-04-29 08:56:39 -05:00 committed by Matthew Jaffee
parent c554adb70a
commit e0e01f9f65
3 changed files with 16 additions and 4 deletions

View file

@ -32,5 +32,6 @@ Backs up a FeatureBase server to a local, tar-formatted snapshot file.
flags.StringVar(&cmd.Pprof, "pprof", cmd.Pprof, "host:port to listen for profiling requests at /debug/pprof and /debug/fgprof.")
ctl.SetTLSConfig(flags, "", &cmd.TLS.CertificatePath, &cmd.TLS.CertificateKeyPath, &cmd.TLS.CACertPath, &cmd.TLS.SkipVerify, &cmd.TLS.EnableClientVerification)
flags.StringVar(&cmd.AuthToken, "auth-token", "", "Authentication token")
flags.StringVar(&cmd.HeaderTimeoutStr, "header-timeout", cmd.HeaderTimeoutStr, "Length of time to wait for initial HTTP response before giving up.")
return ccmd
}

View file

@ -43,7 +43,8 @@ type BackupCommand struct { // nolint: maligned
RetryPeriod time.Duration `json:"retry-period"`
// Response Header Timeout for HTTP Requests
HeaderTimeout time.Duration `json:"header-timeout"`
HeaderTimeoutStr string
HeaderTimeout time.Duration `json:"header-timeout"`
// Host:port on which to listen for pprof.
Pprof string `json:"pprof"`
@ -85,6 +86,13 @@ func (cmd *BackupCommand) Run(ctx context.Context) (err error) {
} else if cmd.Concurrency <= 0 {
return fmt.Errorf("concurrency must be at least one")
}
if cmd.HeaderTimeoutStr != "" {
if dur, err := time.ParseDuration(cmd.HeaderTimeoutStr); err != nil {
return fmt.Errorf("could not parse '%s' as a duration: %v", cmd.HeaderTimeoutStr, err)
} else {
cmd.HeaderTimeout = dur
}
}
// Parse TLS configuration for node-specific clients.
tls := cmd.TLSConfiguration()

View file

@ -173,10 +173,13 @@ func TestClusterStuff(t *testing.T) {
var backupCmd *exec.Cmd
tmpdir := t.TempDir()
// collect code coverage while doing backup using an instrumented binary by calling
// a wrapper test (TestRunMain) for the main entrypoint of featurebase
// Collect code coverage while doing backup using an
// instrumented binary by calling a wrapper test (TestRunMain)
// for the main entrypoint of featurebase. Note, we pass the
// "--header-timeout" option simply to ensure that it is
// accepted and properly parsed by the command.
args := []string{"-test.run=TestRunMain", "-test.coverprofile=/results/coverage-backup.out", "backup",
"--host=pilosa1:10101", fmt.Sprintf("--output=%s", tmpdir+"/backuptest")}
"--host=pilosa1:10101", fmt.Sprintf("--output=%s", tmpdir+"/backuptest"), "--header-timeout=3s"}
if auth {
args = append(args, fmt.Sprintf("--auth-token=%s", token))
}