Repeater: TX stall watchdog -- packets queued, nothing sent for 15 min: re-arm, then reboot
pub-release / release (push) Successful in 39m1s
pub-release / release (push) Successful in 39m1s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
01d66a66ce
commit
d9c7b9c008
6 files changed
+167
-4
No files matched your search
@@ -169,6 +169,68 @@ TEST(RadioSilenceWatchdog, PacedToCheckInterval) {
|
||||
EXPECT_EQ(actions, 1); // the reboot step (5 min) is not due yet
|
||||
}
|
||||
|
||||
// The TX stall watchdog (NodeMaintenance::txStallTick) drives the same class:
|
||||
// begin() on every pass while the outbound queue is empty, poll() with the sent
|
||||
// counter while something waits. Mirror of that glue, one pass per ms.
|
||||
static A::Action txStallPass(A& wd, uint32_t now, int queued, uint32_t sent) {
|
||||
if (queued <= 0) {
|
||||
wd.begin(now, sent, 0);
|
||||
return A::NONE;
|
||||
}
|
||||
return wd.poll(now, sent);
|
||||
}
|
||||
|
||||
TEST(TxStallWatchdog, IdleQueueNeverActs) {
|
||||
A wd;
|
||||
wd.begin(0, 0, 0);
|
||||
wd.setMinutes(15);
|
||||
for (uint32_t t = 0; t < 24 * 60 * MIN; t += 1000) EXPECT_EQ(txStallPass(wd, t, 0, 0), A::NONE);
|
||||
}
|
||||
|
||||
TEST(TxStallWatchdog, LongIdleThenQueuedStartsFromZero) {
|
||||
A wd;
|
||||
wd.begin(0, 0, 0);
|
||||
wd.setMinutes(15);
|
||||
for (uint32_t t = 0; t < 10 * 60 * MIN; t += 1000) txStallPass(wd, t, 0, 7);
|
||||
// hours with an empty queue must not count: a packet queued now gets 15 min
|
||||
uint32_t start = 10 * 60 * MIN, kicked = 0;
|
||||
for (uint32_t t = start; t < start + 20 * MIN; t += 1000) {
|
||||
if (txStallPass(wd, t, 3, 7) == A::KICK_RX) { kicked = t; break; }
|
||||
}
|
||||
EXPECT_GE(kicked - start, 15 * MIN - 1000); // counted from the last empty-queue pass
|
||||
EXPECT_LT(kicked - start, 15 * MIN + A::CHECK_MS + 1000);
|
||||
}
|
||||
|
||||
TEST(TxStallWatchdog, BusyButSendingNeverActs) {
|
||||
A wd;
|
||||
wd.begin(0, 0, 0);
|
||||
wd.setMinutes(15);
|
||||
// a queue that never drains (busy repeater) is fine while packets go out
|
||||
uint32_t sent = 0;
|
||||
for (uint32_t t = 0; t < 6 * 60 * MIN; t += 1000) {
|
||||
if (t % (2 * MIN) == 0) sent++;
|
||||
EXPECT_EQ(txStallPass(wd, t, 32, sent), A::NONE);
|
||||
}
|
||||
}
|
||||
|
||||
TEST(TxStallWatchdog, FrozenSentKicksThenReboots) {
|
||||
A wd;
|
||||
wd.begin(0, 0, 0);
|
||||
wd.setMinutes(15);
|
||||
// mast-three 14. 11. 2026: queue full, sent frozen
|
||||
A::Action first = A::NONE, second = A::NONE;
|
||||
uint32_t t1 = 0, t2 = 0;
|
||||
for (uint32_t t = 0; t < 30 * MIN; t += 1000) {
|
||||
A::Action a = txStallPass(wd, t, 32, 3444);
|
||||
if (a != A::NONE && first == A::NONE) { first = a; t1 = t; }
|
||||
else if (a != A::NONE) { second = a; t2 = t; break; }
|
||||
}
|
||||
EXPECT_EQ(first, A::KICK_RX);
|
||||
EXPECT_EQ(second, A::REBOOT);
|
||||
EXPECT_GE(t1, 15 * MIN);
|
||||
EXPECT_GE(t2 - t1, 5 * MIN); // step = max(15/4, 5) min
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
|
||||
Reference in new issue
Block a user