@@ -118,7 +118,7 @@ func TestLagMonitor(t *testing.T) {
118
118
for i := 0 ; i < 100 ; i ++ {
119
119
advance (i , int64 (i * 2 ), int64 (i ))
120
120
}
121
- So (mon .Metric (), ShouldEqual , 98 ) // min-lag(98) / rate (1 ) = 98
121
+ So (mon .Metric (), ShouldEqual , 49 ) // min-lag(98) / input rate (2 ) = 49
122
122
})
123
123
Convey ("rate of production is 100k and lag is 1000" , func () {
124
124
advance (1 , 100000 , 99000 )
@@ -137,35 +137,23 @@ func TestLagMonitor(t *testing.T) {
137
137
Convey ("rate of production goes up to 200k but we can only keep up with the rate of 100k so lag starts growing" , func () {
138
138
advance (3 , 400000 , 299000 )
139
139
advance (4 , 600000 , 399000 )
140
- So (mon .Metric (), ShouldEqual , 1 ) // (400000-299000)/100000 = 1
140
+ So (mon .Metric (), ShouldEqual , 0 ) // (400000-299000)/200000 = 0
141
141
advance (5 , 800000 , 499000 ) // note: we're now where the producer was at +- t=3.5, so 1.5s behind
142
- So (mon .Metric (), ShouldEqual , 2 ) // (600000-399000)/100000 = 2
142
+ So (mon .Metric (), ShouldEqual , 1 ) // (600000-399000)/200000 = 1
143
143
advance (6 , 1000000 , 599000 ) // note: we're now at where the producer was at +- t=4, so 2 seconds behind
144
- So (mon .Metric (), ShouldEqual , 3 ) // (800000-499000)/100000 = 3
144
+ So (mon .Metric (), ShouldEqual , 1 ) // (800000-499000)/200000 = 1
145
+ advance (15 , 2800000 , 1499000 )
146
+ advance (16 , 3000000 , 1599000 ) // Jump forward 10 seconds, where the producer was at +- t=9, so 7 seconds behind
147
+ So (mon .Metric (), ShouldEqual , 6 ) // (2800000-1499000)/200000 = 6
145
148
})
146
149
Convey ("a GC pause is causing us to not be able to consume during a few seconds" , func () {
147
150
advance (3 , 300000 , 199000 )
148
151
advance (4 , 400000 , 199000 )
149
- // TODO: this punishes really hard for short GC pauses
150
- So (mon .Metric (), ShouldEqual , 101000 ) // ~(300000-199000)/0 -> 101000
151
- // TODO: test what happens during recovery
152
+ So (mon .Metric (), ShouldEqual , 1 ) // ~(300000-199000)/100000 = 1
153
+ // test what happens during recovery
154
+ advance (5 , 500000 , 499000 )
155
+ So (mon .Metric (), ShouldEqual , 0 ) // ~(500000-499000)/100000 = 0
152
156
})
153
157
})
154
158
})
155
- Convey ("with lots of measurements" , t , func () {
156
- now := time .Now ()
157
- for part := range mon .monitors {
158
- for i := 0 ; i < 100 ; i ++ {
159
- mon .StoreOffsets (part , int64 (i ), int64 (2 * i ), now .Add (time .Second * time .Duration (i )))
160
- }
161
- }
162
- So (mon .Metric (), ShouldEqual , 45 )
163
- })
164
- Convey ("metric should be worst partition" , t , func () {
165
- now := time .Now ()
166
- for part := range mon .monitors {
167
- mon .StoreOffsets (part , int64 (part + 200 ), int64 (2 * part + 210 ), now .Add (time .Second * time .Duration (part + 100 )))
168
- }
169
- So (mon .Metric (), ShouldEqual , 6 )
170
- })
171
159
}
0 commit comments