Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
29 changes: 29 additions & 0 deletions tests/integration/compose/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
package integration

import (
"fmt"
"strings"
"testing"
"time"

Expand Down Expand Up @@ -42,3 +44,30 @@ func get_logs(t *testing.T, dockerOptions *docker.Options, container string) str
output := docker.RunDockerComposeAndGetStdOut(t, dockerOptions, "logs", container)
return output
}

func checkContainerLogsWithRetries(subT *testing.T, dockerOptions *docker.Options, container string, tc string, expected string) {
maxRetries := 6
retryDelay := 2 * time.Second

var log string

for i := 0; i < maxRetries; i++ {
log = get_logs(subT, dockerOptions, container)
if strings.Contains(log, expected) {
// Log entry found, proceed to next container
break
}

// Log entry not found, wait before retrying
if i < maxRetries-1 {
time.Sleep(retryDelay)
}
}

// Final assertion
subT.Run(fmt.Sprintf("%s - %s", tc, container), func(t *testing.T) {
if !strings.Contains(log, expected) {
t.Errorf("%s - %s - log should contain matching entry:\n\t%s", tc, container, expected)
}
})
}
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ func (s *commonServicesInternalAuthDockerComposeUpTest) TestDockerComposeUp() {
validate_endpoint(subT, expected.url, expected.responsePayload, expected.httpResponseCode)
}
// Validate log output is expected
s.Contains(get_logs(subT, dockerOptions, expected.name), expected.log, fmt.Sprintf("%s - %s - log should contain matching entry", testCase.name, expected.name))
checkContainerLogsWithRetries(subT, dockerOptions, expected.name, testCase.name, expected.log)
}
})
}
Expand Down
6 changes: 1 addition & 5 deletions tests/integration/compose/docker-compose-legacy-auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,11 +337,7 @@ func (s *commonServicesLegacyAuthDockerComposeUpTest) TestDockerComposeUp() {
}

// Validate log output is expected
s.Contains(
get_logs(subT, dockerOptions, expected.name),
expected.log,
fmt.Sprintf("%s - %s - log should contain matching entry", testCase.name, expected.name),
)
checkContainerLogsWithRetries(subT, dockerOptions, expected.name, testCase.name, expected.log)
}
})
}
Expand Down
Loading