Skip to content

Commit

Permalink
test: add test for global DNS configuration (#1226)
Browse files Browse the repository at this point in the history
Signed-off-by: Mat Kowalski <[email protected]>
  • Loading branch information
mkowalski authored Aug 9, 2024
1 parent db5c1b5 commit a12e1f7
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions test/e2e/handler/rollback_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,15 @@ interfaces:
`, nic))
}

func setBadNameServersGlobal(addr string) nmstate.State {
return nmstate.NewState(fmt.Sprintf(`dns-resolver:
config:
search: []
server:
- %s
`, addr))
}

func discoverNameServers(nic string) nmstate.State {
return nmstate.NewState(fmt.Sprintf(`
dns-resolver:
Expand Down Expand Up @@ -232,4 +241,30 @@ var _ = Describe("rollback", func() {

})
})

Context("when name servers (configured globally) are wrong after state configuration", func() {
BeforeEach(func() {
updateDesiredStateAtNode(nodes[0], setBadNameServersGlobal("192.168.100.3"))
})
AfterEach(func() {
By("Clean up desired state")
resetDesiredStateForNodes()
})
It("should rollback to previous name servers", func() {
By("Should not be available") // Fail fast
policy.StatusConsistently().ShouldNot(policy.ContainPolicyAvailable())

By("Wait for reconcile to fail")
policy.WaitForDegradedTestPolicy()
By("Check that global DNS is rolled back")
Eventually(func() []string {
return dnsResolverForNode(nodes[0], "dns-resolver.running.server")
}, 480*time.Second, ReadInterval).ShouldNot(ContainElement("192.168.100.3"), "should eventually lose wrong name server")

By("Check that global DNS continue with rolled back state")
Consistently(func() []string {
return dnsResolverForNode(nodes[0], "dns-resolver.running.server")
}, 5*time.Second, 1*time.Second).ShouldNot(ContainElement("192.168.100.3"), "should consistently not contain wrong name server")
})
})
})

0 comments on commit a12e1f7

Please sign in to comment.