From cbbf9fbdefc2f94bbf6558d10f20a279b78ee2c0 Mon Sep 17 00:00:00 2001 From: Kristoffer Dalby Date: Fri, 21 Oct 2022 17:44:40 +0200 Subject: [PATCH] Use FQDN from tailscale client Signed-off-by: Kristoffer Dalby --- integration/general_test.go | 24 +++++++++++++++++------- integration/tsic/tsic.go | 9 +++++++++ 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/integration/general_test.go b/integration/general_test.go index ba000b58..183f6615 100644 --- a/integration/general_test.go +++ b/integration/general_test.go @@ -69,10 +69,10 @@ func TestPingAllByIP(t *testing.T) { t.Logf("%d successful pings out of %d", success, len(allClients)*len(allIps)) - // err = scenario.Shutdown() - // if err != nil { - // t.Errorf("failed to tear down scenario: %s", err) - // } + err = scenario.Shutdown() + if err != nil { + t.Errorf("failed to tear down scenario: %s", err) + } } func TestPingAllByHostname(t *testing.T) { @@ -94,6 +94,7 @@ func TestPingAllByHostname(t *testing.T) { } var allClients []*tsic.TailscaleInContainer + var allHostnames []string for namespace := range spec { clients, err := scenario.GetClients(namespace) @@ -109,13 +110,22 @@ func TestPingAllByHostname(t *testing.T) { t.Errorf("failed wait for tailscale clients to be in sync: %s", err) } + for _, client := range allClients { + fqdn, err := client.FQDN() + if err != nil { + t.Errorf("failed to get fqdn of client %s: %s", t.Name(), err) + } + + allHostnames = append(allHostnames, fqdn) + } + success := 0 for _, client := range allClients { - for _, peer := range allClients { - err := client.Ping(peer.Hostname) + for _, hostname := range allHostnames { + err := client.Ping(hostname) if err != nil { - t.Errorf("failed to ping %s from %s: %s", peer.Hostname, client.Hostname, err) + t.Errorf("failed to ping %s from %s: %s", hostname, client.Hostname, err) } else { success++ } diff --git a/integration/tsic/tsic.go b/integration/tsic/tsic.go index 1cdc3711..d62ea1de 100644 --- a/integration/tsic/tsic.go +++ b/integration/tsic/tsic.go @@ -204,6 +204,15 @@ func (t *TailscaleInContainer) Status() (*ipnstate.Status, error) { return &status, err } +func (t *TailscaleInContainer) FQDN() (string, error) { + status, err := t.Status() + if err != nil { + return "", fmt.Errorf("failed to get FQDN: %w", err) + } + + return status.Self.DNSName, nil +} + func (t *TailscaleInContainer) WaitForPeers(expected int) error { return t.pool.Retry(func() error { status, err := t.Status()