Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle SetReadDeadline error for websocket connections (#1292) #1310

Merged
merged 7 commits into from
Mar 21, 2018
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions agent/Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion agent/Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@

[[constraint]]
name = "github.com/golang/mock"
revision ="bd3c8e81be01eef76d4b503f5e687d2d1354d2d9"
revision ="58cd061d09382b6011f84c1291ebe50ef2e25bab"

[[constraint]]
name = "github.com/gorilla/websocket"
Expand Down
16 changes: 8 additions & 8 deletions agent/acs/client/acs_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"github.com/aws/amazon-ecs-agent/agent/acs/model/ecsacs"
"github.com/aws/amazon-ecs-agent/agent/config"
"github.com/aws/amazon-ecs-agent/agent/wsclient"
"github.com/aws/amazon-ecs-agent/agent/wsclient/mock"
"github.com/aws/amazon-ecs-agent/agent/wsclient/wsconn/mock"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/credentials"
"github.com/golang/mock/gomock"
Expand Down Expand Up @@ -91,7 +91,7 @@ func TestMakeUnrecognizedRequest(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()

conn := mock_wsclient.NewMockWebsocketConn(ctrl)
conn := mock_wsconn.NewMockWebsocketConn(ctrl)
conn.EXPECT().SetWriteDeadline(gomock.Any()).Return(nil)
conn.EXPECT().Close()

Expand All @@ -108,7 +108,7 @@ func TestWriteAckRequest(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()

conn := mock_wsclient.NewMockWebsocketConn(ctrl)
conn := mock_wsconn.NewMockWebsocketConn(ctrl)
conn.EXPECT().SetWriteDeadline(gomock.Any()).Return(nil).Times(2)
conn.EXPECT().Close()
cs := testCS(conn)
Expand All @@ -135,7 +135,7 @@ func TestPayloadHandlerCalled(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()

conn := mock_wsclient.NewMockWebsocketConn(ctrl)
conn := mock_wsconn.NewMockWebsocketConn(ctrl)
// Messages should be read from the connection at least once
conn.EXPECT().SetReadDeadline(gomock.Any()).Return(nil).MinTimes(1)
conn.EXPECT().ReadMessage().Return(websocket.TextMessage,
Expand Down Expand Up @@ -167,7 +167,7 @@ func TestRefreshCredentialsHandlerCalled(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()

conn := mock_wsclient.NewMockWebsocketConn(ctrl)
conn := mock_wsconn.NewMockWebsocketConn(ctrl)
// Messages should be read from the connection at least once
conn.EXPECT().SetReadDeadline(gomock.Any()).Return(nil).MinTimes(1)
conn.EXPECT().ReadMessage().Return(websocket.TextMessage,
Expand Down Expand Up @@ -206,7 +206,7 @@ func TestClosingConnection(t *testing.T) {
defer ctrl.Finish()

// Returning EOF tells the ClientServer that the connection is closed
conn := mock_wsclient.NewMockWebsocketConn(ctrl)
conn := mock_wsconn.NewMockWebsocketConn(ctrl)
conn.EXPECT().SetReadDeadline(gomock.Any()).Return(nil)
conn.EXPECT().ReadMessage().Return(0, nil, io.EOF)
// SetWriteDeadline will be invoked once for WriteMessage() and
Expand Down Expand Up @@ -313,7 +313,7 @@ func TestConnectClientError(t *testing.T) {
assert.EqualError(t, err, "InvalidClusterException: Invalid cluster")
}

func testCS(conn *mock_wsclient.MockWebsocketConn) wsclient.ClientServer {
func testCS(conn *mock_wsconn.MockWebsocketConn) wsclient.ClientServer {
testCreds := credentials.AnonymousCredentials
foo := New("localhost:443", testCfg, testCreds, rwTimeout)
cs := foo.(*clientServer)
Expand Down Expand Up @@ -361,7 +361,7 @@ func TestAttachENIHandlerCalled(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()

conn := mock_wsclient.NewMockWebsocketConn(ctrl)
conn := mock_wsconn.NewMockWebsocketConn(ctrl)
cs := testCS(conn)
defer cs.Close()

Expand Down
1 change: 1 addition & 0 deletions agent/acs/handler/acs_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,7 @@ func newDisconnectionTimer(client wsclient.ClientServer, timeout time.Duration,
if err := client.Close(); err != nil {
seelog.Warnf("Error disconnecting: %v", err)
}
seelog.Info("Disconnected from ACS")
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I think copyright line in this file needs updating too.

})

return timer
Expand Down
132 changes: 79 additions & 53 deletions agent/acs/update_handler/os/mock/filesystem.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading