Skip to content

Commit 06f1156

Browse files
committed
tests: Splits hostname from DNS test
At the moment, Windows cannot mount individual files into Containers, which means that the Kubelet-managed hosts file cannot be mounted into the Container, causing the "should provide DNS for pods for Hostname and Subdomain" test to fail. The mentioned test has /etc/hosts file entry checks. This commits separates the DNS check and the /etc/hosts checks into two tests.
1 parent 057ad6d commit 06f1156

File tree

1 file changed

+37
-3
lines changed

1 file changed

+37
-3
lines changed

test/e2e/network/dns.go

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ var _ = SIGDescribe("DNS", func() {
219219
validateDNSResults(f, pod, append(wheezyFileNames, jessieFileNames...))
220220
})
221221

222-
It("should provide DNS for pods for Hostname and Subdomain", func() {
222+
It("should provide DNS for pods for Hostname [LinuxOnly]", func() {
223223
// Create a test headless service.
224224
By("Creating a test headless service")
225225
testServiceSelector := map[string]string{
@@ -239,9 +239,43 @@ var _ = SIGDescribe("DNS", func() {
239239

240240
hostFQDN := fmt.Sprintf("%s.%s.%s.svc.%s", podHostname, serviceName, f.Namespace.Name, framework.TestContext.ClusterDNSDomain)
241241
hostNames := []string{hostFQDN, podHostname}
242+
wheezyProbeCmd, wheezyFileNames := createProbeCommand(nil, hostNames, "", "wheezy", f.Namespace.Name, framework.TestContext.ClusterDNSDomain)
243+
jessieProbeCmd, jessieFileNames := createProbeCommand(nil, hostNames, "", "jessie", f.Namespace.Name, framework.TestContext.ClusterDNSDomain)
244+
By("Running these commands on wheezy: " + wheezyProbeCmd + "\n")
245+
By("Running these commands on jessie: " + jessieProbeCmd + "\n")
246+
247+
// Run a pod which probes DNS and exposes the results by HTTP.
248+
By("creating a pod to probe DNS")
249+
pod1 := createDNSPod(f.Namespace.Name, wheezyProbeCmd, jessieProbeCmd, dnsTestPodHostName, dnsTestServiceName)
250+
pod1.ObjectMeta.Labels = testServiceSelector
251+
pod1.Spec.Hostname = podHostname
252+
pod1.Spec.Subdomain = serviceName
253+
254+
validateDNSResults(f, pod1, append(wheezyFileNames, jessieFileNames...))
255+
})
256+
257+
It("should provide DNS for pods for Subdomain", func() {
258+
// Create a test headless service.
259+
By("Creating a test headless service")
260+
testServiceSelector := map[string]string{
261+
"dns-test-hostname-attribute": "true",
262+
}
263+
serviceName := "dns-test-service-2"
264+
podHostname := "dns-querier-2"
265+
headlessService := framework.CreateServiceSpec(serviceName, "", true, testServiceSelector)
266+
_, err := f.ClientSet.CoreV1().Services(f.Namespace.Name).Create(headlessService)
267+
Expect(err).NotTo(HaveOccurred(), "failed to create headless service: %s", serviceName)
268+
269+
defer func() {
270+
By("deleting the test headless service")
271+
defer GinkgoRecover()
272+
f.ClientSet.CoreV1().Services(f.Namespace.Name).Delete(headlessService.Name, nil)
273+
}()
274+
275+
hostFQDN := fmt.Sprintf("%s.%s.%s.svc.%s", podHostname, serviceName, f.Namespace.Name, framework.TestContext.ClusterDNSDomain)
242276
namesToResolve := []string{hostFQDN}
243-
wheezyProbeCmd, wheezyFileNames := createProbeCommand(namesToResolve, hostNames, "", "wheezy", f.Namespace.Name, framework.TestContext.ClusterDNSDomain)
244-
jessieProbeCmd, jessieFileNames := createProbeCommand(namesToResolve, hostNames, "", "jessie", f.Namespace.Name, framework.TestContext.ClusterDNSDomain)
277+
wheezyProbeCmd, wheezyFileNames := createProbeCommand(namesToResolve, nil, "", "wheezy", f.Namespace.Name, framework.TestContext.ClusterDNSDomain)
278+
jessieProbeCmd, jessieFileNames := createProbeCommand(namesToResolve, nil, "", "jessie", f.Namespace.Name, framework.TestContext.ClusterDNSDomain)
245279
By("Running these commands on wheezy: " + wheezyProbeCmd + "\n")
246280
By("Running these commands on jessie: " + jessieProbeCmd + "\n")
247281

0 commit comments

Comments
 (0)