fix(scaletest/dashboard): fix early exit due to validate (#10212)

This commit is contained in:
Cian Johnston 2023-10-11 12:51:06 +01:00 committed by GitHub
parent ed8092c83d
commit e829cbf2db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 8 deletions

View File

@ -1166,6 +1166,7 @@ func (r *RootCmd) scaletestDashboard() *clibase.Cmd {
//nolint:gocritic
logger.Info(ctx, "runner config", slog.F("interval", interval), slog.F("jitter", jitter), slog.F("headless", headless), slog.F("trace", tracingEnabled))
if err := config.Validate(); err != nil {
logger.Fatal(ctx, "validate config", slog.Error(err))
return err
}
var runner harness.Runnable = dashboard.NewRunner(userClient, metrics, config)

View File

@ -39,13 +39,5 @@ func (c Config) Validate() error {
return xerrors.Errorf("validate jitter: must be less than interval")
}
if c.ActionFunc == nil {
return xerrors.Errorf("validate action func: must not be nil")
}
if c.RandIntn == nil {
return xerrors.Errorf("validate rand intn: must not be nil")
}
return nil
}

View File

@ -4,6 +4,7 @@ import (
"context"
"errors"
"io"
"math/rand"
"time"
"golang.org/x/xerrors"
@ -35,6 +36,9 @@ func NewRunner(client *codersdk.Client, metrics Metrics, cfg Config) *Runner {
if cfg.Screenshot == nil {
cfg.Screenshot = Screenshot
}
if cfg.RandIntn == nil {
cfg.RandIntn = rand.Intn
}
return &Runner{
client: client,
cfg: cfg,