🐞 Skip IPv6 test when IPv4-only

Our unit tests have been failing on our IPv4-only containers because one
of the tests forces a lookup from the (non-existent) IPv6 loopback
interface.

Now we first test to make sure such an interface exists by using
`ping6`. Corner-case: In the event that `ping6` is not on the machine
where the tests are run, but that machine has an IPv6 loopback
interface, that test will be mistakenly skipped. Big deal.

fixes: <https://ci.nono.io/teams/main/pipelines/sslip.io/jobs/unit/builds/4>
```
dig: couldn't get address for '::1': address family not supported
```
This commit is contained in:
Brian Cunnie
2021-07-27 06:25:29 -04:00
parent 43efab0530
commit cdeb5a8768

View File

@@ -56,7 +56,6 @@ var _ = Describe("sslip.io-dns-server", func() {
Eventually(digSession, 1).Should(Exit(0)) Eventually(digSession, 1).Should(Exit(0))
Eventually(string(digSession.Out.Contents())).Should(MatchRegexp(digResults)) Eventually(string(digSession.Out.Contents())).Should(MatchRegexp(digResults))
Eventually(serverSession.Err).Should(Say(serverLogMessage)) Eventually(serverSession.Err).Should(Say(serverLogMessage))
Expect(digSession).Should(Exit())
}, },
Entry("A (customized) for sslip.io", Entry("A (customized) for sslip.io",
"@localhost sslip.io +short", "@localhost sslip.io +short",
@@ -126,6 +125,21 @@ var _ = Describe("sslip.io-dns-server", func() {
) )
}) })
Describe("for more complex assertions", func() { Describe("for more complex assertions", func() {
When("our test is run on a machine which has IPv6", func() {
cmd := exec.Command("ping6", "-c", "1", "::1")
err := cmd.Run() // if the command succeeds, we have IPv6
if err == nil {
It("returns a TXT of the querier's IPv6 address when there are no custom/acme records", func() {
digCmd = exec.Command("dig", "@::1", "ip.", "txt", "+short")
digSession, err = Start(digCmd, GinkgoWriter, GinkgoWriter)
Expect(err).ToNot(HaveOccurred())
Eventually(digSession, 1).Should(Exit(0))
Eventually(string(digSession.Out.Contents())).Should(MatchRegexp(`::1`))
Eventually(serverSession.Err).Should(Say(`TypeTXT ip\. \? \["::1"\]`))
Expect(digSession).To(Exit())
})
}
})
When("ns.sslip.io is queried", func() { When("ns.sslip.io is queried", func() {
It("returns all the A records", func() { It("returns all the A records", func() {
digArgs = "@localhost ns.sslip.io +short" digArgs = "@localhost ns.sslip.io +short"