Revert "Add default timeout to pkg/plugins/client"
This reverts commit 0699b00d26
.
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
This commit is contained in:
parent
a43691d645
commit
5c35bfed3f
2 changed files with 1 additions and 30 deletions
|
@ -16,8 +16,7 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
defaultTimeOut = 30
|
||||
defaultHTTPTimeOut = 32 * time.Second
|
||||
defaultTimeOut = 30
|
||||
)
|
||||
|
||||
// NewClient creates a new plugin client (http).
|
||||
|
@ -54,7 +53,6 @@ func NewClient(addr string, tlsConfig *tlsconfig.Options) (*Client, error) {
|
|||
func NewClientWithTransport(tr transport.Transport) *Client {
|
||||
return &Client{
|
||||
http: &http.Client{
|
||||
Timeout: defaultHTTPTimeOut,
|
||||
Transport: tr,
|
||||
},
|
||||
requestFactory: tr,
|
||||
|
|
|
@ -6,7 +6,6 @@ import (
|
|||
"net/http/httptest"
|
||||
"net/url"
|
||||
"reflect"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
|
@ -31,32 +30,6 @@ func teardownRemotePluginServer() {
|
|||
}
|
||||
}
|
||||
|
||||
func testHTTPTimeout(t *testing.T, timeout, epsilon time.Duration) {
|
||||
addr := setupRemotePluginServer()
|
||||
defer teardownRemotePluginServer()
|
||||
stop := make(chan struct{}) // we need this variable to stop the http server
|
||||
mux.HandleFunc("/hang", func(w http.ResponseWriter, r *http.Request) {
|
||||
<-stop
|
||||
})
|
||||
c, _ := NewClient(addr, &tlsconfig.Options{InsecureSkipVerify: true})
|
||||
c.http.Timeout = timeout
|
||||
begin := time.Now()
|
||||
_, err := c.callWithRetry("hang", nil, false)
|
||||
close(stop)
|
||||
if err == nil || !strings.Contains(err.Error(), "request canceled") {
|
||||
t.Fatalf("The request should be canceled %v", err)
|
||||
}
|
||||
elapsed := time.Now().Sub(begin)
|
||||
if elapsed < timeout-epsilon || elapsed > timeout+epsilon {
|
||||
t.Fatalf("elapsed time: got %v, expected %v (epsilon=%v)",
|
||||
elapsed, timeout, epsilon)
|
||||
}
|
||||
}
|
||||
|
||||
func TestHTTPTimeout(t *testing.T) {
|
||||
testHTTPTimeout(t, 5*time.Second, 500*time.Millisecond)
|
||||
}
|
||||
|
||||
func TestFailedConnection(t *testing.T) {
|
||||
c, _ := NewClient("tcp://127.0.0.1:1", &tlsconfig.Options{InsecureSkipVerify: true})
|
||||
_, err := c.callWithRetry("Service.Method", nil, false)
|
||||
|
|
Loading…
Reference in a new issue