From cdeb5a876899711355751f285011fc5b832f17ee Mon Sep 17 00:00:00 2001 From: Brian Cunnie Date: Tue, 27 Jul 2021 06:25:29 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9E=20Skip=20IPv6=20test=20when=20IPv4?= =?UTF-8?q?-only?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: ``` dig: couldn't get address for '::1': address family not supported ``` --- .../src/sslip.io-dns-server/integration_test.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/bosh-release/src/sslip.io-dns-server/integration_test.go b/bosh-release/src/sslip.io-dns-server/integration_test.go index 0a4fe02..dac8d7c 100644 --- a/bosh-release/src/sslip.io-dns-server/integration_test.go +++ b/bosh-release/src/sslip.io-dns-server/integration_test.go @@ -56,7 +56,6 @@ var _ = Describe("sslip.io-dns-server", func() { Eventually(digSession, 1).Should(Exit(0)) Eventually(string(digSession.Out.Contents())).Should(MatchRegexp(digResults)) Eventually(serverSession.Err).Should(Say(serverLogMessage)) - Expect(digSession).Should(Exit()) }, Entry("A (customized) for sslip.io", "@localhost sslip.io +short", @@ -126,6 +125,21 @@ var _ = Describe("sslip.io-dns-server", 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() { It("returns all the A records", func() { digArgs = "@localhost ns.sslip.io +short"