mirror of
https://github.com/juanfont/headscale.git
synced 2026-10-24 07:16:49 +09:00
state: return a node's primary routes in stable order
They came from map iteration, so an unchanged router rendered its self node differently on every call. Updates #3502
This commit is contained in:
1 parent
31582dd2c2
commit
ba413fca3d
2 files changed
+25
-1
No files matched your search
@@ -1496,6 +1496,28 @@ func TestHealthOnlyWriteReusesPeerMap(t *testing.T) {
|
||||
peersCalls.Load())
|
||||
}
|
||||
|
||||
// TestPrimaryRoutesForNodeSorted checks a router's primaries come back in
|
||||
// a stable order: they render into its self node, which the mapper resends
|
||||
// whenever it differs from what the node holds (issue #3502).
|
||||
func TestPrimaryRoutesForNodeSorted(t *testing.T) {
|
||||
node := createTestNode(1, 1, "user1", "router")
|
||||
|
||||
prefixes := make([]netip.Prefix, 0, 8)
|
||||
for i := range 8 {
|
||||
prefixes = append(prefixes, netip.PrefixFrom(netip.AddrFrom4([4]byte{10, byte(i), 0, 0}), 16))
|
||||
}
|
||||
|
||||
node.Hostinfo = &tailcfg.Hostinfo{Hostname: "router", RoutableIPs: prefixes}
|
||||
node.ApprovedRoutes = prefixes
|
||||
node.IsOnline = new(true)
|
||||
|
||||
store := NewNodeStore(types.Nodes{&node}, allowAllPeersFunc, TestBatchSize, TestBatchTimeout)
|
||||
|
||||
for range 20 {
|
||||
require.Equal(t, prefixes, store.PrimaryRoutesForNode(1))
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkSnapshotPayloadDense(b *testing.B) {
|
||||
const nodeCount = 500
|
||||
|
||||
|
||||
Reference in new issue
Block a user