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
3 changed files with 5 additions and 8 deletions

View File

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

View File

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