Procházet zdrojové kódy

Revert "Add default timeout to pkg/plugins/client"

This reverts commit 0699b00d26a60f4a8447572b34c4aad1ce73d2e1.

Signed-off-by: Antonio Murdaca <runcom@redhat.com>
Antonio Murdaca před 8 roky
rodič
revize
5c35bfed3f
2 změnil soubory, kde provedl 1 přidání a 30 odebrání
  1. 1 3
      pkg/plugins/client.go
  2. 0 27
      pkg/plugins/client_test.go

+ 1 - 3
pkg/plugins/client.go

@@ -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,

+ 0 - 27
pkg/plugins/client_test.go

@@ -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)