File tree Expand file tree Collapse file tree 2 files changed +24
-7
lines changed Expand file tree Collapse file tree 2 files changed +24
-7
lines changed Original file line number Diff line number Diff line change @@ -473,13 +473,14 @@ func TestAgent(t *testing.T) {
473
473
t .Run ("Tailnet" , func (t * testing.T ) {
474
474
t .Parallel ()
475
475
derpMap := tailnettest .RunDERPAndSTUN (t )
476
- conn := setupSSHSession (t , agent.Metadata {
476
+ conn := setupAgent (t , agent.Metadata {
477
477
DERPMap : derpMap ,
478
- })
478
+ }, 0 )
479
479
defer conn .Close ()
480
- output , err := conn .CombinedOutput ("echo test" )
481
- require .NoError (t , err )
482
- t .Log (string (output ))
480
+ require .Eventually (t , func () bool {
481
+ _ , err := conn .Ping ()
482
+ return err == nil
483
+ }, testutil .WaitMedium , testutil .IntervalFast )
483
484
})
484
485
}
485
486
Original file line number Diff line number Diff line change @@ -15,6 +15,8 @@ import (
15
15
16
16
"golang.org/x/crypto/ssh"
17
17
"golang.org/x/xerrors"
18
+ "tailscale.com/ipn/ipnstate"
19
+ "tailscale.com/tailcfg"
18
20
19
21
"github.com/coder/coder/peer"
20
22
"github.com/coder/coder/peerbroker/proto"
@@ -139,8 +141,22 @@ type TailnetConn struct {
139
141
* tailnet.Conn
140
142
}
141
143
142
- func (* TailnetConn ) Ping () (time.Duration , error ) {
143
- return 0 , nil
144
+ func (c * TailnetConn ) Ping () (time.Duration , error ) {
145
+ errCh := make (chan error , 1 )
146
+ durCh := make (chan time.Duration , 1 )
147
+ c .Conn .Ping (tailnetIP , tailcfg .PingICMP , func (pr * ipnstate.PingResult ) {
148
+ if pr .Err != "" {
149
+ errCh <- xerrors .New (pr .Err )
150
+ return
151
+ }
152
+ durCh <- time .Duration (pr .LatencySeconds * float64 (time .Second ))
153
+ })
154
+ select {
155
+ case err := <- errCh :
156
+ return 0 , err
157
+ case dur := <- durCh :
158
+ return dur , nil
159
+ }
144
160
}
145
161
146
162
func (c * TailnetConn ) CloseWithError (_ error ) error {
You can’t perform that action at this time.
0 commit comments