mirror of
https://github.com/netbirdio/netbird.git
synced 2026-04-25 19:56:46 +00:00
Refactor sync fast path tests and fix CI flakiness
- Introduce `skipOnWindows` helper to properly skip tests relying on Unix specific paths. - Replace fixed sleep with `require.Eventually` in `waitForPeerDisconnect` to address flakiness in CI. - Split `commitFastPath` logic out of `runFastPathSync` to close race conditions and improve clarity. - Update tests to leverage new helpers and more precise assertions (e.g., `waitForPeerDisconnect`). - Add `flakyStore` test helper to exercise fail-closed behavior in flag handling. - Enhance `RunFastPathFlagRoutine` to disable the flag on store read errors.
This commit is contained in:
@@ -67,6 +67,9 @@ func (f *FastPathFlag) setEnabled(v bool) {
|
||||
// flag is toggled cluster-wide by writing the key in Redis) and falls back to
|
||||
// an in-process gocache otherwise, which is enough for single-replica dev and
|
||||
// test setups.
|
||||
//
|
||||
// The routine fails closed: any store read error (other than a plain "key not
|
||||
// found" miss) disables the flag until Redis confirms it is enabled again.
|
||||
func RunFastPathFlagRoutine(ctx context.Context, cacheStore store.StoreInterface, interval time.Duration, flagKey string) *FastPathFlag {
|
||||
flag := &FastPathFlag{}
|
||||
|
||||
@@ -92,11 +95,10 @@ func RunFastPathFlagRoutine(ctx context.Context, cacheStore store.StoreInterface
|
||||
value, err := flagCache.Get(getCtx, flagKey)
|
||||
if err != nil {
|
||||
var notFound *store.NotFound
|
||||
if errors.As(err, ¬Found) {
|
||||
flag.setEnabled(false)
|
||||
return
|
||||
if !errors.As(err, ¬Found) {
|
||||
log.Errorf("Sync fast-path flag refresh: %v; disabling fast path", err)
|
||||
}
|
||||
log.Debugf("Sync fast-path flag refresh: %v", err)
|
||||
flag.setEnabled(false)
|
||||
return
|
||||
}
|
||||
flag.setEnabled(parseFastPathFlag(value))
|
||||
|
||||
Reference in New Issue
Block a user