diff options
| author | Adrian Dewhurst <adrian@tailscale.com> | 2024-06-03 16:12:12 -0400 |
|---|---|---|
| committer | Adrian Dewhurst <sailor@sailorfrag.net> | 2024-06-03 16:58:25 -0400 |
| commit | 3bf2bddbb58c30d332d78fb64115138d00ba6c09 (patch) | |
| tree | c25fd3f663d8e1550be45759bac87b94c69e056f /control/controlknobs | |
| parent | d21c00205d6af2648a5b2723a234277e281e6dcc (diff) | |
| download | tailscale-3bf2bddbb58c30d332d78fb64115138d00ba6c09.tar.xz tailscale-3bf2bddbb58c30d332d78fb64115138d00ba6c09.zip | |
ipn/ipnlocal: improve testability of random node selection
In order to test the sticky last suggestion code, a test was written for
LocalBackend.SuggestExitNode but it contains a random number generator
which makes writing comprehensive tests very difficult. This doesn't
change how the last suggestion works, but it adds some infrastructure to
make that easier in a later PR.
This adds func parameters for the two randomized parts: breaking ties
between DERP regions and breaking ties between nodes. This way tests can
validate the entire list of tied options, rather than expecting a
particular outcome given a particular random seed.
As a result of this, the global random number generator can be used
rather than seeding a local one each time.
In order to see the tied nodes for the location based (i.e. Mullvad)
case, pickWeighted needed to return a slice instead of a single
arbitrary option, so there is a small change in how that works.
Updates tailscale/corp#19681
Change-Id: I83c48a752abdec0f59c58ccfd8bfb3f3f17d0ea8
Signed-off-by: Adrian Dewhurst <adrian@tailscale.com>
Diffstat (limited to 'control/controlknobs')
0 files changed, 0 insertions, 0 deletions
