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 resource metric integration test #453

Open
wants to merge 56 commits into
base: main
Choose a base branch
from

Conversation

varunch77
Copy link
Member

@varunch77 varunch77 commented Jan 17, 2025

Description of the issue

There is no integration test that verifies that an entity is being sent when we send resource metrics such as cpu and memory to CloudWatch—this is currently a gap in our testing.

Description of changes

  • Create an agent config to send resource metrics to Cloudwatch
  • Sign and send a request that calls ListEntitiesForMetric to get the entity associated with our metrics
  • Validate the returned entity
  • Update our integration testing IAM role to include permission for ListEntitiesForMetric

License

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Tests

Integration test run: https://github.com/aws/amazon-cloudwatch-agent/actions/runs/12838570212

@varunch77 varunch77 changed the title Resource metric integ test Add resource metric integration test Jan 17, 2025
@varunch77 varunch77 marked this pull request as ready for review January 17, 2025 23:05
@varunch77 varunch77 requested a review from a team as a code owner January 17, 2025 23:05
test/cloudwatchlogs/publish_logs_test.go Outdated Show resolved Hide resolved
test/cloudwatchlogs/publish_logs_test.go Outdated Show resolved Hide resolved
test/cloudwatchlogs/publish_logs_test.go Outdated Show resolved Hide resolved
test/cloudwatchlogs/publish_logs_test.go Outdated Show resolved Hide resolved
test/cloudwatchlogs/publish_logs_test.go Outdated Show resolved Hide resolved
test/cloudwatchlogs/publish_logs_test.go Outdated Show resolved Hide resolved
test/cloudwatchlogs/resources/config_log_resource.json Outdated Show resolved Hide resolved
@varunch77
Copy link
Member Author

Changes:

  • Removed anything logs-related
  • Moved the location of the test into the entity folder
  • Created a helper function in the util/common/metrics package to handle building the ListEntitiesForMetric call
  • Updated the entity validation to use existing helper functions

common.StopAgent()

// build ListEntitiesForMetric request:
requestBody := []byte(fmt.Sprintf(`{
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 would be nice to turn these into test case input, then in the future if someone else to implement a new test, they can just write an additional case instead of copying this entire boilerplate code. For example: https://github.com/aws/amazon-cloudwatch-agent-test/pull/453/files#diff-13510c6aa10605c1f76162fde322c3a4da1cf75441a3a93cb340fbb9d36c480dR186

@zhihonl
Copy link
Contributor

zhihonl commented Jan 24, 2025

Can you attach a new integration test run with this change so we can make sure the test still passes?

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.

3 participants