mirror of
https://github.com/fleetdm/fleet
synced 2026-05-17 05:58:40 +00:00
For #26713 # Details This PR updates Fleet and its related tools and binaries to use Go version 1.24.1. Scanning through the changelog, I didn't see anything relevant to Fleet that requires action. The only possible breaking change I spotted was: > As [announced](https://tip.golang.org/doc/go1.23#linux) in the Go 1.23 release notes, Go 1.24 requires Linux kernel version 3.2 or later. Linux kernel 3.2 was released in January of 2012, so I think we can commit to dropping support for earlier kernel versions. The new [tools directive](https://tip.golang.org/doc/go1.24#tools) is interesting as it means we can move away from using `tools.go` files, but it's not a required update. # Checklist for submitter If some of the following don't apply, delete the relevant line. <!-- Note that API documentation changes are now addressed by the product design team. --> - [X] Changes file added for user-visible changes in `changes/`, `orbit/changes/` or `ee/fleetd-chrome/changes`. - [x] Manual QA for all new/changed functionality - For Orbit and Fleet Desktop changes: - [X] Make sure fleetd is compatible with the latest released version of Fleet - [x] Orbit runs on macOS ✅ , Linux ✅ and Windows. - [x] Manual QA must be performed in the three main OSs, macOS ✅, Windows and Linux ✅.
52 lines
1.3 KiB
Go
52 lines
1.3 KiB
Go
package service
|
|
|
|
import (
|
|
crand "crypto/rand"
|
|
"math"
|
|
"math/big"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestJitterForHost(t *testing.T) {
|
|
jh := newJitterHashTable(30)
|
|
|
|
histogram := make(map[int64]int)
|
|
hostCount := 3000
|
|
for i := 0; i < hostCount; i++ {
|
|
hostID, err := crand.Int(crand.Reader, big.NewInt(10000))
|
|
require.NoError(t, err)
|
|
jitter := jh.jitterForHost(uint(hostID.Int64() + 10000)) //nolint:gosec // dismiss G115
|
|
jitterMinutes := int64(jitter.Minutes())
|
|
histogram[jitterMinutes]++
|
|
}
|
|
minVal, maxVal := math.MaxInt, 0
|
|
for jitterMinutes, count := range histogram {
|
|
if count < minVal {
|
|
minVal = count
|
|
}
|
|
if count > maxVal {
|
|
maxVal = count
|
|
}
|
|
t.Logf("jitterMinutes=%d \t count=%d\n", jitterMinutes, count)
|
|
}
|
|
variation := maxVal - minVal
|
|
t.Logf("min=%d \t max=%d \t variation=%d\n", minVal, maxVal, variation)
|
|
|
|
// check that variation is below 1% of the total amount of hosts
|
|
require.Less(t, variation, int(float32(hostCount)/0.01))
|
|
}
|
|
|
|
func TestNoJitter(t *testing.T) {
|
|
jh := newJitterHashTable(0)
|
|
|
|
hostCount := 3000
|
|
for i := 0; i < hostCount; i++ {
|
|
hostID, err := crand.Int(crand.Reader, big.NewInt(10000))
|
|
require.NoError(t, err)
|
|
jitter := jh.jitterForHost(uint(hostID.Int64() + 10000)) //nolint:gosec // dismiss G115
|
|
jitterMinutes := int64(jitter.Minutes())
|
|
require.Equal(t, int64(0), jitterMinutes)
|
|
}
|
|
}
|