Skip to content

Commit

Permalink
WIP mock time in the rest of the executors (split me)
Browse files Browse the repository at this point in the history
  • Loading branch information
oleiade committed Dec 3, 2021
1 parent 0bb0b7a commit 67fc6e0
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 6 deletions.
7 changes: 6 additions & 1 deletion lib/executor/constant_vus.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,12 @@ func (clv ConstantVUs) Run(
duration := clv.config.Duration.TimeDuration()
gracefulStop := clv.config.GetGracefulStop()

startTime, maxDurationCtx, regDurationCtx, cancel := getDurationContexts(parentCtx, duration, gracefulStop)
startTime, maxDurationCtx, regDurationCtx, cancel := getDurationContexts(
parentCtx,
clv.config.clock,
duration,
gracefulStop,
)
defer cancel()

// Make sure the log and the progress bar have accurate information
Expand Down
7 changes: 6 additions & 1 deletion lib/executor/ramping_arrival_rate.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,12 @@ func (varr RampingArrivalRate) Run(
activeVUsWg := &sync.WaitGroup{}

returnedVUs := make(chan struct{})
startTime, maxDurationCtx, regDurationCtx, cancel := getDurationContexts(parentCtx, duration, gracefulStop)
startTime, maxDurationCtx, regDurationCtx, cancel := getDurationContexts(
parentCtx,
varr.config.clock,
duration,
gracefulStop,
)

vusPool := newActiveVUPool()

Expand Down
10 changes: 7 additions & 3 deletions lib/executor/ramping_arrival_rate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"testing"
"time"

"github.com/benbjohnson/clock"
"github.com/sirupsen/logrus"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand All @@ -43,9 +44,12 @@ import (

func getTestRampingArrivalRateConfig() *RampingArrivalRateConfig {
return &RampingArrivalRateConfig{
BaseConfig: BaseConfig{GracefulStop: types.NullDurationFrom(1 * time.Second)},
TimeUnit: types.NullDurationFrom(time.Second),
StartRate: null.IntFrom(10),
BaseConfig: BaseConfig{
GracefulStop: types.NullDurationFrom(1 * time.Second),
clock: clock.NewMock(),
},
TimeUnit: types.NullDurationFrom(time.Second),
StartRate: null.IntFrom(10),
Stages: []Stage{
{
Duration: types.NullDurationFrom(time.Second * 1),
Expand Down
7 changes: 6 additions & 1 deletion lib/executor/shared_iterations.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,12 @@ func (si SharedIterations) Run(
duration := si.config.MaxDuration.TimeDuration()
gracefulStop := si.config.GetGracefulStop()

startTime, maxDurationCtx, regDurationCtx, cancel := getDurationContexts(parentCtx, duration, gracefulStop)
startTime, maxDurationCtx, regDurationCtx, cancel := getDurationContexts(
parentCtx,
si.config.clock,
duration,
gracefulStop,
)
defer cancel()

// Make sure the log and the progress bar have accurate information
Expand Down

0 comments on commit 67fc6e0

Please sign in to comment.