diff --git a/integration/tailscale.go b/integration/tailscale.go index 0ae52eae..166b851f 100644 --- a/integration/tailscale.go +++ b/integration/tailscale.go @@ -25,7 +25,6 @@ type TailscaleClient interface { WaitForLogout() error WaitForPeers(expected int) error Ping(hostnameOrIP string, opts ...tsic.PingOption) error - PingViaDERP(hostnameOrIP string, opts ...tsic.PingOption) error Curl(url string, opts ...tsic.CurlOption) (string, error) ID() string } diff --git a/integration/tsic/tsic.go b/integration/tsic/tsic.go index 28d5d06a..52a3ff38 100644 --- a/integration/tsic/tsic.go +++ b/integration/tsic/tsic.go @@ -545,49 +545,6 @@ func (t *TailscaleInContainer) Ping(hostnameOrIP string, opts ...PingOption) err command = append(command, hostnameOrIP) - return t.pool.Retry(func() error { - result, _, err := t.Execute(command) - if err != nil { - log.Printf( - "failed to run ping command from %s to %s, err: %s", - t.Hostname(), - hostnameOrIP, - err, - ) - - return err - } - - if !strings.Contains(result, "pong") && !strings.Contains(result, "is local") { - return backoff.Permanent(errTailscalePingFailed) - } - - return nil - }) -} - -// PingViaDERP executes the Tailscale ping command and pings a hostname -// or IP via the DERP network (i.e., not a direct connection). It accepts a series of DERPPingOption. -// TODO(kradalby): Make multiping, go routine magic. -func (t *TailscaleInContainer) PingViaDERP(hostnameOrIP string, opts ...PingOption) error { - args := pingArgs{ - timeout: time.Second, - count: defaultPingCount, - } - - for _, opt := range opts { - opt(&args) - } - - command := []string{ - "tailscale", "ping", - fmt.Sprintf("--timeout=%s", args.timeout), - fmt.Sprintf("--c=%d", args.count), - "--until-direct=false", - } - - command = append(command, hostnameOrIP) - return t.pool.Retry(func() error { result, _, err := t.Execute( command, @@ -614,8 +571,12 @@ func (t *TailscaleInContainer) PingViaDERP(hostnameOrIP string, opts ...PingOpti return backoff.Permanent(errTailscalePingFailed) } - if !strings.Contains(result, "via DERP") { - return backoff.Permanent(errTailscalePingNotDERP) + if !args.direct { + if strings.Contains(result, "via DERP") { + return nil + } else { + return backoff.Permanent(errTailscalePingNotDERP) + } } return nil diff --git a/integration/utils.go b/integration/utils.go index 907c5456..2ed3e3e7 100644 --- a/integration/utils.go +++ b/integration/utils.go @@ -40,10 +40,11 @@ func pingDerpAllHelper(t *testing.T, clients []TailscaleClient, addrs []string) continue } - err := client.PingViaDERP( + err := client.Ping( addr, tsic.WithPingTimeout(derpPingTimeout), tsic.WithPingCount(derpPingCount), + tsic.WithPingUntilDirect(false), ) if err != nil { t.Errorf("failed to ping %s from %s: %s", addr, client.Hostname(), err)