Fix the third review of the origin changes
check / check (push) Canceled after 57s

The prune test gains a third prefix with more than 500 rows newer than 72
hours, and checks every newer row survives and every older one is deleted, in
a helper shared by the three prefixes. The prefix page test uses an origin AS
the routing table does not carry. README's limit list says the routing table
drops the oldest waiting origin changes past 100,000, and the prefix page
entry says the page shows at most the newest 5,000. The tests read 5,000 and
100,000 from named limits instead of bare numbers, so the routing table's
waiting cap is now exported for them.

Model: deepseek-v4-pro
This commit is contained in:
2026-11-05 05:36:57 +00:00
parent 22783eb425
commit 4581bc2cc4
7 changed files with 108 additions and 75 deletions
+3 -3
View File
@@ -6,10 +6,10 @@ import (
"time"
)
// maxWaitingOriginChanges is the most origin changes the table keeps waiting
// MaxWaitingOriginChanges is the most origin changes the table keeps waiting
// for the prefix handler to write. The oldest change past it is dropped and
// counted.
const maxWaitingOriginChanges = 100000
const MaxWaitingOriginChanges = 100000
// OriginChange is one change of a prefix and origin AS pair: the origin AS
// gained its first peer, or lost its last.
@@ -76,7 +76,7 @@ func (t *Table) PutBackOriginChanges(changes []OriginChange) {
// trimOriginChanges drops the oldest origin changes past the cap and counts
// them. The caller holds the lock.
func (t *Table) trimOriginChanges() {
if extra := len(t.originChanges) - maxWaitingOriginChanges; extra > 0 {
if extra := len(t.originChanges) - MaxWaitingOriginChanges; extra > 0 {
t.originChangesDropped += extra
t.originChanges = t.originChanges[extra:]
}
+11 -14
View File
@@ -184,25 +184,24 @@ func TestOriginChangesPutBackPutsRowsInFront(t *testing.T) {
func TestOriginChangesDropPastTheLimit(t *testing.T) {
t.Parallel()
const limit = 100000
table := routetable.New(routetable.Params{})
addr := netip.MustParseAddr("10.0.0.0")
for range limit + 1 {
for range routetable.MaxWaitingOriginChanges + 1 {
prefix := netip.PrefixFrom(addr, 32)
table.Announce(prefix, asA, routeOf(peerA, asA, 10))
addr = addr.Next()
}
changes, dropped := table.TakeOriginChanges(limit)
changes, dropped := table.TakeOriginChanges(routetable.MaxWaitingOriginChanges)
if dropped != 1 {
t.Errorf("dropped = %d, want 1", dropped)
}
if len(changes) != limit {
t.Errorf("len(changes) = %d, want %d", len(changes), limit)
if len(changes) != routetable.MaxWaitingOriginChanges {
t.Errorf("len(changes) = %d, want %d", len(changes),
routetable.MaxWaitingOriginChanges)
}
}
@@ -212,17 +211,15 @@ func TestOriginChangesDropPastTheLimit(t *testing.T) {
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 {
for range routetable.MaxWaitingOriginChanges + 1 {
table.Announce(netip.PrefixFrom(addr, 32), asA, routeOf(peerA, asA, 10))
addr = addr.Next()
}
_, dropped := table.TakeOriginChanges(limit)
_, dropped := table.TakeOriginChanges(routetable.MaxWaitingOriginChanges)
if dropped != 1 {
t.Fatalf("dropped = %d, want 1", dropped)
}
@@ -241,7 +238,6 @@ func TestOriginChangesPutBackTrimsToTheLimit(t *testing.T) {
t.Parallel()
const (
limit = 100000
taken = 20000
added = 20000
)
@@ -263,7 +259,7 @@ func TestOriginChangesPutBackTrimsToTheLimit(t *testing.T) {
}
}
announce(limit)
announce(routetable.MaxWaitingOriginChanges)
takenChanges, _ := table.TakeOriginChanges(taken)
@@ -276,8 +272,9 @@ func TestOriginChangesPutBackTrimsToTheLimit(t *testing.T) {
t.Errorf("dropped = %d, want %d", dropped, added)
}
if len(changes) != limit {
t.Errorf("len(changes) = %d, want %d", len(changes), limit)
if len(changes) != routetable.MaxWaitingOriginChanges {
t.Errorf("len(changes) = %d, want %d", len(changes),
routetable.MaxWaitingOriginChanges)
}
// The put-back rows are the oldest, so they are the ones dropped. The