Skip to content

Commit

Permalink
Use FQDN from tailscale client
Browse files Browse the repository at this point in the history
Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
  • Loading branch information
kradalby committed Oct 23, 2022
1 parent d8144ee commit cbbf9fb
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
24 changes: 17 additions & 7 deletions integration/general_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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)
Expand All @@ -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++
}
Expand Down
9 changes: 9 additions & 0 deletions integration/tsic/tsic.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit cbbf9fb

Please sign in to comment.