mirror of
https://github.com/tailscale/tailscale.git
synced 2025-08-14 23:17:29 +00:00
cmd/derpprobe,prober: add ability to restrict derpprobe to a single region
Updates #24522 Co-authored-by: Mario Minardi <mario@tailscale.com> Signed-off-by: Percy Wegmann <percy@tailscale.com>
This commit is contained in:

committed by
Percy Wegmann

parent
c3c4c05331
commit
1355f622be
@@ -44,6 +44,19 @@ func TestDerpProber(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
1: {
|
||||
RegionID: 1,
|
||||
RegionCode: "one",
|
||||
Nodes: []*tailcfg.DERPNode{
|
||||
{
|
||||
Name: "n3",
|
||||
RegionID: 0,
|
||||
HostName: "derpn3.tailscale.test",
|
||||
IPv4: "1.1.1.1",
|
||||
IPv6: "::1",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -68,6 +81,7 @@ func TestDerpProber(t *testing.T) {
|
||||
meshProbeFn: func(_, _ string) ProbeClass { return FuncProbe(func(context.Context) error { return nil }) },
|
||||
nodes: make(map[string]*tailcfg.DERPNode),
|
||||
probes: make(map[string]*Probe),
|
||||
regionCode: "zero",
|
||||
}
|
||||
if err := dp.probeMapFn(context.Background()); err != nil {
|
||||
t.Errorf("unexpected probeMapFn() error: %s", err)
|
||||
@@ -84,9 +98,9 @@ func TestDerpProber(t *testing.T) {
|
||||
|
||||
// Add one more node and check that probes got created.
|
||||
dm.Regions[0].Nodes = append(dm.Regions[0].Nodes, &tailcfg.DERPNode{
|
||||
Name: "n3",
|
||||
Name: "n4",
|
||||
RegionID: 0,
|
||||
HostName: "derpn3.tailscale.test",
|
||||
HostName: "derpn4.tailscale.test",
|
||||
IPv4: "1.1.1.1",
|
||||
IPv6: "::1",
|
||||
})
|
||||
@@ -113,6 +127,19 @@ func TestDerpProber(t *testing.T) {
|
||||
if len(dp.probes) != 4 {
|
||||
t.Errorf("unexpected probes: %+v", dp.probes)
|
||||
}
|
||||
|
||||
// Stop filtering regions.
|
||||
dp.regionCode = ""
|
||||
if err := dp.probeMapFn(context.Background()); err != nil {
|
||||
t.Errorf("unexpected probeMapFn() error: %s", err)
|
||||
}
|
||||
if len(dp.nodes) != 2 {
|
||||
t.Errorf("unexpected nodes: %+v", dp.nodes)
|
||||
}
|
||||
// 6 regular probes + 2 mesh probe
|
||||
if len(dp.probes) != 8 {
|
||||
t.Errorf("unexpected probes: %+v", dp.probes)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRunDerpProbeNodePair(t *testing.T) {
|
||||
|
Reference in New Issue
Block a user