@@ -30,14 +30,16 @@ func compareJobs(t *testing.T, expected, actual *JobWithMetadata) {
30
30
31
31
func TestRecordCountPlanner_Plan (t * testing.T ) {
32
32
for _ , tc := range []struct {
33
- name string
34
- recordCount int64
35
- expectedJobs []* JobWithMetadata
36
- groupLag map [int32 ]kadm.GroupMemberLag
33
+ name string
34
+ recordCount int64
35
+ minOffsetsPerJob int
36
+ expectedJobs []* JobWithMetadata
37
+ groupLag map [int32 ]kadm.GroupMemberLag
37
38
}{
38
39
{
39
- name : "single partition, single job" ,
40
- recordCount : 100 ,
40
+ name : "single partition, single job" ,
41
+ recordCount : 100 ,
42
+ minOffsetsPerJob : 0 ,
41
43
groupLag : map [int32 ]kadm.GroupMemberLag {
42
44
0 : {
43
45
Commit : kadm.Offset {
@@ -57,8 +59,9 @@ func TestRecordCountPlanner_Plan(t *testing.T) {
57
59
},
58
60
},
59
61
{
60
- name : "single partition, multiple jobs" ,
61
- recordCount : 50 ,
62
+ name : "single partition, multiple jobs" ,
63
+ recordCount : 50 ,
64
+ minOffsetsPerJob : 0 ,
62
65
groupLag : map [int32 ]kadm.GroupMemberLag {
63
66
0 : {
64
67
Commit : kadm.Offset {
@@ -82,8 +85,9 @@ func TestRecordCountPlanner_Plan(t *testing.T) {
82
85
},
83
86
},
84
87
{
85
- name : "multiple partitions" ,
86
- recordCount : 100 ,
88
+ name : "multiple partitions" ,
89
+ recordCount : 100 ,
90
+ minOffsetsPerJob : 0 ,
87
91
groupLag : map [int32 ]kadm.GroupMemberLag {
88
92
0 : {
89
93
Commit : kadm.Offset {
@@ -120,8 +124,9 @@ func TestRecordCountPlanner_Plan(t *testing.T) {
120
124
},
121
125
},
122
126
{
123
- name : "no lag" ,
124
- recordCount : 100 ,
127
+ name : "no lag" ,
128
+ recordCount : 100 ,
129
+ minOffsetsPerJob : 0 ,
125
130
groupLag : map [int32 ]kadm.GroupMemberLag {
126
131
0 : {
127
132
Commit : kadm.Offset {
@@ -135,6 +140,37 @@ func TestRecordCountPlanner_Plan(t *testing.T) {
135
140
},
136
141
expectedJobs : nil ,
137
142
},
143
+ {
144
+ name : "skip small jobs" ,
145
+ recordCount : 100 ,
146
+ minOffsetsPerJob : 40 ,
147
+ groupLag : map [int32 ]kadm.GroupMemberLag {
148
+ 0 : {
149
+ Commit : kadm.Offset {
150
+ At : 100 ,
151
+ },
152
+ End : kadm.ListedOffset {
153
+ Offset : 130 , // Only 30 records available, less than minimum
154
+ },
155
+ Partition : 0 ,
156
+ },
157
+ 1 : {
158
+ Commit : kadm.Offset {
159
+ At : 200 ,
160
+ },
161
+ End : kadm.ListedOffset {
162
+ Offset : 300 , // 100 records available, more than minimum
163
+ },
164
+ Partition : 1 ,
165
+ },
166
+ },
167
+ expectedJobs : []* JobWithMetadata {
168
+ NewJobWithMetadata (
169
+ types .NewJob (1 , types.Offsets {Min : 201 , Max : 300 }),
170
+ 99 , // priority is total remaining: 300-201
171
+ ),
172
+ },
173
+ },
138
174
} {
139
175
t .Run (tc .name , func (t * testing.T ) {
140
176
mockReader := & mockOffsetReader {
@@ -147,7 +183,7 @@ func TestRecordCountPlanner_Plan(t *testing.T) {
147
183
}
148
184
require .NoError (t , cfg .Validate ())
149
185
planner := NewRecordCountPlanner (mockReader , tc .recordCount , time .Hour , log .NewNopLogger ())
150
- jobs , err := planner .Plan (context .Background (), 0 )
186
+ jobs , err := planner .Plan (context .Background (), 0 , tc . minOffsetsPerJob )
151
187
require .NoError (t , err )
152
188
153
189
require .Equal (t , len (tc .expectedJobs ), len (jobs ))
0 commit comments