@@ -36,7 +36,7 @@ var _ = Describe("Retries", func() {
36
36
BeforeEach (func () {
37
37
appURL = "bad-app." + test_util .LocalhostDNS
38
38
39
- badApp = common .NewTcpApp ([]route.Uri {route .Uri (appURL )}, testState . cfg . Port , testState .mbusClient , nil , "" )
39
+ badApp = common .NewTcpApp ([]route.Uri {route .Uri (appURL )}, test_util . NextAvailPort () , testState .mbusClient , nil , "" )
40
40
badApp .Register ()
41
41
})
42
42
@@ -70,16 +70,25 @@ var _ = Describe("Retries", func() {
70
70
badApp .SetHandlers (handlers )
71
71
badApp .Listen ()
72
72
73
- req := testState .newPostRequest (
74
- fmt .Sprintf ("http://%s" , appURL ),
75
- bytes .NewReader ([]byte (payload )),
76
- )
77
- resp , err := testState .client .Do (req )
78
- Expect (err ).NotTo (HaveOccurred ())
79
- Expect (resp .StatusCode ).To (Equal (200 ))
80
- if resp .Body != nil {
81
- resp .Body .Close ()
73
+ successSeen := false
74
+ // we need to retry the entire http request many times to get a success until https://github.com/golang/go/issues/31259
75
+ // is resolved.
76
+ for i := 0 ; i < 100 ; i ++ {
77
+ req := testState .newPostRequest (
78
+ fmt .Sprintf ("http://%s" , appURL ),
79
+ bytes .NewReader ([]byte (payload )),
80
+ )
81
+ resp , err := testState .client .Do (req )
82
+ Expect (err ).NotTo (HaveOccurred ())
83
+ if resp .StatusCode == http .StatusOK {
84
+ successSeen = true
85
+ break
86
+ }
87
+ if resp .Body != nil {
88
+ resp .Body .Close ()
89
+ }
82
90
}
91
+ Expect (successSeen ).To (BeTrue ())
83
92
})
84
93
})
85
94
})
0 commit comments