From 49de23cf1bae372996de797d86ced771ed314756 Mon Sep 17 00:00:00 2001 From: Jordan Whited Date: Thu, 31 Oct 2024 19:25:00 -0700 Subject: [PATCH] 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 --- net/netcheck/netcheck_test.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/net/netcheck/netcheck_test.go b/net/netcheck/netcheck_test.go index f287978d2..b4fbb4023 100644 --- a/net/netcheck/netcheck_test.go +++ b/net/netcheck/netcheck_test.go @@ -357,6 +357,15 @@ type step struct { 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) {