Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Flaky Test]: TestActionDispatcher/Dispatch_multiples_events_returns_one_error – Expected error #4937

Closed
rdner opened this issue Jun 14, 2024 · 6 comments · Fixed by #5366
Assignees
Labels
flaky-test Unstable or unreliable test cases. Team:Elastic-Agent Label for the Agent team Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team

Comments

@rdner
Copy link
Member

rdner commented Jun 14, 2024

Failing test case

TestActionDispatcher/Dispatch_multiples_events_returns_one_error

Error message

dispatcher_test.go:393: Expected error

Build

https://buildkite.com/elastic/elastic-agent/builds/9615#0190110f-0b1c-45ba-81d9-c1406e137e09

OS

Mac

Stacktrace and notes

=== Failed
=== FAIL: internal/pkg/agent/application/dispatcher TestActionDispatcher/Dispatch_multiples_events_returns_one_error (0.52s)
    dispatcher_test.go:393: Expected error
=== FAIL: internal/pkg/agent/application/dispatcher TestActionDispatcher (1.52s)
@rdner rdner added Team:Elastic-Agent Label for the Agent team flaky-test Unstable or unreliable test cases. labels Jun 14, 2024
@elasticmachine
Copy link
Contributor

Pinging @elastic/elastic-agent (Team:Elastic-Agent)

@rdner
Copy link
Member Author

rdner commented Jun 14, 2024

@rdner
Copy link
Member Author

rdner commented Jun 18, 2024

@pchila
Copy link
Member

pchila commented Jun 18, 2024

Given the long times for the unit tests run on Mac for the builds where It failed, I guess that the 200 ms sleeps we have are not enough (in a well designed unit test we should not rely on time.Sleep to make things work but it's at least marked as a workaround in code)

// Kind of a dirty work around to test an error return.
// launch in another routing and sleep to check if an error is generated
dispatchCtx, cancelFn := context.WithCancel(context.Background())
defer cancelFn()
go d.Dispatch(dispatchCtx, detailsSetter, ack, action1, action2)
time.Sleep(time.Millisecond * 200)
select {
case <-d.Errors():
default:
t.Fatal("Expected error")
}
time.Sleep(time.Millisecond * 200)
select {
case <-d.Errors():
t.Fatal(err)
default:
}

These should probably replaced by longer timeouts in the select statements instead of the default case, even better if we could rely on a global unit test timeout of a few seconds (if we find one that is reliable enough without being too long) and block on the errors channel

@ycombinator ycombinator added the Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team label Jun 21, 2024
@elasticmachine
Copy link
Contributor

Pinging @elastic/elastic-agent-control-plane (Team:Elastic-Agent-Control-Plane)

@ycombinator
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flaky-test Unstable or unreliable test cases. Team:Elastic-Agent Label for the Agent team Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team
Projects
None yet
6 participants