[#1] mclock: Use time.Duration for idle timeout

Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
Dmitrii Stepanov 2025-01-27 16:46:38 +03:00
parent 47559a8d16
commit f1cb5b40d5
Signed by: dstepanov-yadro
GPG key ID: 237AF1A763293BC0
3 changed files with 10 additions and 9 deletions

View file

@ -275,7 +275,7 @@ func TestMClockReservationScheduling(t *testing.T) {
func TestMClockIdleTag(t *testing.T) {
t.Parallel()
reqCount := 100
idleTimeout := 2.0
idleTimeout := 2 * time.Second
cl := &noopClock{}
q, err := NewMClock(1, math.MaxUint64, map[string]TagInfo{
"class1": {Share: 1},
@ -287,7 +287,7 @@ func TestMClockIdleTag(t *testing.T) {
var requests []*request
tag := "class1"
for i := 0; i < reqCount/2; i++ {
cl.v += idleTimeout / 2
cl.v += idleTimeout.Seconds() / 2
req, _, err := q.pushRequest(tag)
require.NoError(t, err)
requests = append(requests, req)
@ -295,7 +295,7 @@ func TestMClockIdleTag(t *testing.T) {
// class1 requests have shares [1.0; 2.0; 3.0; ... ]
cl.v += 2 * idleTimeout
cl.v += 2 * idleTimeout.Seconds()
tag = "class2"
req, _, err := q.pushRequest(tag)
@ -424,7 +424,7 @@ func TestMClockParameterValidation(t *testing.T) {
require.NoError(t, err)
_, err = NewMClock(1, 1, map[string]TagInfo{
"class1": {Share: 1},
}, float64(0))
}, 0)
require.NoError(t, err)
negativeValue := -1.0
zeroValue := float64(0)
@ -466,7 +466,7 @@ func TestMClockTimeBasedSchedule(t *testing.T) {
limit := 1.0 // 1 request per second allowed
cl := &noopClock{v: float64(1.5)}
q, err := NewMClock(100, math.MaxUint64, map[string]TagInfo{
"class1": {Shares: 1, Limit: &limit},
"class1": {Share: 1, LimitIOPS: &limit},
}, 100)
require.NoError(t, err)
defer q.Close()