3
3
// Use of this software is governed by the CockroachDB Software License
4
4
// included in the /LICENSE file.
5
5
6
- package kvserver
6
+ package taskpacer
7
7
8
8
import (
9
9
"testing"
@@ -16,30 +16,30 @@ import (
16
16
"github.com/stretchr/testify/require"
17
17
)
18
18
19
- // MockTaskPacerConfig is a test implementation of a task pacer configuration.
20
- type MockTaskPacerConfig struct {
19
+ // MockConfig is a test implementation of a task pacer configuration.
20
+ type MockConfig struct {
21
21
// refresh is the interval between task batches
22
22
refresh time.Duration
23
23
// smear is the interval between task batches
24
24
smear time.Duration
25
25
}
26
26
27
- func newMockTaskPacerConfig (refresh , smear time.Duration ) * MockTaskPacerConfig {
28
- return & MockTaskPacerConfig {
27
+ func newMockConfig (refresh , smear time.Duration ) * MockConfig {
28
+ return & MockConfig {
29
29
refresh : refresh ,
30
30
smear : smear ,
31
31
}
32
32
}
33
33
34
- func (tp * MockTaskPacerConfig ) getRefresh () time.Duration {
34
+ func (tp * MockConfig ) GetRefresh () time.Duration {
35
35
return tp .refresh
36
36
}
37
37
38
- func (tp * MockTaskPacerConfig ) getSmear () time.Duration {
38
+ func (tp * MockConfig ) GetSmear () time.Duration {
39
39
return tp .smear
40
40
}
41
41
42
- func TestTaskPacer (t * testing.T ) {
42
+ func TestPacer (t * testing.T ) {
43
43
defer leaktest .AfterTest (t )()
44
44
defer log .Scope (t ).Close (t )
45
45
@@ -62,7 +62,7 @@ func TestTaskPacer(t *testing.T) {
62
62
wantBy : []time.Duration {200 },
63
63
wantDone : 55 ,
64
64
}, {
65
- // If smear is set to 0, the taskPacer should not smear the work over
65
+ // If smear is set to 0, the Pacer should not smear the work over
66
66
// time.
67
67
desc : "zero-smear" ,
68
68
deadline : 200 , smear : 0 , work : 1234 ,
@@ -143,8 +143,8 @@ func TestTaskPacer(t *testing.T) {
143
143
start := timeutil .Unix (946684800 , 0 ) // Jan 1, 2000
144
144
now := start
145
145
146
- conf := newMockTaskPacerConfig (tc .deadline , tc .smear )
147
- pacer := NewTaskPacer (conf )
146
+ conf := newMockConfig (tc .deadline , tc .smear )
147
+ pacer := New (conf )
148
148
pacer .StartTask (now )
149
149
150
150
for work , startAt := tc .work , now ; work != 0 ; {
@@ -171,9 +171,9 @@ func TestTaskPacer(t *testing.T) {
171
171
}
172
172
}
173
173
174
- // TestTaskPacerAccommodatesConfChanges tests that the taskPacer can accommodate
174
+ // TestPacerAccommodatesConfChanges tests that the Pacer can accommodate
175
175
// changing the refresh and the smear intervals mid-run.
176
- func TestTaskPacerAccommodatesConfChanges (t * testing.T ) {
176
+ func TestPacerAccommodatesConfChanges (t * testing.T ) {
177
177
defer leaktest .AfterTest (t )()
178
178
defer log .Scope (t ).Close (t )
179
179
@@ -242,8 +242,8 @@ func TestTaskPacerAccommodatesConfChanges(t *testing.T) {
242
242
start := timeutil .Unix (946684800 , 0 ) // Jan 1, 2000
243
243
now := start
244
244
245
- conf := newMockTaskPacerConfig (tc .refreshes [0 ], tc .smears [0 ])
246
- pacer := NewTaskPacer (conf )
245
+ conf := newMockConfig (tc .refreshes [0 ], tc .smears [0 ])
246
+ pacer := New (conf )
247
247
pacer .StartTask (now )
248
248
249
249
index := 0
@@ -274,5 +274,4 @@ func TestTaskPacerAccommodatesConfChanges(t *testing.T) {
274
274
assert .Equal (t , tc .wantDone , now .Sub (start ))
275
275
})
276
276
}
277
-
278
277
}
0 commit comments