diff --git a/pkg/router/auth_test.go b/pkg/router/auth_test.go index 7605bf48..316f19b6 100644 --- a/pkg/router/auth_test.go +++ b/pkg/router/auth_test.go @@ -9,8 +9,10 @@ import ( "net/http" "os" "testing" + "time" "github.com/gorilla/mux" + "k8s.io/apimachinery/pkg/util/wait" fv1 "github.com/fission/fission/pkg/apis/core/v1" config "github.com/fission/fission/pkg/featureconfig" @@ -104,6 +106,23 @@ func TestRouterAuth(t *testing.T) { }, } + backOff := wait.Backoff{Duration: 1 * time.Second, Cap: 20 * time.Second, Steps: 5} + + condition := func() (bool, error) { + rBody := bytes.NewBuffer(postBody) + _, err := http.Post("http://localhost:8990/auth/login", "application/json", rBody) + if err != nil { + return false, nil + } + + return true, nil + } + + err := wait.ExponentialBackoff(backOff, condition) + if err != nil { + t.Error(err) + } + loginResp, err := http.Post("http://localhost:8990/auth/login", "application/json", responseBody) if err != nil { t.Error(err)