Skip to content

Commit

Permalink
Guard against non positive time limit
Browse files Browse the repository at this point in the history
  • Loading branch information
lyzs90 committed Feb 5, 2021
1 parent 9540f98 commit db6047b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion clusterloader2/pkg/tuningset/randomized_time_limited.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ func (r *randomizedTimeLimitedLoad) Execute(actions []func()) {
index := i
wg.Start(func() {
// Sleeps for random duration in [0, TimeLimit].
time.Sleep(time.Duration(rand.Int63n(r.params.TimeLimit.ToTimeDuration().Nanoseconds())))
timeLimit := r.params.TimeLimit.ToTimeDuration().Nanoseconds()
if timeLimit > 0 {
time.Sleep(time.Duration(rand.Int63n(timeLimit)))
}
actions[index]()
})
}
Expand Down
2 changes: 1 addition & 1 deletion clusterloader2/testing/load/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ tuningSets:
# The expected number of created/deleted pods is totalPods/4 when scaling,
# as each RS changes its size from X to a uniform random value in [X/2, 3X/2].
# To match 10 [pods/s] requirement, we need to divide saturationTime by 4.
timeLimit: {{MaxInt 1 (DivideInt $saturationTime 4)}}s
timeLimit: {{DivideInt $saturationTime 4}}s
- name: RandomizedDeletionTimeLimited
RandomizedTimeLimitedLoad:
timeLimit: {{$deletionTime}}s
Expand Down

0 comments on commit db6047b

Please sign in to comment.