mirror of
https://github.com/fleetdm/fleet
synced 2026-05-21 16:08:47 +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 ✅.
71 lines
1.6 KiB
Go
71 lines
1.6 KiB
Go
package retry
|
|
|
|
import (
|
|
"errors"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
var errTest = errors.New("test error")
|
|
|
|
func TestRetryDo(t *testing.T) {
|
|
t.Run("WithMaxAttempts only performs the operation the configured number of times", func(t *testing.T) {
|
|
count := 0
|
|
maxAttempts := 3
|
|
|
|
err := Do(func() error {
|
|
count++
|
|
return errTest
|
|
}, WithMaxAttempts(maxAttempts), WithInterval(1*time.Millisecond))
|
|
|
|
require.ErrorIs(t, errTest, err)
|
|
require.Equal(t, maxAttempts, count)
|
|
})
|
|
|
|
t.Run("operations are run an unlimited number of times by default", func(t *testing.T) {
|
|
count := 0
|
|
maxAttempts := 10
|
|
|
|
err := Do(func() error {
|
|
if count++; count != maxAttempts {
|
|
return errTest
|
|
}
|
|
return nil
|
|
}, WithInterval(1*time.Millisecond))
|
|
|
|
require.NoError(t, err)
|
|
require.Equal(t, maxAttempts, count)
|
|
})
|
|
|
|
t.Run("with backoff", func(t *testing.T) {
|
|
count := 0
|
|
maxAttempts := 4
|
|
start := time.Now()
|
|
err := Do(func() error {
|
|
switch count {
|
|
case 0:
|
|
require.WithinDuration(t, start, time.Now(), 1*time.Millisecond)
|
|
case 1:
|
|
require.WithinDuration(t, start.Add(50*time.Millisecond), time.Now(), 10*time.Millisecond)
|
|
case 2:
|
|
require.WithinDuration(t, start.Add((50+100)*time.Millisecond), time.Now(), 10*time.Millisecond)
|
|
case 3:
|
|
require.WithinDuration(t, start.Add((50+100+200)*time.Millisecond), time.Now(), 10*time.Millisecond)
|
|
}
|
|
count++
|
|
if count != maxAttempts {
|
|
return errTest
|
|
}
|
|
return nil
|
|
},
|
|
WithInterval(50*time.Millisecond),
|
|
WithBackoffMultiplier(2),
|
|
WithMaxAttempts(4),
|
|
)
|
|
|
|
require.NoError(t, err)
|
|
require.Equal(t, maxAttempts, count)
|
|
})
|
|
}
|