wait in testcase until server starts (#2648)

This commit is contained in:
neha_gupta
2022-11-30 17:31:19 +05:30
committed by GitHub
parent e015d6d61f
commit 9eb7acf061
+19
View File
@@ -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)