Make the routewatch tests pass on a loaded host (closes #213)
check / check (push) Canceled after 0s
check / check (push) Canceled after 0s
Five prefix handler tests gave HandleMessage two seconds to apply a full batch of 25,000 prefixes, which under the race detector on a loaded host takes longer. A test now waits up to stepTimeout, 15 seconds, for each step it expects. The slowest tests filled production limits, such as the peering handler's 500,000 paths. The peering handler now takes its path limit, and the prefix handler its limit on one write of the table's changes, as they take their timer interval. Those tests give small limits, and the tests of the maximum batch size lower it to one batch. This also fixes #215. The test helpers bound every wait, Stop included, so a test that hangs in one fails with its own message. Model: opus-5-5
This commit was merged in pull request #214.
This commit is contained in:
1 parent
5ea1bb17fe
commit
38b43549b9
14 files changed
+234
-143
No files matched your search
@@ -30,11 +30,12 @@ const (
|
||||
|
||||
// firstManyPrefix is the first prefix announceManyPrefixes announces.
|
||||
firstManyPrefix = "10.0.0.0/32"
|
||||
)
|
||||
|
||||
// tableWriteTimeout is how long a test waits for the flush timer to write the
|
||||
// routing table's changes: a few ticks of it.
|
||||
const tableWriteTimeout = 5 * prefixBatchTimeout
|
||||
// testMaxTableChangesPerWrite is a limit of one write of the routing
|
||||
// table's changes that a test exceeds quickly, in place of
|
||||
// maxTableChangesPerWrite.
|
||||
testMaxTableChangesPerWrite = 10
|
||||
)
|
||||
|
||||
// tableCase is one test of the routing table in memory: the messages handed to
|
||||
// the prefix handler, and for each prefix the peers that carry it with each
|
||||
@@ -276,9 +277,9 @@ func TestPrefixHandlerWritesTheTableChangesEachSecond(t *testing.T) {
|
||||
t.Fatalf("wrote %+v, want the pair of %s and AS%d with "+
|
||||
"removed %t", changes, prefix, testASNB, step.wantRemoved)
|
||||
}
|
||||
case <-time.After(tableWriteTimeout):
|
||||
case <-time.After(stepTimeout):
|
||||
t.Fatalf("the routing table's change was not written within %s",
|
||||
tableWriteTimeout)
|
||||
stepTimeout)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -375,25 +376,32 @@ func (s *tableWriteSizesStore) WriteRouteChanges(
|
||||
// takes, then flushes three times. The first write must hold as many pairs as
|
||||
// one write takes, and the peer. The second must hold the other pairs, and the
|
||||
// third flush must write nothing. The database must then hold the table in
|
||||
// memory.
|
||||
// memory. The handler's limit is small, and its timer does not fire.
|
||||
func TestPrefixHandlerWritesManyTableChangesOverSeveralFlushes(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
const (
|
||||
pairs = maxTableChangesPerWrite * 3 / 2
|
||||
pairs = testMaxTableChangesPerWrite * 3 / 2
|
||||
flushes = 3
|
||||
)
|
||||
|
||||
db := newTestDatabase(t)
|
||||
store := &tableWriteSizesStore{Database: db}
|
||||
h := prefixHandlerWithoutTimer(store)
|
||||
announceManyPrefixes(h.table, pairs)
|
||||
table := routetable.New(routetable.Params{})
|
||||
announceManyPrefixes(table, pairs)
|
||||
|
||||
h := newPrefixHandler(store, logger.New(), table, longerThanAnyTest,
|
||||
testMaxTableChangesPerWrite)
|
||||
|
||||
defer stopInTime(t, h)
|
||||
|
||||
for range flushes {
|
||||
h.flushBatch()
|
||||
}
|
||||
|
||||
wantChanges := []int{maxTableChangesPerWrite, pairs - maxTableChangesPerWrite}
|
||||
wantChanges := []int{
|
||||
testMaxTableChangesPerWrite, pairs - testMaxTableChangesPerWrite,
|
||||
}
|
||||
wantNewPeers := []int{1, 0}
|
||||
|
||||
if !slices.Equal(store.changes, wantChanges) ||
|
||||
@@ -415,11 +423,11 @@ func TestPrefixHandlerWritesManyTableChangesOverSeveralFlushes(t *testing.T) {
|
||||
// takes. Its last flush writes one write's worth, so Stop must log the pairs
|
||||
// that no write took, and must not say that the stop deadline passed. The
|
||||
// flush timer must not fire, or its writes could leave no pairs for Stop to
|
||||
// log.
|
||||
// log. The handler's limit of one write is small.
|
||||
func TestPrefixHandlerStopLogsTheTableChangesLeftUnwritten(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
const pairs = maxTableChangesPerWrite + 1
|
||||
const pairs = testMaxTableChangesPerWrite + 1
|
||||
|
||||
var logs bytes.Buffer
|
||||
|
||||
@@ -427,7 +435,8 @@ func TestPrefixHandlerStopLogsTheTableChangesLeftUnwritten(t *testing.T) {
|
||||
table := routetable.New(routetable.Params{})
|
||||
announceManyPrefixes(table, pairs)
|
||||
|
||||
h := newPrefixHandler(store, newErrorLogger(&logs), table, longerThanAnyTest)
|
||||
h := newPrefixHandler(store, newErrorLogger(&logs), table, longerThanAnyTest,
|
||||
testMaxTableChangesPerWrite)
|
||||
h.Stop(t.Context())
|
||||
|
||||
written := 0
|
||||
|
||||
Reference in new issue
Block a user