Skip to content

Commit

Permalink
fix integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
spiffyy99 committed Jan 3, 2025
1 parent 660b0b5 commit 9ee8eb8
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
20 changes: 18 additions & 2 deletions receiver/dockerstatsreceiver/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,13 +250,21 @@ func TestContainerLifecycleEventsIntegration(t *testing.T) {
require.NoError(t, nginxContainer.Terminate(ctx))

assert.Eventuallyf(t, func() bool {
return hasDockerEvents(consumer.AllLogs(), redisID, []string{
return hasDockerEvents(consumer.AllLogs(), nginxID, []string{
"docker.container.die",
"docker.container.stop",
})
}, 5*time.Second, 1*time.Second, "failed to receive container stop/die events")

consumer.Reset()
require.NoError(t, redisContainer.Terminate(ctx))

assert.Eventuallyf(t, func() bool {
return hasDockerEvents(consumer.AllLogs(), redisID, []string{
"docker.container.die",
"docker.container.stop",
})
}, 5*time.Second, 1*time.Second, "failed to receive container stop/die events")
assert.NoError(t, recv.Shutdown(ctx))
}

Expand All @@ -268,7 +276,7 @@ func TestFilteredContainerEventsIntegration(t *testing.T) {
f, config := factory()
// Only receive events from redis containers
config.Logs.Filters = map[string][]string{
"image": {"*redis*"},
"image": {"docker.io/library/redis:latest"},
}

consumer := new(consumertest.LogsSink)
Expand All @@ -295,8 +303,16 @@ func TestFilteredContainerEventsIntegration(t *testing.T) {
})
}, 5*time.Second, 1*time.Second, "failed to receive redis container events")

consumer.Reset()
require.NoError(t, nginxContainer.Terminate(ctx))
require.NoError(t, redisContainer.Terminate(ctx))
assert.Eventuallyf(t, func() bool {
return hasDockerEvents(consumer.AllLogs(), redisID, []string{
"docker.container.die",
"docker.container.stop",
})
}, 5*time.Second, 1*time.Second, "failed to receive container stop/die events")

assert.NoError(t, recv.Shutdown(ctx))
}

Expand Down
11 changes: 7 additions & 4 deletions receiver/dockerstatsreceiver/logs_receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,13 @@ func newDockerEventPoller(
}

func (d *dockerEventPoller) Start(ctx context.Context) {
filterArgs := filters.NewArgs()
for k, v := range d.config.Logs.Filters {
for _, elem := range v {
filterArgs.Add(k, elem)
filterArgs := filters.Args{}
if len(d.config.Logs.Filters) > 0 {
filterArgs = filters.NewArgs()
for k, v := range d.config.Logs.Filters {
for _, elem := range v {
filterArgs.Add(k, elem)
}
}
}
for {
Expand Down

0 comments on commit 9ee8eb8

Please sign in to comment.