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
Show file tree
Hide file tree
Changes from 4 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
3 changes: 3 additions & 0 deletions test/cloudwatchlogs/publish_logs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.

common.DeleteFile(common.AgentLogFile)
common.TouchFile(common.AgentLogFile)
Expand Down
3 changes: 2 additions & 1 deletion test/cloudwatchlogs/resources/config_auto_removal.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"log_group_name": "{instance_id}",
"log_stream_name": "{instance_id}",
"timezone": "UTC",
"auto_removal": true
"auto_removal": true,
"retention_in_days": 7
}
]
}
Expand Down
3 changes: 2 additions & 1 deletion test/cloudwatchlogs/resources/config_log.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"file_path": "/tmp/cwagent_log_test.log",
"log_group_name": "{instance_id}",
"log_stream_name": "{instance_id}",
"timezone": "UTC"
"timezone": "UTC",
"retention_in_days": 7
}
]
}
Expand Down
3 changes: 2 additions & 1 deletion test/cloudwatchlogs/resources/config_log_filter.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"type": "include",
"expression": "foo"
}
]
],
"retention_in_days": 7
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@
"collect_list": [
{
"file_path": "/tmp/cwagent_log_test.log",
"log_group_name": "infrequent_access",
"log_group_name": "infrequent_access-{instance_id}",
"log_stream_name": "{instance_id}",
"timezone": "UTC",
"log_group_class": "INFREQUENT_ACCESS"
"log_group_class": "INFREQUENT_ACCESS",
"retention_in_days": 7
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
"collect_list": [
{
"file_path": "/tmp/cwagent_log_test.log",
"log_group_name": "standard-no-specification",
"log_group_name": "standard-no-specification-{instance_id}",
"log_stream_name": "{instance_id}",
"timezone": "UTC"
"timezone": "UTC",
"retention_in_days": 7
}
]
}
Expand Down
3 changes: 2 additions & 1 deletion test/cloudwatchlogs/resources/config_log_rotated.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"file_path": "/tmp/rotate_me.log*",
"log_group_name": "{instance_id}",
"log_stream_name": "{instance_id}Rotated",
"timezone": "UTC"
"timezone": "UTC",
"retention_in_days": 7
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@
"collect_list": [
{
"file_path": "/tmp/cwagent_log_test.log",
"log_group_name": "standard-with-specification",
"log_group_name": "standard-with-specification-{instance_id}",
"log_stream_name": "{instance_id}",
"timezone": "UTC",
"log_group_class": "STANDARD"
"log_group_class": "STANDARD",
"retention_in_days": 7
}
]
}
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/jmx/jmx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
//------------------------------------------------------------------------------

var (
env *environment.MetaData
env *environment.MetaData
)

//------------------------------------------------------------------------------
Expand Down
Loading