]> Cypherpunks repositories - gostls13.git/commitdiff
net: deflake TestLookupCNAME
authoradrienpetel <peteladrien@gmail.com>
Fri, 30 Mar 2018 10:15:24 +0000 (14:15 +0400)
committerBrad Fitzpatrick <bradfitz@golang.org>
Fri, 30 Mar 2018 19:04:10 +0000 (19:04 +0000)
Apply the same approach as in CL 102397.

Updates #24580

Change-Id: I65955f62a70807c87216519d03f3643a8f214dee
Reviewed-on: https://go-review.googlesource.com/103655
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/net/lookup_test.go

index 217a24705b820d729a38939ec78cb9b20e791f0e..c2a6477e2e43e19f81a513be804fe0e967562eb9 100644 (file)
@@ -308,9 +308,20 @@ func TestLookupCNAME(t *testing.T) {
 
        defer dnsWaitGroup.Wait()
 
-       for _, tt := range lookupCNAMETests {
+       attempts := 0
+       for i := 0; i < len(lookupCNAMETests); i++ {
+               tt := lookupCNAMETests[i]
                cname, err := LookupCNAME(tt.name)
                if err != nil {
+                       testenv.SkipFlakyNet(t)
+                       if attempts < len(backoffDuration) {
+                               dur := backoffDuration[attempts]
+                               t.Logf("backoff %v after failure %v\n", dur, err)
+                               time.Sleep(dur)
+                               attempts++
+                               i--
+                               continue
+                       }
                        t.Fatal(err)
                }
                if !strings.HasSuffix(cname, tt.cname) {