mirror of
https://github.com/tailscale/tailscale.git
synced 2026-04-04 06:36:01 -04:00
Added good integration tests for PingRequest addition
This commit is contained in:
@@ -784,9 +784,24 @@ func TestControlSelectivePing(t *testing.T) {
|
||||
n1.AwaitRunning(t)
|
||||
n2.AwaitRunning(t)
|
||||
|
||||
t.Log("CONTROLURL", env.ControlServer.URL)
|
||||
req := new(tailcfg.MapRequest)
|
||||
req.Ping = true
|
||||
t.Log("NEWREQ", req)
|
||||
|
||||
env.Control.MapResponse(req)
|
||||
if err := tstest.WaitFor(2*time.Second, func() error {
|
||||
st := n1.MustStatus(t)
|
||||
req.NodeKey = tailcfg.NodeKey(st.Self.PublicKey)
|
||||
return nil
|
||||
}); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
mr, err := env.Control.MapResponse(req)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
t.Log("RECEIVED PR", mr.PingRequest)
|
||||
if mr.PingRequest == nil {
|
||||
t.Error("PingRequest does not exist")
|
||||
}
|
||||
d1.MustCleanShutdown(t)
|
||||
d2.MustCleanShutdown(t)
|
||||
}
|
||||
|
||||
@@ -570,11 +570,12 @@ func (s *Server) MapResponse(req *tailcfg.MapRequest) (res *tailcfg.MapResponse,
|
||||
res.Node.AllowedIPs = res.Node.Addresses
|
||||
|
||||
// Function to add a PingRequest to one of its Peers to the MapResponse
|
||||
err = s.addPingRequest(res)
|
||||
if err != nil {
|
||||
log.Println("ADDPINGREQ ERROR", err)
|
||||
if req.Ping {
|
||||
err = s.addPingRequest(res)
|
||||
if err != nil {
|
||||
log.Println("ADDPINGREQ ERROR", err)
|
||||
}
|
||||
}
|
||||
|
||||
return res, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user