Skip to content

Commit

Permalink
Fix ramping-arrival-rate execution requirements (#3593)
Browse files Browse the repository at this point in the history
* Fix ramping-arrival-rate execution requirements

* Fix linting issue
  • Loading branch information
joanlopez authored Feb 13, 2024
1 parent 9dbf343 commit 9c0c179
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/executor/ramping_arrival_rate.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func (varc RampingArrivalRateConfig) GetExecutionRequirements(et *lib.ExecutionT
{
TimeOffset: 0,
PlannedVUs: uint64(et.ScaleInt64(varc.PreAllocatedVUs.Int64)),
MaxUnplannedVUs: uint64(et.ScaleInt64(varc.MaxVUs.Int64 - varc.PreAllocatedVUs.Int64)),
MaxUnplannedVUs: uint64(et.ScaleInt64(varc.MaxVUs.Int64) - et.ScaleInt64(varc.PreAllocatedVUs.Int64)),
},
{
TimeOffset: sumStagesDuration(varc.Stages) + varc.GracefulStop.TimeDuration(),
Expand Down
36 changes: 36 additions & 0 deletions lib/executor/ramping_arrival_rate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -777,3 +777,39 @@ func TestRampingArrivalRateActiveVUs(t *testing.T) {
assert.GreaterOrEqual(t, running, int64(5))
assert.LessOrEqual(t, running, int64(10))
}

func TestRampingArrivalRateActiveVUs_GetExecutionRequirements(t *testing.T) {
t.Parallel()

tcs := map[string]struct {
preAllocatedVUs int64
maxVUs int64
segment string
sequence string
expPlannedVUs uint64
expMaxUnplannedVUs uint64
}{
"Segmented/Odd": {preAllocatedVUs: 1, maxVUs: 4000, segment: "0:1/4", sequence: "0,1/4,1/2,3/4,1", expPlannedVUs: 1, expMaxUnplannedVUs: 999},
"Segmented/Even": {preAllocatedVUs: 100, maxVUs: 4000, segment: "0:1/4", sequence: "0,1/4,1/2,3/4,1", expPlannedVUs: 25, expMaxUnplannedVUs: 975},
"NotSegmented/Odd": {preAllocatedVUs: 1, maxVUs: 4000, segment: "0:1", sequence: "0,1", expPlannedVUs: 1, expMaxUnplannedVUs: 3999},
"NotSegmented/Even": {preAllocatedVUs: 100, maxVUs: 4000, segment: "0:1", sequence: "0,1", expPlannedVUs: 100, expMaxUnplannedVUs: 3900},
}

for name, tc := range tcs {
tc := tc
t.Run(name, func(t *testing.T) {
t.Parallel()

config := &RampingArrivalRateConfig{
PreAllocatedVUs: null.IntFrom(tc.preAllocatedVUs),
MaxVUs: null.IntFrom(tc.maxVUs),
}

et, err := lib.NewExecutionTuple(newExecutionSegmentFromString(tc.segment), newExecutionSegmentSequenceFromString(tc.sequence))
require.NoError(t, err)

exp := []lib.ExecutionStep{{PlannedVUs: tc.expPlannedVUs, MaxUnplannedVUs: tc.expMaxUnplannedVUs}, {}}
require.Equal(t, exp, config.GetExecutionRequirements(et))
})
}
}

0 comments on commit 9c0c179

Please sign in to comment.