Skip to content

Commit

Permalink
Fix flaky cloudwatchlogs test (#455)
Browse files Browse the repository at this point in the history
  • Loading branch information
varunch77 authored Jan 27, 2025
1 parent 70baaf0 commit 54ee01d
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 13 deletions.
7 changes: 5 additions & 2 deletions test/cloudwatchlogs/publish_logs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,10 @@ func TestLogGroupClass(t *testing.T) {

for _, param := range cloudWatchLogGroupClassTestParameters {
t.Run(param.testName, func(t *testing.T) {
defer awsservice.DeleteLogGroupAndStream(param.logGroupName, instanceId)
// 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
logGroupName := param.logGroupName + "-" + instanceId
defer awsservice.DeleteLogGroupAndStream(logGroupName, instanceId)
common.DeleteFile(common.AgentLogFile)
common.TouchFile(common.AgentLogFile)

Expand All @@ -269,7 +272,7 @@ func TestLogGroupClass(t *testing.T) {
}
t.Logf("Agent logs %s", string(agentLog))

assert.True(t, awsservice.IsLogGroupExists(param.logGroupName, param.logGroupClass))
assert.True(t, awsservice.IsLogGroupExists(logGroupName, param.logGroupClass))
})
}
}
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
5 changes: 3 additions & 2 deletions test/cloudwatchlogs/resources/config_log_standard_access.json
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

0 comments on commit 54ee01d

Please sign in to comment.