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:
@@ -145,4 +145,75 @@ func TestPrefixDetailSaysWhenMoreThan5000Changes(t *testing.T) {
|
||||
if !strings.Contains(page, "more than 5000 changes") {
|
||||
t.Errorf("page does not say there are more than 5000 changes")
|
||||
}
|
||||
|
||||
if got := strings.Count(page, "<td>Announced</td>"); got != 5000 {
|
||||
t.Errorf("page shows %d change rows, want 5000", got)
|
||||
}
|
||||
}
|
||||
|
||||
// TestPrefixDetailShowsNoNoteAtExactly5000Changes checks that a prefix with
|
||||
// exactly 5,000 origin changes shows all 5,000 and no note.
|
||||
func TestPrefixDetailShowsNoNoteAtExactly5000Changes(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
prefix := netip.MustParsePrefix(testPrefixV4)
|
||||
|
||||
changes := make([]routetable.OriginChange, 0, 5000)
|
||||
for i := range 5000 {
|
||||
changes = append(changes, routetable.OriginChange{
|
||||
Prefix: prefix, OriginASN: 64500, Announced: true, PeerCount: 1,
|
||||
Time: testRouteTime(i),
|
||||
})
|
||||
}
|
||||
|
||||
s := newPrefixDetailServer(t, changes)
|
||||
|
||||
rec := httptest.NewRecorder()
|
||||
s.router.ServeHTTP(rec, httptest.NewRequestWithContext(
|
||||
t.Context(), http.MethodGet, "/prefix/"+testPrefixV4, nil))
|
||||
|
||||
if rec.Code != http.StatusOK {
|
||||
t.Fatalf("status %d, want %d; body %s", rec.Code, http.StatusOK, rec.Body)
|
||||
}
|
||||
|
||||
page := rec.Body.String()
|
||||
|
||||
if strings.Contains(page, "more than") {
|
||||
t.Errorf("page says there are more changes, but a prefix has 5000")
|
||||
}
|
||||
|
||||
if got := strings.Count(page, "<td>Announced</td>"); got != 5000 {
|
||||
t.Errorf("page shows %d change rows, want 5000", got)
|
||||
}
|
||||
}
|
||||
|
||||
// TestPrefixDetailShowsOriginChangeTimeAndPeerCount checks that a row shows
|
||||
// its time and its peer count.
|
||||
func TestPrefixDetailShowsOriginChangeTimeAndPeerCount(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
prefix := netip.MustParsePrefix(testPrefixV4)
|
||||
|
||||
s := newPrefixDetailServer(t, []routetable.OriginChange{
|
||||
{Prefix: prefix, OriginASN: 64500, Announced: true, PeerCount: 7,
|
||||
Time: testRouteTime(5)},
|
||||
})
|
||||
|
||||
rec := httptest.NewRecorder()
|
||||
s.router.ServeHTTP(rec, httptest.NewRequestWithContext(
|
||||
t.Context(), http.MethodGet, "/prefix/"+testPrefixV4, nil))
|
||||
|
||||
if rec.Code != http.StatusOK {
|
||||
t.Fatalf("status %d, want %d; body %s", rec.Code, http.StatusOK, rec.Body)
|
||||
}
|
||||
|
||||
page := rec.Body.String()
|
||||
|
||||
if !strings.Contains(page, "2026-01-02 03:09:05") {
|
||||
t.Errorf("page does not show the origin change's time")
|
||||
}
|
||||
|
||||
if !strings.Contains(page, "<td>7</td>") {
|
||||
t.Errorf("page does not show the origin change's peer count")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user