/
dns.go
84 lines (75 loc) · 2.18 KB
/
dns.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
package common
import (
"context"
"fmt"
"net"
"time"
"github.com/giantswarm/clustertest/pkg/application"
"github.com/giantswarm/clustertest/pkg/logger"
"github.com/giantswarm/clustertest/pkg/wait"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/giantswarm/cluster-test-suites/internal/state"
)
func runDNS(bastionSuppoted bool) {
Context("dns", func() {
var (
resolver *net.Resolver
values *application.DefaultAppsValues
)
getARecords := func(domain string) ([]net.IP, error) {
records, err := resolver.LookupIP(context.Background(), "ip", domain)
if err != nil {
logger.Log("domain %s still not available", domain)
return nil, err
}
logger.Log("resolved domain %s to %+v", domain, records)
return records, nil
}
BeforeEach(func() {
values = &application.DefaultAppsValues{}
defaultAppsName := fmt.Sprintf("%s-default-apps", state.GetCluster().Name)
err := state.GetFramework().MC().GetHelmValues(defaultAppsName, state.GetCluster().GetNamespace(), values)
Expect(err).NotTo(HaveOccurred())
resolver = &net.Resolver{
PreferGo: true,
StrictErrors: true,
Dial: func(ctx context.Context, network, address string) (net.Conn, error) {
d := net.Dialer{
Timeout: time.Millisecond * time.Duration(10000),
}
return d.DialContext(ctx, "udp", "8.8.4.4:53")
},
}
})
It("sets up the api DNS records", func() {
apiDomain := fmt.Sprintf("api.%s", values.BaseDomain)
var records []net.IP
Eventually(func() error {
var err error
records, err = getARecords(apiDomain)
return err
}).
WithTimeout(5 * time.Minute).
WithPolling(wait.DefaultInterval).
Should(Succeed())
Expect(records).ToNot(BeEmpty())
})
It("sets up the bastion DNS records", func() {
if !bastionSuppoted {
Skip("Bastion is not supported.")
}
bastionDomain := fmt.Sprintf("bastion1.%s", values.BaseDomain)
var records []net.IP
Eventually(func() error {
var err error
records, err = getARecords(bastionDomain)
return err
}).
WithTimeout(5 * time.Minute).
WithPolling(wait.DefaultInterval).
Should(Succeed())
Expect(records).ToNot(BeEmpty())
})
})
}