The routing table in memory now holds every route, so the two per-peer route tables go, with every write, delete, count and read that served them. The prefix handler applies each update to the table, writes the table's changes every second, and stores each new prefix with its first-seen time. The peer delete, its retry on the next flush and the updates held for it go too. The types and errors of the server's answers move to internal/server. The image's memory settings fit a full table of about 1 GB: GOMEMLIMIT of 2.5 GiB, a 512 MiB page cache for the writing connection, and SQLite heap limits of 768 MiB and 1 GiB. The README describes the new table, its database copy and the memory budget. Model: opus-5-5
This commit was merged in pull request #195.
This commit is contained in:
@@ -11,6 +11,7 @@ import (
|
||||
"time"
|
||||
|
||||
"git.eeqj.de/sneak/routewatch/internal/database"
|
||||
"git.eeqj.de/sneak/routewatch/internal/ristypes"
|
||||
"git.eeqj.de/sneak/routewatch/internal/routetable"
|
||||
)
|
||||
|
||||
@@ -134,6 +135,34 @@ func TestIPLookupGivesTheOriginMostPeersCarry(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestIPLookupAsksForNoWHOISLookupOfOriginZero checks that the IP lookup asks
|
||||
// for no WHOIS lookup of AS 0, which means no known origin. It asks for one of
|
||||
// an AS whose WHOIS details were never fetched or are stale, and not of one
|
||||
// whose details are fresh.
|
||||
func TestIPLookupAsksForNoWHOISLookupOfOriginZero(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
fresh := time.Now().Add(-time.Hour)
|
||||
stale := time.Now().Add(-2 * whoisStaleThreshold)
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
asInfo database.ASN
|
||||
want bool
|
||||
}{
|
||||
{"no known origin", database.ASN{ASN: ristypes.NoOrigin}, false},
|
||||
{"details never fetched", database.ASN{ASN: mostPeersASN}, true},
|
||||
{"stale details", database.ASN{ASN: mostPeersASN, WHOISUpdatedAt: &stale}, true},
|
||||
{"fresh details", database.ASN{ASN: mostPeersASN, WHOISUpdatedAt: &fresh}, false},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
if got := needsWHOISRefresh(&tt.asInfo); got != tt.want {
|
||||
t.Errorf("%s: needsWHOISRefresh = %t, want %t", tt.name, got, tt.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// prefixRoute is one route of the prefix API's answer. A field the answer
|
||||
// leaves out stays nil.
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user