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

Add tests for GetTaskProtection API to high-level TMDS tests #3739

Merged
merged 3 commits into from
Jun 8, 2023

Conversation

amogh09
Copy link
Contributor

@amogh09 amogh09 commented Jun 7, 2023

Summary

Add comprehensive unit tests for GetTaskProtection API to Task Metadata Server (TMDS) tests. These test cases are already covered by handler-level unit tests for GetTaskProtection handler, however, we will be moving the handler to ecs-agent module in upcoming PRs and having the API tested by TMDS tests will help gain confidence in the move.

This change is a part of a series of similar changes we have been making for many TMDS endpoints. See #3729, #3722, and #3708 that did the same for taskWithTags, task metadata, and container metadata endpoints, respectively.

Implementation details

  • Export NewTaskProtectionClient method of TaskProtectionClientFactoryInterface interface so that it can be mocked. This interface is used by task protection handlers to initialize ECS clients with the right permissions to make ECS task protection calls for the tasks.
  • Update TMDS setup in agent/handlers/task_server_setup.go to use dependency injection for TaskProtectionClientFactoryInterface.
  • Add TestGetTaskProtection function to TMDS test file. This function contains tests for GetTaskProtection API.

Testing

New tests cover the changes: NA

Description for the changelog

Add tests for GetTaskProtection API to high-level TMDS tests

Licensing

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@amogh09 amogh09 marked this pull request as ready for review June 7, 2023 16:52
@amogh09 amogh09 requested a review from a team as a code owner June 7, 2023 16:52
@amogh09 amogh09 force-pushed the get-task-protection-tests branch 2 times, most recently from 289f51c to 2549644 Compare June 7, 2023 17:54
singholt
singholt previously approved these changes Jun 7, 2023
agent/handlers/task_server_setup_test.go Outdated Show resolved Hide resolved
@danehlim
Copy link
Contributor

danehlim commented Jun 8, 2023

nit: For PR description, unless I'm misunderstanding, I think

Add TestAgentAPIV1GetTaskProtectionHandler function to TMDS test file.

should be replaced with

Add TestGetTaskProtection function to TMDS test file.

Changes themselves LGTM 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants