From aa763a7218a159298f7f53b3d2a1d9a78ada1637 Mon Sep 17 00:00:00 2001 From: Cian Johnston Date: Wed, 11 Oct 2023 11:22:14 +0000 Subject: [PATCH] fix(scaletest/dashboard): fix early exit due to validate --- cli/exp_scaletest.go | 1 + scaletest/dashboard/config.go | 8 -------- scaletest/dashboard/run.go | 4 ++++ 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/cli/exp_scaletest.go b/cli/exp_scaletest.go index 3154e96ddb7ef..be9fb56a9d367 100644 --- a/cli/exp_scaletest.go +++ b/cli/exp_scaletest.go @@ -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) diff --git a/scaletest/dashboard/config.go b/scaletest/dashboard/config.go index 0397f52e390c5..2bd72ccdf6cbc 100644 --- a/scaletest/dashboard/config.go +++ b/scaletest/dashboard/config.go @@ -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 } diff --git a/scaletest/dashboard/run.go b/scaletest/dashboard/run.go index fd7ce95b63adf..9d7d6f32f2a35 100644 --- a/scaletest/dashboard/run.go +++ b/scaletest/dashboard/run.go @@ -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,