wait in testcase until server starts (#2648)
This commit is contained in:
@@ -9,8 +9,10 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
|
"k8s.io/apimachinery/pkg/util/wait"
|
||||||
|
|
||||||
fv1 "github.com/fission/fission/pkg/apis/core/v1"
|
fv1 "github.com/fission/fission/pkg/apis/core/v1"
|
||||||
config "github.com/fission/fission/pkg/featureconfig"
|
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)
|
loginResp, err := http.Post("http://localhost:8990/auth/login", "application/json", responseBody)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
|
|||||||
Reference in New Issue
Block a user