~stepbrobd/tailscale

49de23cf1bae372996de797d86ced771ed314756 — Jordan Whited a month ago 84c8860
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>
1 files changed, 9 insertions(+), 0 deletions(-)

M net/netcheck/netcheck_test.go
M net/netcheck/netcheck_test.go => net/netcheck/netcheck_test.go +9 -0
@@ 357,6 357,15 @@ func TestAddReportHistoryAndSetPreferredDERP(t *testing.T) {
			wantPrevLen: 3,
			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 {
		t.Run(tt.name, func(t *testing.T) {