Skip to content

Commit

Permalink
e2e: retry to solve timeout (#759)
Browse files Browse the repository at this point in the history
Signed-off-by: spacewander <[email protected]>
  • Loading branch information
spacewander authored Oct 10, 2024
1 parent 6a77468 commit 3e29c94
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions e2e/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ module mosn.io/htnn/e2e
go 1.21.5

require (
github.com/avast/retry-go v3.0.0+incompatible
github.com/stretchr/testify v1.9.0
istio.io/client-go v1.21.2
k8s.io/api v0.29.3
Expand Down
2 changes: 2 additions & 0 deletions e2e/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ github.com/agnivade/levenshtein v1.1.1 h1:QY8M92nrzkmr798gCo3kmMyqXFzdQVpxLlGPRB
github.com/agnivade/levenshtein v1.1.1/go.mod h1:veldBMzWxcCG2ZvUTKD2kJNRdCk5hVbJomOvKkmgYbo=
github.com/antlr4-go/antlr/v4 v4.13.0 h1:lxCg3LAv+EUK6t1i0y1V6/SLeUi0eKEKdhQAlS8TVTI=
github.com/antlr4-go/antlr/v4 v4.13.0/go.mod h1:pfChB/xh/Unjila75QW7+VU4TSnWnnk9UTnmpPaOR2g=
github.com/avast/retry-go v3.0.0+incompatible h1:4SOWQ7Qs+oroOTQOYnAHqelpCO0biHSxpiH9JdtuBj0=
github.com/avast/retry-go v3.0.0+incompatible/go.mod h1:XtSnn+n/sHqQIpZ10K1qAevBhOOCWBLXXy3hyiqqBrY=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
Expand Down
16 changes: 15 additions & 1 deletion e2e/tests/consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"testing"
"time"

"github.com/avast/retry-go"
"github.com/stretchr/testify/require"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
Expand All @@ -42,7 +43,20 @@ func init() {
suite.Register(suite.Test{
Manifests: []string{"base/httproute.yml"},
Run: func(t *testing.T, suite *suite.Suite) {
rsp, err := suite.Get("/echo", hdrWithKey("rick"))
var rsp *http.Response
var err error
err = retry.Do(
func() error {
rsp, err = suite.Get("/echo", hdrWithKey("rick"))
return err
},
retry.RetryIf(func(err error) bool {
return true
}),
retry.Attempts(3),
// backoff delay
retry.Delay(500*time.Millisecond),
)
require.NoError(t, err)
require.Equal(t, 200, rsp.StatusCode)
req, _, err := suite.Capture(rsp)
Expand Down

0 comments on commit 3e29c94

Please sign in to comment.