diff --git a/integration/tailscale.go b/integration/tailscale.go index 298817e3..aaf57aea 100644 --- a/integration/tailscale.go +++ b/integration/tailscale.go @@ -15,6 +15,7 @@ type TailscaleClient interface { IPs() ([]netip.Addr, error) FQDN() (string, error) Status() (*ipnstate.Status, error) + WaitForReady() error WaitForPeers(expected int) error Ping(hostnameOrIP string) error } diff --git a/integration/tsic/tsic.go b/integration/tsic/tsic.go index 14c627d4..2984ad45 100644 --- a/integration/tsic/tsic.go +++ b/integration/tsic/tsic.go @@ -25,6 +25,7 @@ var ( errTailscalePingFailed = errors.New("ping failed") errTailscaleNotLoggedIn = errors.New("tailscale not logged in") errTailscaleWrongPeerCount = errors.New("wrong peer count") + errTailscaleNotConnected = errors.New("tailscale not connected") ) type TailscaleInContainer struct { @@ -222,6 +223,21 @@ func (t *TailscaleInContainer) FQDN() (string, error) { return status.Self.DNSName, nil } +func (t *TailscaleInContainer) WaitForReady() error { + return t.pool.Retry(func() error { + status, err := t.Status() + if err != nil { + return fmt.Errorf("failed to fetch tailscale status: %w", err) + } + + if status.CurrentTailnet != nil { + return nil + } + + return errTailscaleNotConnected + }) +} + func (t *TailscaleInContainer) WaitForPeers(expected int) error { return t.pool.Retry(func() error { status, err := t.Status()