net/netcheck: add addReportHistoryAndSetPreferredDERP() test case (#13989)

Add an explicit case for exercising preferred DERP hysteresis around
the branch that compares latencies on a percentage basis.

Updates #cleanup

Signed-off-by: Jordan Whited <jordan@tailscale.com>
This commit is contained in:
Jordan Whited 2024-10-31 19:25:00 -07:00 committed by GitHub
parent 84c8860472
commit 49de23cf1b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -357,6 +357,15 @@ type step struct {
wantPrevLen: 3, wantPrevLen: 3,
wantDERP: 2, // moved to d2 since d1 is gone wantDERP: 2, // moved to d2 since d1 is gone
}, },
{
name: "preferred_derp_hysteresis_no_switch_pct",
steps: []step{
{0 * time.Second, report("d1", 34*time.Millisecond, "d2", 35*time.Millisecond)},
{1 * time.Second, report("d1", 34*time.Millisecond, "d2", 23*time.Millisecond)},
},
wantPrevLen: 2,
wantDERP: 1, // diff is 11ms, but d2 is greater than 2/3s of d1
},
} }
for _, tt := range tests { for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {