From 7cf54615248730a81d4ed2c6a0b6d9c6bc23a2fd Mon Sep 17 00:00:00 2001 From: lisguo Date: Tue, 3 Dec 2024 15:25:46 -0500 Subject: [PATCH] Add retry logic to fluent test --- test/fluent/fluent_test.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/test/fluent/fluent_test.go b/test/fluent/fluent_test.go index 951a72ed8..c2074626f 100644 --- a/test/fluent/fluent_test.go +++ b/test/fluent/fluent_test.go @@ -17,7 +17,7 @@ import ( "github.com/aws/amazon-cloudwatch-agent-test/util/awsservice" ) -const logStreamRetry = 20 +const logStreamRetry = 10 // fluent log group with expected log message fields var logGroupToKey = map[string][][]string{ @@ -61,10 +61,19 @@ func TestFluentLogs(t *testing.T) { logGroupToKey = logGroupToKeyWindows } + currRetries := 0 now := time.Now() for group, fieldsArr := range logGroupToKey { group = fmt.Sprintf("/aws/containerinsights/%s/%s", env.EKSClusterName, group) - if !awsservice.IsLogGroupExists(group) { + for currRetries < logStreamRetry { + if awsservice.IsLogGroupExists(group) { + break + } else { + currRetries++ + time.Sleep(time.Duration(currRetries) * time.Second) + } + } + if currRetries >= logStreamRetry { t.Fatalf("fluent log group doesn't exsit: %s", group) }