Closes: #33412
Signed-off-by: Felix Abecassis <fabecassis@nvidia.com>
| ... | ... |
@@ -129,15 +129,15 @@ func (c *Client) SendFile(serviceMethod string, data io.Reader, ret interface{})
|
| 129 | 129 |
} |
| 130 | 130 |
|
| 131 | 131 |
func (c *Client) callWithRetry(serviceMethod string, data io.Reader, retry bool) (io.ReadCloser, error) {
|
| 132 |
- req, err := c.requestFactory.NewRequest(serviceMethod, data) |
|
| 133 |
- if err != nil {
|
|
| 134 |
- return nil, err |
|
| 135 |
- } |
|
| 136 |
- |
|
| 137 | 132 |
var retries int |
| 138 | 133 |
start := time.Now() |
| 139 | 134 |
|
| 140 | 135 |
for {
|
| 136 |
+ req, err := c.requestFactory.NewRequest(serviceMethod, data) |
|
| 137 |
+ if err != nil {
|
|
| 138 |
+ return nil, err |
|
| 139 |
+ } |
|
| 140 |
+ |
|
| 141 | 141 |
resp, err := c.http.Do(req) |
| 142 | 142 |
if err != nil {
|
| 143 | 143 |
if !retry {
|
| ... | ... |
@@ -6,6 +6,7 @@ import ( |
| 6 | 6 |
"net/http/httptest" |
| 7 | 7 |
"net/url" |
| 8 | 8 |
"reflect" |
| 9 |
+ "strings" |
|
| 9 | 10 |
"testing" |
| 10 | 11 |
"time" |
| 11 | 12 |
|
| ... | ... |
@@ -38,6 +39,26 @@ func TestFailedConnection(t *testing.T) {
|
| 38 | 38 |
} |
| 39 | 39 |
} |
| 40 | 40 |
|
| 41 |
+func TestFailOnce(t *testing.T) {
|
|
| 42 |
+ addr := setupRemotePluginServer() |
|
| 43 |
+ defer teardownRemotePluginServer() |
|
| 44 |
+ |
|
| 45 |
+ failed := false |
|
| 46 |
+ mux.HandleFunc("/Test.FailOnce", func(w http.ResponseWriter, r *http.Request) {
|
|
| 47 |
+ if !failed {
|
|
| 48 |
+ failed = true |
|
| 49 |
+ panic("Plugin not ready")
|
|
| 50 |
+ } |
|
| 51 |
+ }) |
|
| 52 |
+ |
|
| 53 |
+ c, _ := NewClient(addr, &tlsconfig.Options{InsecureSkipVerify: true})
|
|
| 54 |
+ b := strings.NewReader("body")
|
|
| 55 |
+ _, err := c.callWithRetry("Test.FailOnce", b, true)
|
|
| 56 |
+ if err != nil {
|
|
| 57 |
+ t.Fatal(err) |
|
| 58 |
+ } |
|
| 59 |
+} |
|
| 60 |
+ |
|
| 41 | 61 |
func TestEchoInputOutput(t *testing.T) {
|
| 42 | 62 |
addr := setupRemotePluginServer() |
| 43 | 63 |
defer teardownRemotePluginServer() |