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

Consume ECS client from ecs-agent module in agent module #4032

Merged
merged 1 commit into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 3 additions & 2 deletions agent/acs/session/payload_responder.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"github.com/aws/amazon-ecs-agent/agent/eventhandler"
"github.com/aws/amazon-ecs-agent/ecs-agent/acs/model/ecsacs"
apiresource "github.com/aws/amazon-ecs-agent/ecs-agent/api/attachment/resource"
"github.com/aws/amazon-ecs-agent/ecs-agent/api/ecs"
apitaskstatus "github.com/aws/amazon-ecs-agent/ecs-agent/api/task/status"
"github.com/aws/amazon-ecs-agent/ecs-agent/credentials"
"github.com/aws/amazon-ecs-agent/ecs-agent/logger"
Expand All @@ -40,7 +41,7 @@ type skipAddTaskComparatorFunc func(apitaskstatus.TaskStatus) bool
// payloadMessageHandler implements PayloadMessageHandler interface defined in ecs-agent module.
type payloadMessageHandler struct {
taskEngine engine.TaskEngine
ecsClient api.ECSClient
ecsClient ecs.ECSClient
dataClient data.Client
taskHandler *eventhandler.TaskHandler
credentialsManager credentials.Manager
Expand All @@ -49,7 +50,7 @@ type payloadMessageHandler struct {

// NewPayloadMessageHandler creates a new payloadMessageHandler.
func NewPayloadMessageHandler(taskEngine engine.TaskEngine,
ecsClient api.ECSClient,
ecsClient ecs.ECSClient,
dataClient data.Client,
taskHandler *eventhandler.TaskHandler,
credentialsManager credentials.Manager,
Expand Down
12 changes: 6 additions & 6 deletions agent/acs/session/payload_responder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ import (
"sync"
"testing"

"github.com/aws/amazon-ecs-agent/agent/api"
mock_api "github.com/aws/amazon-ecs-agent/agent/api/mocks"
apitask "github.com/aws/amazon-ecs-agent/agent/api/task"
"github.com/aws/amazon-ecs-agent/agent/data"
"github.com/aws/amazon-ecs-agent/agent/engine/dockerstate"
Expand All @@ -35,6 +33,8 @@ import (
acssession "github.com/aws/amazon-ecs-agent/ecs-agent/acs/session"
"github.com/aws/amazon-ecs-agent/ecs-agent/acs/session/testconst"
apiresource "github.com/aws/amazon-ecs-agent/ecs-agent/api/attachment/resource"
"github.com/aws/amazon-ecs-agent/ecs-agent/api/ecs"
mock_ecs "github.com/aws/amazon-ecs-agent/ecs-agent/api/ecs/mocks"
apitaskstatus "github.com/aws/amazon-ecs-agent/ecs-agent/api/task/status"
"github.com/aws/amazon-ecs-agent/ecs-agent/credentials"
ni "github.com/aws/amazon-ecs-agent/ecs-agent/netlib/model/networkinterface"
Expand Down Expand Up @@ -76,7 +76,7 @@ type testHelper struct {
func setup(t *testing.T, acsResponseSender wsclient.RespondFunc) *testHelper {
ctrl := gomock.NewController(t)
taskEngine := mock_engine.NewMockTaskEngine(ctrl)
ecsClient := mock_api.NewMockECSClient(ctrl)
ecsClient := mock_ecs.NewMockECSClient(ctrl)
dataClient := data.NewNoopClient()
credentialsManager := credentials.NewManager()
ctx := context.Background()
Expand Down Expand Up @@ -1057,7 +1057,7 @@ func TestHandlePayloadMessageAddedFirelensData(t *testing.T) {

func TestHandleInvalidTask(t *testing.T) {
tester := setup(t, nil)
mockECSACSClient := mock_api.NewMockECSClient(tester.ctrl)
mockECSACSClient := mock_ecs.NewMockECSClient(tester.ctrl)
taskHandler := eventhandler.NewTaskHandler(tester.ctx, data.NewNoopClient(), dockerstate.NewTaskEngineState(),
mockECSACSClient)
tester.payloadMessageHandler.ecsClient = mockECSACSClient
Expand All @@ -1070,8 +1070,8 @@ func TestHandleInvalidTask(t *testing.T) {
wait := &sync.WaitGroup{}
wait.Add(1)

mockECSACSClient.EXPECT().SubmitTaskStateChange(gomock.Any()).Do(func(change api.TaskStateChange) {
assert.NotNil(t, change.Task)
mockECSACSClient.EXPECT().SubmitTaskStateChange(gomock.Any()).Do(func(change ecs.TaskStateChange) {
assert.False(t, change.MetadataGetter.GetTaskIsNil())
wait.Done()
})

Expand Down
Loading