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

Fix flaky cloudwatchlogs test #455

Merged
merged 7 commits into from
Jan 27, 2025
Merged

Fix flaky cloudwatchlogs test #455

merged 7 commits into from
Jan 27, 2025

Conversation

varunch77
Copy link
Member

@varunch77 varunch77 commented Jan 24, 2025

Description of the issue

TestLogGroupClass uses fixed log group names in the tests. When multiple integration tests are run concurrently in the same account, they're all trying to operate and validate with the same log groups, leading to flaky behavior.

Description of changes

The log groups created now have the instance id appended to the end of the name, ensuring there is no overlap. I've also added a 7-day log group retention policy in the agent configs.

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: https://github.com/aws/amazon-cloudwatch-agent/actions/runs/12958277627

@varunch77 varunch77 marked this pull request as ready for review January 24, 2025 20:44
@varunch77 varunch77 requested a review from a team as a code owner January 24, 2025 20:44
musa-asad
musa-asad previously approved these changes Jan 24, 2025
@@ -249,6 +249,9 @@ func TestLogGroupClass(t *testing.T) {

for _, param := range cloudWatchLogGroupClassTestParameters {
t.Run(param.testName, func(t *testing.T) {
// add instance id to ensure that running integration tests concurrently doesn't cause tests
// to operate and validate with the same log groups and lead to flaky results
param.logGroupName += "-" + instanceId
defer awsservice.DeleteLogGroupAndStream(param.logGroupName, instanceId)
Copy link
Contributor

@dricross dricross Jan 24, 2025

Choose a reason for hiding this comment

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

Mentioned in another comment, but we should update the logGroupName passed to DeleteLogGroupAndStream as well

Copy link
Contributor

@musa-asad musa-asad Jan 25, 2025

Choose a reason for hiding this comment

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

Good catch @dricross.

Suggested change
defer awsservice.DeleteLogGroupAndStream(param.logGroupName, instanceId)
defer awsservice.DeleteLogGroupAndStream(param.logGroupName += "-" + instanceId, instanceId)

Copy link
Member Author

@varunch77 varunch77 Jan 25, 2025

Choose a reason for hiding this comment

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

I believe this should have already been handled since I was using += here but I rewrote it to make it more clear now

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah good point, I missed that. Thanks Varun!

I think with that we don't really need to change log retention at all then since the log group and stream gets deleted. Though it also doesn't hurt to set it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah missed that too. Yeah, keeping the log retention doesn't hurt.

@musa-asad musa-asad self-requested a review January 25, 2025 05:12
@@ -249,6 +249,9 @@ func TestLogGroupClass(t *testing.T) {

for _, param := range cloudWatchLogGroupClassTestParameters {
t.Run(param.testName, func(t *testing.T) {
// add instance id to ensure that running integration tests concurrently doesn't cause tests
// to operate and validate with the same log groups and lead to flaky results
param.logGroupName += "-" + instanceId
defer awsservice.DeleteLogGroupAndStream(param.logGroupName, instanceId)
Copy link
Contributor

@musa-asad musa-asad Jan 25, 2025

Choose a reason for hiding this comment

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

Good catch @dricross.

Suggested change
defer awsservice.DeleteLogGroupAndStream(param.logGroupName, instanceId)
defer awsservice.DeleteLogGroupAndStream(param.logGroupName += "-" + instanceId, instanceId)

@varunch77
Copy link
Member Author

varunch77 commented Jan 25, 2025

Changes:

@varunch77 varunch77 merged commit 54ee01d into main Jan 27, 2025
2 checks passed
@varunch77 varunch77 deleted the flaky-cloudwatchlogs-tests branch January 27, 2025 15:26
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