diff --git a/test/new-e2e/tests/agent-metrics-logs/log-agent/listener/listener_test.go b/test/new-e2e/tests/agent-metrics-logs/log-agent/listener/listener_test.go index aacabae8032754..6a11c2f7d28528 100644 --- a/test/new-e2e/tests/agent-metrics-logs/log-agent/listener/listener_test.go +++ b/test/new-e2e/tests/agent-metrics-logs/log-agent/listener/listener_test.go @@ -115,5 +115,4 @@ func assertLogsReceived( t.Logf("stdout:\n\n%s\n\nstderr:\n\n%s", stdout, stderr) utils.CheckLogsExpected(t, fakeIntake, "test-app", "bob", []string{sourceHostTag}) - utils.CheckNoDuplicateTags(t, fakeIntake, "test-app", "bob") } diff --git a/test/new-e2e/tests/agent-metrics-logs/log-agent/utils/file_tailing_utils.go b/test/new-e2e/tests/agent-metrics-logs/log-agent/utils/file_tailing_utils.go index f253b7eadc6ee4..4805a6ac8e6127 100644 --- a/test/new-e2e/tests/agent-metrics-logs/log-agent/utils/file_tailing_utils.go +++ b/test/new-e2e/tests/agent-metrics-logs/log-agent/utils/file_tailing_utils.go @@ -148,7 +148,7 @@ func FetchAndFilterLogs(fakeIntake *components.FakeIntake, service, content stri return logs, nil } -// CheckLogsExpected verifies the presence of expected logs. +// CheckLogsExpected verifies the presence of expected logs, and verifies that there are no duplicate tags. func CheckLogsExpected(t *testing.T, fakeIntake *components.FakeIntake, service, content string, expectedTags ddtags) { t.Helper() @@ -160,27 +160,6 @@ func CheckLogsExpected(t *testing.T, fakeIntake *components.FakeIntake, service, if assert.NotEmpty(c, logs, "Expected logs with content: '%s' not found. Instead, found: %s", content, intakeLog) { t.Logf("Logs from service: '%s' with content: '%s' collected", service, content) log := logs[0] - for _, expectedTag := range expectedTags { - assert.Contains(t, log.Tags, expectedTag) - } - } - } - }, 2*time.Minute, 10*time.Second) -} - -// CheckNoDuplicateTags verifies that there is no duplicate tags -func CheckNoDuplicateTags(t *testing.T, fakeIntake *components.FakeIntake, service, content string) { - t.Helper() - - assert.EventuallyWithT(t, func(c *assert.CollectT) { - logs, err := FetchAndFilterLogs(fakeIntake, service, content) - - if assert.NoErrorf(c, err, "Error fetching logs: %s", err) { - intakeLog := logsToString(logs) - if assert.NotEmpty(c, logs, "Expected logs with content: '%s' not found. Instead, found: %s", content, intakeLog) { - t.Logf("Logs from service: '%s' with content: '%s' collected", service, content) - log := logs[0] - // Use a map to check for duplicate tags seenTags := make(map[string]struct{}) for _, tag := range log.Tags { @@ -189,6 +168,9 @@ func CheckNoDuplicateTags(t *testing.T, fakeIntake *components.FakeIntake, servi } seenTags[tag] = struct{}{} // Mark the tag as seen } + for _, expectedTag := range expectedTags { + assert.Contains(t, log.Tags, expectedTag) + } } } }, 2*time.Minute, 10*time.Second)