diff --git a/integration/tailscale.go b/integration/tailscale.go index 01004c3f..6b51193a 100644 --- a/integration/tailscale.go +++ b/integration/tailscale.go @@ -17,6 +17,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 0f1d9c85..5f11a543 100644 --- a/integration/tsic/tsic.go +++ b/integration/tsic/tsic.go @@ -26,6 +26,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 { @@ -252,6 +253,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()