Use FQDN from tailscale client

Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
This commit is contained in:
Kristoffer Dalby 2022-10-21 17:44:40 +02:00
parent d8144ee2ed
commit cbbf9fbdef
No known key found for this signature in database
2 changed files with 26 additions and 7 deletions

View File

@ -69,10 +69,10 @@ func TestPingAllByIP(t *testing.T) {
t.Logf("%d successful pings out of %d", success, len(allClients)*len(allIps)) t.Logf("%d successful pings out of %d", success, len(allClients)*len(allIps))
// err = scenario.Shutdown() err = scenario.Shutdown()
// if err != nil { if err != nil {
// t.Errorf("failed to tear down scenario: %s", err) t.Errorf("failed to tear down scenario: %s", err)
// } }
} }
func TestPingAllByHostname(t *testing.T) { func TestPingAllByHostname(t *testing.T) {
@ -94,6 +94,7 @@ func TestPingAllByHostname(t *testing.T) {
} }
var allClients []*tsic.TailscaleInContainer var allClients []*tsic.TailscaleInContainer
var allHostnames []string
for namespace := range spec { for namespace := range spec {
clients, err := scenario.GetClients(namespace) 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) 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 success := 0
for _, client := range allClients { for _, client := range allClients {
for _, peer := range allClients { for _, hostname := range allHostnames {
err := client.Ping(peer.Hostname) err := client.Ping(hostname)
if err != nil { 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 { } else {
success++ success++
} }

View File

@ -204,6 +204,15 @@ func (t *TailscaleInContainer) Status() (*ipnstate.Status, error) {
return &status, err 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 { func (t *TailscaleInContainer) WaitForPeers(expected int) error {
return t.pool.Retry(func() error { return t.pool.Retry(func() error {
status, err := t.Status() status, err := t.Status()