Skip to content
This repository was archived by the owner on Aug 23, 2023. It is now read-only.

Commit 16e0f25

Browse files
committed
Fix up tests
1 parent 9f33af1 commit 16e0f25

File tree

1 file changed

+11
-23
lines changed

1 file changed

+11
-23
lines changed

input/kafkamdm/lag_monitor_test.go

+11-23
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ func TestLagMonitor(t *testing.T) {
118118
for i := 0; i < 100; i++ {
119119
advance(i, int64(i*2), int64(i))
120120
}
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
122122
})
123123
Convey("rate of production is 100k and lag is 1000", func() {
124124
advance(1, 100000, 99000)
@@ -137,35 +137,23 @@ func TestLagMonitor(t *testing.T) {
137137
Convey("rate of production goes up to 200k but we can only keep up with the rate of 100k so lag starts growing", func() {
138138
advance(3, 400000, 299000)
139139
advance(4, 600000, 399000)
140-
So(mon.Metric(), ShouldEqual, 1) // (400000-299000)/100000 = 1
140+
So(mon.Metric(), ShouldEqual, 0) // (400000-299000)/200000 = 0
141141
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
143143
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
145148
})
146149
Convey("a GC pause is causing us to not be able to consume during a few seconds", func() {
147150
advance(3, 300000, 199000)
148151
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
152156
})
153157
})
154158
})
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-
})
171159
}

0 commit comments

Comments
 (0)