Skip to content
This repository was archived by the owner on May 12, 2021. It is now read-only.

protocol: client: enable builtin yamux client support#201

Merged
egernst merged 1 commit intokata-containers:masterfrom
bergwolf:yamux_client
Apr 4, 2018
Merged

protocol: client: enable builtin yamux client support#201
egernst merged 1 commit intokata-containers:masterfrom
bergwolf:yamux_client

Conversation

@bergwolf
Copy link
Copy Markdown
Member

@bergwolf bergwolf commented Apr 3, 2018

When enableYamux is set, dial the grpc server with builtin yamux
translation support.

Fixes: #200

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 3, 2018

Codecov Report

Merging #201 into master will increase coverage by 1.19%.
The diff coverage is 68%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #201      +/-   ##
==========================================
+ Coverage   31.71%   32.91%   +1.19%     
==========================================
  Files          10       10              
  Lines        1463     1580     +117     
==========================================
+ Hits          464      520      +56     
- Misses        936      980      +44     
- Partials       63       80      +17
Impacted Files Coverage Δ
protocols/client/client.go 68.69% <68%> (-2.14%) ⬇️
network.go 46.24% <0%> (-0.21%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a78f4e7...e37feac. Read the comment docs.


cliFunc := func(sock string, success bool, expect string) {
cli, err := NewAgentClient(sock)
cli, err := NewAgentClient(sock, false)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there no way to unit test the yamux option?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

surely there is. I'll add UT for it.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @bergwolf ! 😄

Copy link
Copy Markdown

@sboeuf sboeuf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but please address @jodh-intel comment about unit testing before merging.

@bergwolf
Copy link
Copy Markdown
Member Author

bergwolf commented Apr 4, 2018

@jodh-intel UT added. PTAL.

@jodh-intel
Copy link
Copy Markdown

Thanks @bergwolf - TestNewAgentClientWithYamux() failed under Travis though (test timed out).

@bergwolf
Copy link
Copy Markdown
Member Author

bergwolf commented Apr 4, 2018

@jodh-intel CI test timeout is too low. Can we increase it?
panic: test timed out after 10s

The UT actually includes two context deadline timeout tests that only return after waiting for 5 seconds each.

@jodh-intel
Copy link
Copy Markdown

Hi @bergwolf - yes, we could change the timeout...

... but 10 seconds is a long time. How about doing this instead?:

diff --git a/protocols/client/client.go b/protocols/client/client.go
index ffaded3..b092524 100644
--- a/protocols/client/client.go
+++ b/protocols/client/client.go
@@ -26,9 +26,11 @@ import (
 const (
 	unixSocketScheme  = "unix"
 	vsockSocketScheme = "vsock"
-	dialTimeout       = 5 * time.Second
 )
 
+// defined as a var to allow the tests to modify it
+var dialTimeout = 5 * time.Second
+
 // AgentClient is an agent gRPC client connection wrapper for agentgrpc.AgentServiceClient
 type AgentClient struct {
 	agentgrpc.AgentServiceClient
diff --git a/protocols/client/client_test.go b/protocols/client/client_test.go
index b7789b3..633da23 100644
--- a/protocols/client/client_test.go
+++ b/protocols/client/client_test.go
@@ -12,6 +12,7 @@ import (
 	"os"
 	"strings"
 	"testing"
+	"time"
 
 	"github.com/hashicorp/yamux"
 	"github.com/stretchr/testify/assert"
@@ -106,6 +107,13 @@ func agentClientTest(t *testing.T, sock string, success, enableYamux bool, expec
 }
 
 func TestNewAgentClient(t *testing.T) {
+	savedDialTimeout := dialTimeout
+	dialTimeout = 1 * time.Second
+
+	defer func() {
+		dialTimeout = savedDialTimeout
+	}()
+
 	mock, waitCh, err := startMockServer(t, false)
 	assert.Nil(t, err, "failed to start mock server: %s", err)
 
@@ -129,6 +137,13 @@ func TestNewAgentClient(t *testing.T) {
 }
 
 func TestNewAgentClientWithYamux(t *testing.T) {
+	savedDialTimeout := dialTimeout
+	dialTimeout = 1 * time.Second
+
+	defer func() {
+		dialTimeout = savedDialTimeout
+	}()
+
 	mock, waitCh, err := startMockServer(t, true)
 	assert.Nil(t, err, "failed to start mock server: %s", err)

When enableYamux is set, dial the grpc server with builtin yamux
translation support.

Fixes: kata-containers#200

Signed-off-by: Peng Tao <bergwolf@gmail.com>
@bergwolf
Copy link
Copy Markdown
Member Author

bergwolf commented Apr 4, 2018

@jodh-intel thanks for the suggestion. I've added it. PTAL.

@jodh-intel
Copy link
Copy Markdown

jodh-intel commented Apr 4, 2018

Hi @bergwolf - Nice - much neater your way! ;)

lgtm

Approved with PullApprove

@egernst egernst merged commit c8199f6 into kata-containers:master Apr 4, 2018
@egernst egernst removed the review label Apr 4, 2018
@bergwolf bergwolf deleted the yamux_client branch April 8, 2019 08:28
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants