33// Use of this software is governed by the CockroachDB Software License
44// included in the /LICENSE file.
55
6- package kvserver
6+ package taskpacer
77
88import (
99 "testing"
@@ -16,30 +16,30 @@ import (
1616 "github.com/stretchr/testify/require"
1717)
1818
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 {
2121 // refresh is the interval between task batches
2222 refresh time.Duration
2323 // smear is the interval between task batches
2424 smear time.Duration
2525}
2626
27- func newMockTaskPacerConfig (refresh , smear time.Duration ) * MockTaskPacerConfig {
28- return & MockTaskPacerConfig {
27+ func newMockConfig (refresh , smear time.Duration ) * MockConfig {
28+ return & MockConfig {
2929 refresh : refresh ,
3030 smear : smear ,
3131 }
3232}
3333
34- func (tp * MockTaskPacerConfig ) getRefresh () time.Duration {
34+ func (tp * MockConfig ) GetRefresh () time.Duration {
3535 return tp .refresh
3636}
3737
38- func (tp * MockTaskPacerConfig ) getSmear () time.Duration {
38+ func (tp * MockConfig ) GetSmear () time.Duration {
3939 return tp .smear
4040}
4141
42- func TestTaskPacer (t * testing.T ) {
42+ func TestPacer (t * testing.T ) {
4343 defer leaktest .AfterTest (t )()
4444 defer log .Scope (t ).Close (t )
4545
@@ -62,7 +62,7 @@ func TestTaskPacer(t *testing.T) {
6262 wantBy : []time.Duration {200 },
6363 wantDone : 55 ,
6464 }, {
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
6666 // time.
6767 desc : "zero-smear" ,
6868 deadline : 200 , smear : 0 , work : 1234 ,
@@ -143,8 +143,8 @@ func TestTaskPacer(t *testing.T) {
143143 start := timeutil .Unix (946684800 , 0 ) // Jan 1, 2000
144144 now := start
145145
146- conf := newMockTaskPacerConfig (tc .deadline , tc .smear )
147- pacer := NewTaskPacer (conf )
146+ conf := newMockConfig (tc .deadline , tc .smear )
147+ pacer := New (conf )
148148 pacer .StartTask (now )
149149
150150 for work , startAt := tc .work , now ; work != 0 ; {
@@ -171,9 +171,9 @@ func TestTaskPacer(t *testing.T) {
171171 }
172172}
173173
174- // TestTaskPacerAccommodatesConfChanges tests that the taskPacer can accommodate
174+ // TestPacerAccommodatesConfChanges tests that the Pacer can accommodate
175175// changing the refresh and the smear intervals mid-run.
176- func TestTaskPacerAccommodatesConfChanges (t * testing.T ) {
176+ func TestPacerAccommodatesConfChanges (t * testing.T ) {
177177 defer leaktest .AfterTest (t )()
178178 defer log .Scope (t ).Close (t )
179179
@@ -242,8 +242,8 @@ func TestTaskPacerAccommodatesConfChanges(t *testing.T) {
242242 start := timeutil .Unix (946684800 , 0 ) // Jan 1, 2000
243243 now := start
244244
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 )
247247 pacer .StartTask (now )
248248
249249 index := 0
@@ -274,5 +274,4 @@ func TestTaskPacerAccommodatesConfChanges(t *testing.T) {
274274 assert .Equal (t , tc .wantDone , now .Sub (start ))
275275 })
276276 }
277-
278277}
0 commit comments