Skip to content

oteltest: tests written with CheckReceivers take too long to run #45368

@mauri870

Description

@mauri870

We have a small unit test suite called oteltest.CheckReceivers that simulates a otel collector so we can run beats receivers and make assertions on behavior and side effects.

If we look at the execution time of one of these tests:

go test -timeout 5m -tags integration,unit -run '^TestNewReceiver$' ./x-pack/filebeat/fbreceiver -v -count=1
=== RUN   TestNewReceiver
--- PASS: TestNewReceiver (13.12s)
PASS
ok      github.com/elastic/beats/v7/x-pack/filebeat/fbreceiver  13.156s

This single test alone takes 13s to run, that is fairly long for a simple unit test.

If we compare with one of our real integration tests with filebeat otel:

cd x-pack/filebeat/
go test -c -tags otelbeat
mage docker:composeUp
go test   -tags "integration" -run 'TestFilebeatOTelE2E' ./tests/integration -v -count=1
=== RUN   TestFilebeatOTelE2E
--- PASS: TestFilebeatOTelE2E (5.74s)
PASS

That's less than 6 seconds for a full integration test that spawns a process with a real OTel collector, starts it, and successfully ingests data into an Elasticsearch instance.

Something isn’t quite right with our oteltest suite — it should be much faster than it currently is. The goal is to investigate further, identify why it's taking so long, and make the necessary adjustments to speed it up. Fast prototyping is crucial when working with receivers, so we should aim to keep unit tests relatively fast to ensure they remain relevant to our workflow.

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions