Skip to content

Commit

Permalink
Using ddebpf.Manager instead of manager.Manager in consumer_test.go
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielLavie committed Dec 19, 2024
1 parent 22022a5 commit 3030851
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions pkg/network/protocols/events/consumer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"time"
"unsafe"

ebpftelemetry "github.com/DataDog/datadog-agent/pkg/ebpf/telemetry"
manager "github.com/DataDog/ebpf-manager"
"github.com/cilium/ebpf"
"github.com/cilium/ebpf/features"
Expand Down Expand Up @@ -53,15 +54,15 @@ func TestConsumer(t *testing.T) {
}
}

consumer, err := NewConsumer("test", program, callback)
consumer, err := NewConsumer("test", program.Manager, callback)
require.NoError(t, err)
consumer.Start()

err = program.Start()
require.NoError(t, err)

// generate test events
generator := newEventGenerator(program, t)
generator := newEventGenerator(program.Manager, t)
for i := 0; i < numEvents; i++ {
generator.Generate(uint64(i))
}
Expand Down Expand Up @@ -92,7 +93,7 @@ func TestInvalidBatchCountMetric(t *testing.T) {
require.NoError(t, err)
t.Cleanup(func() { program.Stop(manager.CleanAll) })

consumer, err := NewConsumer("test", program, func([]uint64) {})
consumer, err := NewConsumer("test", program.Manager, func([]uint64) {})
require.NoError(t, err)

// We are creating a raw sample with a data length of 4, which is smaller than sizeOfBatch
Expand Down Expand Up @@ -172,7 +173,7 @@ func (e *eventGenerator) Stop() {
e.testFile.Close()
}

func newEBPFProgram(c *config.Config) (*manager.Manager, error) {
func newEBPFProgram(c *config.Config) (*ddebpf.Manager, error) {
bc, err := bytecode.GetReader(c.BPFDir, "usm_events_test-debug.o")
if err != nil {
return nil, err
Expand Down Expand Up @@ -208,11 +209,13 @@ func newEBPFProgram(c *config.Config) (*manager.Manager, error) {
},
}

Configure(config.New(), "test", m, &options)
ddEbpfManager := ddebpf.NewManager(m, "usm", &ebpftelemetry.ErrorsTelemetryModifier{})

Configure(config.New(), "test", ddEbpfManager.Manager, &options)
err = m.InitWithOptions(bc, options)
if err != nil {
return nil, err
}

return m, nil
return ddEbpfManager, nil
}

0 comments on commit 3030851

Please sign in to comment.