Stop now counts the origin changes inside a running write, in a new writingOriginChanges field, and adds them to the count it logs. The prune test checks which rows survive, including a prefix with rows on both sides of 72 hours. The prefix page tests cover 5,000 and 5,001 rows and a row's time and peer count. New tests cover the dropped-rows warning and the dropped count's reset. The prune floor is named minOriginChangesPerPrefix. The README, TODO, package doc and doc comments are corrected to match. Model: deepseek-v4-pro
This commit is contained in:
@@ -206,6 +206,33 @@ func TestOriginChangesDropPastTheLimit(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestOriginChangesTakeResetsTheDroppedCount checks that a TakeOriginChanges
|
||||
// that reports dropped rows leaves the next one reporting none, so each drop
|
||||
// is logged once, not on every later write.
|
||||
func TestOriginChangesTakeResetsTheDroppedCount(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
const limit = 100000
|
||||
|
||||
table := routetable.New(routetable.Params{})
|
||||
addr := netip.MustParseAddr("10.0.0.0")
|
||||
|
||||
for range limit + 1 {
|
||||
table.Announce(netip.PrefixFrom(addr, 32), asA, routeOf(peerA, asA, 10))
|
||||
addr = addr.Next()
|
||||
}
|
||||
|
||||
_, dropped := table.TakeOriginChanges(limit)
|
||||
if dropped != 1 {
|
||||
t.Fatalf("dropped = %d, want 1", dropped)
|
||||
}
|
||||
|
||||
_, dropped = table.TakeOriginChanges(0)
|
||||
if dropped != 0 {
|
||||
t.Errorf("the next take's dropped = %d, want 0", dropped)
|
||||
}
|
||||
}
|
||||
|
||||
// TestOriginChangesPutBackTrimsToTheLimit checks that putting back what a
|
||||
// failed write took, after new changes filled the table again, drops the
|
||||
// oldest changes past the cap and counts them, so the cap still holds. The
|
||||
|
||||
Reference in New Issue
Block a user