diff --git a/integration_common_test.go b/integration_common_test.go index a7b948bb..fa848aef 100644 --- a/integration_common_test.go +++ b/integration_common_test.go @@ -248,3 +248,37 @@ func getDNSNames( return hostnames, nil } + +func getMagicFQDN( + headscale *dockertest.Resource, +) ([]string, error) { + + listAllResult, err := ExecuteCommand( + headscale, + []string{ + "headscale", + "nodes", + "list", + "--output", + "json", + }, + []string{}, + ) + if err != nil { + return nil, err + } + + var listAll []v1.Machine + err = json.Unmarshal([]byte(listAllResult), &listAll) + if err != nil { + return nil, err + } + + hostnames := make([]string, len(listAll)) + + for index := range listAll { + hostnames[index] = fmt.Sprintf("%s.%s.headscale.net", listAll[index].GetGivenName(), listAll[index].GetNamespace().GetName()) + } + + return hostnames, nil +} diff --git a/integration_test.go b/integration_test.go index d1fb8877..124b458c 100644 --- a/integration_test.go +++ b/integration_test.go @@ -636,11 +636,13 @@ func (s *IntegrationTestSuite) TestPingAllPeersByHostname() { } func (s *IntegrationTestSuite) TestMagicDNS() { - for namespace, scales := range s.namespaces { - ips, err := getIPs(scales.tailscales) - assert.Nil(s.T(), err) + hostnames, err := getMagicFQDN(&s.headscale) + assert.Nil(s.T(), err) - hostnames, err := getDNSNames(&s.headscale) + log.Printf("Resolved hostnames: %#v", hostnames) + + for _, scales := range s.namespaces { + ips, err := getIPs(scales.tailscales) assert.Nil(s.T(), err) for hostname, tailscale := range scales.tailscales { @@ -648,10 +650,10 @@ func (s *IntegrationTestSuite) TestMagicDNS() { if strings.Contains(peername, hostname) { continue } + s.T().Run(fmt.Sprintf("%s-%s", hostname, peername), func(t *testing.T) { command := []string{ - "tailscale", "ip", - fmt.Sprintf("%s.%s.headscale.net", peername, namespace), + "tailscale", "ip", peername, } log.Printf(