Browse code

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

This reverts commit 0699b00d26a60f4a8447572b34c4aad1ce73d2e1.

Signed-off-by: Antonio Murdaca <runcom@redhat.com>

Antonio Murdaca authored on 2016/09/16 19:34:34
Showing 2 changed files
... ...
@@ -16,8 +16,7 @@ import (
16 16
 )
17 17
 
18 18
 const (
19
-	defaultTimeOut     = 30
20
-	defaultHTTPTimeOut = 32 * time.Second
19
+	defaultTimeOut = 30
21 20
 )
22 21
 
23 22
 // NewClient creates a new plugin client (http).
... ...
@@ -54,7 +53,6 @@ func NewClient(addr string, tlsConfig *tlsconfig.Options) (*Client, error) {
54 54
 func NewClientWithTransport(tr transport.Transport) *Client {
55 55
 	return &Client{
56 56
 		http: &http.Client{
57
-			Timeout:   defaultHTTPTimeOut,
58 57
 			Transport: tr,
59 58
 		},
60 59
 		requestFactory: tr,
... ...
@@ -6,7 +6,6 @@ import (
6 6
 	"net/http/httptest"
7 7
 	"net/url"
8 8
 	"reflect"
9
-	"strings"
10 9
 	"testing"
11 10
 	"time"
12 11
 
... ...
@@ -31,32 +30,6 @@ func teardownRemotePluginServer() {
31 31
 	}
32 32
 }
33 33
 
34
-func testHTTPTimeout(t *testing.T, timeout, epsilon time.Duration) {
35
-	addr := setupRemotePluginServer()
36
-	defer teardownRemotePluginServer()
37
-	stop := make(chan struct{}) // we need this variable to stop the http server
38
-	mux.HandleFunc("/hang", func(w http.ResponseWriter, r *http.Request) {
39
-		<-stop
40
-	})
41
-	c, _ := NewClient(addr, &tlsconfig.Options{InsecureSkipVerify: true})
42
-	c.http.Timeout = timeout
43
-	begin := time.Now()
44
-	_, err := c.callWithRetry("hang", nil, false)
45
-	close(stop)
46
-	if err == nil || !strings.Contains(err.Error(), "request canceled") {
47
-		t.Fatalf("The request should be canceled %v", err)
48
-	}
49
-	elapsed := time.Now().Sub(begin)
50
-	if elapsed < timeout-epsilon || elapsed > timeout+epsilon {
51
-		t.Fatalf("elapsed time: got %v, expected %v (epsilon=%v)",
52
-			elapsed, timeout, epsilon)
53
-	}
54
-}
55
-
56
-func TestHTTPTimeout(t *testing.T) {
57
-	testHTTPTimeout(t, 5*time.Second, 500*time.Millisecond)
58
-}
59
-
60 34
 func TestFailedConnection(t *testing.T) {
61 35
 	c, _ := NewClient("tcp://127.0.0.1:1", &tlsconfig.Options{InsecureSkipVerify: true})
62 36
 	_, err := c.callWithRetry("Service.Method", nil, false)