~samwhited/xmpp

e7a6fe8da19cc7c8a365314e537d1a5aae7d8849 — Sam Whited 2 months ago a4ca230
dial: retry DNS integration tests up to 3 times

These are probably our most flaky integration tests. Retry them up to 3
times to try and reduce the flake to acceptable levels.

Signed-off-by: Sam Whited <sam@samwhited.com>
1 files changed, 7 insertions(+), 1 deletions(-)

M dial/integration_test.go
M dial/integration_test.go => dial/integration_test.go +7 -1
@@ 52,11 52,17 @@ var dialTests = []struct {
func TestIntegrationDial(t *testing.T) {
	for _, tc := range dialTests {
		t.Run(tc.domain, func(t *testing.T) {
			tries := 3
		retry:
			ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
			defer cancel()
			j := jid.MustParse("test@" + tc.domain)

			_, err := tc.dialer.Dial(ctx, "tcp", j)
			if dnsErr, ok := err.(*net.DNSError); tries > 0 && ok && (dnsErr.Temporary() || dnsErr.Timeout()) {
				tries--
				t.Logf("DNS lookup failed for %s, retries remaining %d: %v", tc.domain, tries, err)
				goto retry
			}
			switch {
			case tc.err != "" && err == nil:
				t.Errorf("expected error if SRV record target is missing, got none")