Test magic dns with the correct urls
This commit is contained in:
parent
4a9d3bedf9
commit
77ceeaf5fd
2 changed files with 42 additions and 6 deletions
|
@ -248,3 +248,37 @@ func getDNSNames(
|
||||||
|
|
||||||
return hostnames, nil
|
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
|
||||||
|
}
|
||||||
|
|
|
@ -636,11 +636,13 @@ func (s *IntegrationTestSuite) TestPingAllPeersByHostname() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *IntegrationTestSuite) TestMagicDNS() {
|
func (s *IntegrationTestSuite) TestMagicDNS() {
|
||||||
for namespace, scales := range s.namespaces {
|
hostnames, err := getMagicFQDN(&s.headscale)
|
||||||
ips, err := getIPs(scales.tailscales)
|
assert.Nil(s.T(), err)
|
||||||
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)
|
assert.Nil(s.T(), err)
|
||||||
|
|
||||||
for hostname, tailscale := range scales.tailscales {
|
for hostname, tailscale := range scales.tailscales {
|
||||||
|
@ -648,10 +650,10 @@ func (s *IntegrationTestSuite) TestMagicDNS() {
|
||||||
if strings.Contains(peername, hostname) {
|
if strings.Contains(peername, hostname) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
s.T().Run(fmt.Sprintf("%s-%s", hostname, peername), func(t *testing.T) {
|
s.T().Run(fmt.Sprintf("%s-%s", hostname, peername), func(t *testing.T) {
|
||||||
command := []string{
|
command := []string{
|
||||||
"tailscale", "ip",
|
"tailscale", "ip", peername,
|
||||||
fmt.Sprintf("%s.%s.headscale.net", peername, namespace),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf(
|
log.Printf(
|
||||||
|
|
Loading…
Reference in a new issue