membrane_core
membrane_core copied to clipboard
Buffer ordering in testing pipeline
The standard way to validate buffers in integration tests is to end the pipeline with the testing sink and do assertions like assert_sink_buffer(pipeline, sink, %Buffer{...})
. However, making multiple assertions like that doesn't guarantee that buffers come in in the order of those assertions. I suppose we should provide a mechanism to retrieve all the needed buffers/events/notifications as a list to be able to assert on whatever feature needed.
What is more, to make sure no other buffer came apart from the asserted ones, refute_sink_buffer(pipeline, sink, _)
has to be used. This, however, waits for two seconds by default, making tests execute longer.
As @bblaszkow06 pointed out, this can be solved by doing
assert_sink_buffer(pipeline, :sink, buffer)
assert %Buffer{...} = buffer
and waiting can be avoided by
assert_end_of_stream(pipeline, :sink)
refute_sink_buffer(pipeline, :sink, _, 0)
But still, in my opinion, that should be simpler or even default. Also, the possibility to retrieve multiple messages at once would be useful in many cases.
It won't help when we'd like to ensure the order of events in relation to buffers. What I think we should do instead, is to store all the received buffers and events within Testing.Sink, assert on EoS and then obtain the data from the element (either "manually" by sending a message and awaiting response or by sending the data from Testing.Sink on EoS)
Moved to https://github.com/orgs/membraneframework/discussions/715