Add functional test.
@@ -610,6 +610,38 @@ var _ = Describe("Networking", func() {
})
})
+ Context("VirtualMachineInstance with custom dns", func() {
+ BeforeEach(func() {
+ tests.BeforeTestCleanup()
+ })
+
+ It("should have custom resolv.conf", func() {
+ optionValue := "2"
+ userData := "#cloud-config\npassword: fedora\nchpasswd: { expire: False }\n"
+ dnsVMI := tests.NewRandomVMIWithEphemeralDiskAndUserdata(tests.ContainerDiskFor(tests.ContainerDiskCirros), userData)
+ dnsVMI.Spec.DNSPolicy = "None"
+ dnsVMI.Spec.DNSConfig = &k8sv1.PodDNSConfig{
+ Nameservers: []string{"8.8.8.8", "4.2.2.1"},
+ Searches: []string{"example.com"},
+ }
+
+ _, err = virtClient.VirtualMachineInstance(tests.NamespaceTestDefault).Create(dnsVMI)
+ Expect(err).ToNot(HaveOccurred())
+ time.Sleep(10 * time.Minute)
+ tests.WaitUntilVMIReady(dnsVMI, tests.LoggedInCirrosExpecter)
+
+ err = tests.CheckForTextExpecter(dnsVMI, []expect.Batcher{
+ &expect.BSnd{S: "\n"},
+ &expect.BExp{R: "#"},
+ &expect.BSnd{S: "cat /etc/resolv.conf\n"},
+ &expect.BExp{R: "search example.com\nnameserver 8.8.8.8\nnameserver 4.2.2.1"},
+ &expect.BExp{R: "#"},
+ }, 15)
+
+ Expect(err).ToNot(HaveOccurred())
+ })
+ })
+
Context("VirtualMachineInstance with masquerade binding mechanism", func() {
var serverVMI *v1.VirtualMachineInstance
var clientVMI *v1.VirtualMachineInstance
