|
@@ -6,6 +6,7 @@ import (
|
|
|
"net/http/httptest"
|
|
|
"net/url"
|
|
|
"reflect"
|
|
|
+ "strings"
|
|
|
"testing"
|
|
|
"time"
|
|
|
|
|
@@ -30,6 +31,26 @@ func teardownRemotePluginServer() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+func TestHttpTimeout(t *testing.T) {
|
|
|
+ addr := setupRemotePluginServer()
|
|
|
+ defer teardownRemotePluginServer()
|
|
|
+ stop := false // we need this variable to stop the http server
|
|
|
+ mux.HandleFunc("/hang", func(w http.ResponseWriter, r *http.Request) {
|
|
|
+ for {
|
|
|
+ if stop {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ time.Sleep(5 * time.Second)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ c, _ := NewClient(addr, &tlsconfig.Options{InsecureSkipVerify: true})
|
|
|
+ _, err := c.callWithRetry("hang", nil, false)
|
|
|
+ stop = true
|
|
|
+ if err == nil || !strings.Contains(err.Error(), "request canceled") {
|
|
|
+ t.Fatalf("The request should be canceled %v", err)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
func TestFailedConnection(t *testing.T) {
|
|
|
c, _ := NewClient("tcp://127.0.0.1:1", &tlsconfig.Options{InsecureSkipVerify: true})
|
|
|
_, err := c.callWithRetry("Service.Method", nil, false)
|