membrane_core icon indicating copy to clipboard operation
membrane_core copied to clipboard

Buffer ordering in testing pipeline

Open mat-hek opened this issue 4 years ago • 2 comments

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.

mat-hek avatar Mar 19 '20 14:03 mat-hek

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.

mat-hek avatar Mar 19 '20 18:03 mat-hek

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)

bblaszkow06 avatar Mar 20 '20 15:03 bblaszkow06

Moved to https://github.com/orgs/membraneframework/discussions/715

mat-hek avatar Jan 19 '24 15:01 mat-hek