mirror of
https://github.com/netbirdio/netbird.git
synced 2026-10-30 08:19:09 +01:00
[client] Assert the sync response is dropped for the right reason
Start returns before the first sync response necessarily arrives, so the disabled case could pass against a client that had simply not synced yet. Wait for the engine to apply a sync, then require the persistence error rather than any error, so a not-started engine no longer satisfies it. Also document that PeerState is a read-only snapshot which shares its mutex and route map with the recorder.
This commit is contained in:
@@ -233,9 +233,16 @@ func TestClientSyncResponsePersistence(t *testing.T) {
|
||||
}
|
||||
})
|
||||
|
||||
// Start returns before the first sync response necessarily arrives, so
|
||||
// wait for the engine to apply one. Without this the assertion below
|
||||
// could pass on a client that simply has not synced yet.
|
||||
require.Eventually(t, func() bool {
|
||||
return client.StatusSnapshot().LocalPeerState.IP != ""
|
||||
}, 30*time.Second, 200*time.Millisecond, "the initial management sync should be applied")
|
||||
|
||||
if !tc.persisted {
|
||||
_, err := client.GetLatestSyncResponse()
|
||||
require.Error(t, err, "no sync response may be retained when persistence is disabled")
|
||||
require.ErrorContains(t, err, "persistence is disabled", "the sync response must be dropped, not merely unavailable")
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user