mirror of
https://github.com/juanfont/headscale.git
synced 2025-08-10 13:46:46 +02:00
notifier: use convenience funcs
Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
This commit is contained in:
parent
b9868f6516
commit
388bf5c7b9
@ -10,6 +10,8 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"slices"
|
||||||
|
|
||||||
"github.com/google/go-cmp/cmp"
|
"github.com/google/go-cmp/cmp"
|
||||||
"github.com/juanfont/headscale/hscontrol/types"
|
"github.com/juanfont/headscale/hscontrol/types"
|
||||||
"github.com/juanfont/headscale/hscontrol/util"
|
"github.com/juanfont/headscale/hscontrol/util"
|
||||||
@ -252,9 +254,7 @@ func TestBatcher(t *testing.T) {
|
|||||||
|
|
||||||
// Make the inner order stable for comparison.
|
// Make the inner order stable for comparison.
|
||||||
for _, u := range got {
|
for _, u := range got {
|
||||||
sort.Slice(u.ChangeNodes, func(i, j int) bool {
|
slices.Sort(u.ChangeNodes)
|
||||||
return u.ChangeNodes[i] < u.ChangeNodes[j]
|
|
||||||
})
|
|
||||||
sort.Slice(u.ChangePatches, func(i, j int) bool {
|
sort.Slice(u.ChangePatches, func(i, j int) bool {
|
||||||
return u.ChangePatches[i].NodeID < u.ChangePatches[j].NodeID
|
return u.ChangePatches[i].NodeID < u.ChangePatches[j].NodeID
|
||||||
})
|
})
|
||||||
@ -301,11 +301,11 @@ func TestIsLikelyConnectedRaceCondition(t *testing.T) {
|
|||||||
|
|
||||||
// Start goroutines to cause a race
|
// Start goroutines to cause a race
|
||||||
wg.Add(concurrentAccessors)
|
wg.Add(concurrentAccessors)
|
||||||
for i := 0; i < concurrentAccessors; i++ {
|
for i := range concurrentAccessors {
|
||||||
go func(routineID int) {
|
go func(routineID int) {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
|
|
||||||
for j := 0; j < iterations; j++ {
|
for range iterations {
|
||||||
// Simulate race by having some goroutines check IsLikelyConnected
|
// Simulate race by having some goroutines check IsLikelyConnected
|
||||||
// while others add/remove the node
|
// while others add/remove the node
|
||||||
if routineID%3 == 0 {
|
if routineID%3 == 0 {
|
||||||
|
Loading…
Reference in New Issue
Block a user