SetBGPPeerCount stored a count only when it was above 0, so once the last peer's session ended, /api/v1/stats kept reporting the previous count. It now stores every count from 0 up; a negative count, or one too large for the int32 it is kept in, is still not stored. Model: opus-5-5
This commit is contained in:
@@ -25,3 +25,18 @@ func TestReconnectCount(t *testing.T) {
|
||||
t.Fatalf("reconnect count = %d, want %d", got, wantReconnects)
|
||||
}
|
||||
}
|
||||
|
||||
// TestBGPPeerCountDropsToZero sets a peer count of 1 and then 0, the way the
|
||||
// streamer does when the last peer's session ends, and expects 0 back.
|
||||
func TestBGPPeerCountDropsToZero(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
tracker := metrics.New()
|
||||
|
||||
tracker.SetBGPPeerCount(1)
|
||||
tracker.SetBGPPeerCount(0)
|
||||
|
||||
if got := tracker.GetBGPPeerCount(); got != 0 {
|
||||
t.Fatalf("peer count = %d after setting 0, want 0", got)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user