mirror of
https://github.com/tailscale/tailscale.git
synced 2025-02-27 02:37:38 +00:00
[WIP] magicsock: infinite ping test
Run this for ~2 minutes to see the connection fail and not recover.
This commit is contained in:
parent
07106e9898
commit
bdc894fc4c
@ -772,6 +772,9 @@ func (c *Conn) ReceiveIPv4(b []byte) (n int, ep conn.Endpoint, addr *net.UDPAddr
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DERP always wins in tests
|
||||||
|
//time.Sleep(100 * time.Millisecond)
|
||||||
|
|
||||||
addr := pAddr.(*net.UDPAddr)
|
addr := pAddr.(*net.UDPAddr)
|
||||||
addr.IP = addr.IP.To4()
|
addr.IP = addr.IP.To4()
|
||||||
select {
|
select {
|
||||||
|
@ -13,6 +13,7 @@ import (
|
|||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"testing"
|
"testing"
|
||||||
@ -519,4 +520,70 @@ func TestTwoDevicePing(t *testing.T) {
|
|||||||
t.Error("handshake spray failed to find real route")
|
t.Error("handshake spray failed to find real route")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
//cfgs[0] = *dev1.Config()
|
||||||
|
//cfgs[1] = *dev2.Config()
|
||||||
|
|
||||||
|
// Start collecting endpoint updates and Reconfig'ing using them.
|
||||||
|
var cfgsMu sync.Mutex
|
||||||
|
go func() {
|
||||||
|
for epstrs := range epCh1 {
|
||||||
|
eps := append([]wgcfg.Endpoint{derpEp}, makeEps(epstrs)...)
|
||||||
|
//eps[2].Port = 1111
|
||||||
|
|
||||||
|
old := dev2.Config().Peers[0].Endpoints
|
||||||
|
log.Printf("dev2: replacing %v with %v", old, eps)
|
||||||
|
|
||||||
|
cfgsMu.Lock()
|
||||||
|
cfgs[1].Peers[0].Endpoints = eps
|
||||||
|
if err := dev2.Reconfig(&cfgs[1]); err != nil {
|
||||||
|
log.Printf("dev2.Reconfig: %v", err)
|
||||||
|
}
|
||||||
|
cfgsMu.Unlock()
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
go func() {
|
||||||
|
for epstrs := range epCh2 {
|
||||||
|
eps := append([]wgcfg.Endpoint{derpEp}, makeEps(epstrs)...)
|
||||||
|
//eps[2].Port = 1111
|
||||||
|
|
||||||
|
old := dev1.Config().Peers[0].Endpoints
|
||||||
|
log.Printf("dev1: replacing %v with %v", old, eps)
|
||||||
|
|
||||||
|
cfgsMu.Lock()
|
||||||
|
cfgs[0].Peers[0].Endpoints = eps
|
||||||
|
if err := dev1.Reconfig(&cfgs[0]); err != nil {
|
||||||
|
log.Printf("dev1.Reconfig: %v", err)
|
||||||
|
}
|
||||||
|
cfgsMu.Unlock()
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
t.Run("infping", func(t *testing.T) {
|
||||||
|
//t.Skipf("used for manual testing only")
|
||||||
|
for i := 0; true; i++ {
|
||||||
|
t.Logf("long running ping %v", time.Now())
|
||||||
|
ping1(t)
|
||||||
|
ping2(t)
|
||||||
|
time.Sleep(1 * time.Second)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func makeEps(epstrs []string) (eps []wgcfg.Endpoint) {
|
||||||
|
for _, str := range epstrs {
|
||||||
|
host, port, err := net.SplitHostPort(str)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("bad endpoint %q: %v", str, err)
|
||||||
|
}
|
||||||
|
portNum, err := strconv.Atoi(port)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("bad endpoint port %q: %v", str, err)
|
||||||
|
}
|
||||||
|
eps = append(eps, wgcfg.Endpoint{
|
||||||
|
Host: host,
|
||||||
|
Port: uint16(portNum),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return eps
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user