mirror of
https://github.com/netbirdio/netbird.git
synced 2024-11-29 19:43:57 +01:00
0eb99c266a
The cleanup loop did not manage those situations well when a connection failed or the connection success but the code did not add a peer connection to it yet. - in the cleanup loop check if a connection failed to a server - after adding a foreign server connection force to keep it a minimum 5 sec
31 lines
545 B
Go
31 lines
545 B
Go
package client
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"testing"
|
|
)
|
|
|
|
func TestServerPicker_UnavailableServers(t *testing.T) {
|
|
sp := ServerPicker{
|
|
TokenStore: nil,
|
|
PeerID: "test",
|
|
}
|
|
|
|
ctx, cancel := context.WithTimeout(context.Background(), connectionTimeout+1)
|
|
defer cancel()
|
|
|
|
go func() {
|
|
_, err := sp.PickServer(ctx, []string{"rel://dummy1", "rel://dummy2"})
|
|
if err == nil {
|
|
t.Error(err)
|
|
}
|
|
cancel()
|
|
}()
|
|
|
|
<-ctx.Done()
|
|
if errors.Is(ctx.Err(), context.DeadlineExceeded) {
|
|
t.Errorf("PickServer() took too long to complete")
|
|
}
|
|
}
|