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

Remove assert_pipeline_play #528

Merged
merged 3 commits into from
Feb 16, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* The flow control of the pad is now set with a single `:flow_control` option instead of `:mode` and `:demand_mode` options.
* Remove _t suffix from types [#509](https://github.com/membraneframework/membrane_core/pull/509)
* Implement automatic demands in Membrane Sinks and Endpoints. [#512](https://github.com/membraneframework/membrane_core/pull/512)
* Remove `assert_pipeline_play/2` from `Membrane.Testing.Assertions`. [#528](https://github.com/membraneframework/membrane_core/pull/528)

## 0.11.0
* Separate element_name and pad arguments in handle_element_{start, end}_of_stream signature [#219](https://github.com/membraneframework/membrane_core/issues/219)
Expand Down
4 changes: 0 additions & 4 deletions lib/membrane/testing/assertions.ex
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,6 @@ defmodule Membrane.Testing.Assertions do
assert_receive_from_pipeline(pipeline, :setup, timeout)
end

defmacro assert_pipeline_play(pipeline, timeout \\ @default_timeout) do
assert_receive_from_pipeline(pipeline, :play, timeout)
end

@doc """
Asserts that pipeline received or will receive a message matching
`message_pattern` from another process within the `timeout` period specified
Expand Down
5 changes: 4 additions & 1 deletion test/membrane/core/pipeline_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ defmodule Membrane.Core.PipelineTest do
}

Testing.Pipeline.execute_actions(pid, spec: spec)
assert_pipeline_play(pid)

for payload <- [1, 2, 3] do
assert_sink_buffer(pid, :b, %Membrane.Buffer{payload: ^payload})
end
end
end
9 changes: 0 additions & 9 deletions test/membrane/element_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -76,20 +76,15 @@ defmodule Membrane.ElementTest do
end

test "play", %{pipeline: pipeline} do
assert_pipeline_play(pipeline)
TestFilter.assert_callback_called(:handle_playing)
end

describe "Start of stream" do
test "causes handle_start_of_stream/3 to be called", %{pipeline: pipeline} do
assert_pipeline_play(pipeline)

TestFilter.assert_callback_called(:handle_start_of_stream)
end

test "does not trigger calling callback handle_event/3", %{pipeline: pipeline} do
assert_pipeline_play(pipeline)

TestFilter.refute_callback_called(:handle_event)
end

Expand All @@ -101,14 +96,10 @@ defmodule Membrane.ElementTest do
describe "End of stream" do
@tag :target
test "causes handle_end_of_stream/3 to be called", %{pipeline: pipeline} do
assert_pipeline_play(pipeline)

TestFilter.assert_callback_called(:handle_end_of_stream)
end

test "does not trigger calling callback handle_event/3", %{pipeline: pipeline} do
assert_pipeline_play(pipeline)

TestFilter.refute_callback_called(:handle_event)
end

Expand Down
7 changes: 1 addition & 6 deletions test/membrane/integration/auto_demands_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@ defmodule Membrane.Integration.AutoDemandsTest do
|> child(:sink, Sink)
)

assert_pipeline_play(pipeline)

Enum.each(out_payloads, fn payload ->
assert_sink_buffer(pipeline, :sink, buffer)
assert buffer.payload == payload
Expand All @@ -99,7 +97,6 @@ defmodule Membrane.Integration.AutoDemandsTest do
]
)

assert_pipeline_play(pipeline)
Pipeline.message_child(pipeline, :right_sink, {:make_demand, 1000})

Enum.each(1..1000, fn payload ->
Expand All @@ -124,7 +121,6 @@ defmodule Membrane.Integration.AutoDemandsTest do
]
)

assert_pipeline_play(pipeline)
Process.sleep(500)
Pipeline.execute_actions(pipeline, remove_children: :right_sink)

Expand Down Expand Up @@ -215,7 +211,6 @@ defmodule Membrane.Integration.AutoDemandsTest do
|> child(:sink, Sink)
)

assert_pipeline_play(pipeline)
buffers = Enum.map(1..10, &%Membrane.Buffer{payload: &1})
Pipeline.message_child(pipeline, :source, buffer: {:output, buffers})

Expand Down Expand Up @@ -245,7 +240,7 @@ defmodule Membrane.Integration.AutoDemandsTest do
)

Process.monitor(pipeline)
assert_pipeline_play(pipeline)

buffers = Enum.map(1..100_000, &%Membrane.Buffer{payload: &1})
Pipeline.message_child(pipeline, :source, buffer: {:output, buffers})
assert_receive({:DOWN, _ref, :process, ^pipeline, {:shutdown, :child_crash}})
Expand Down
6 changes: 0 additions & 6 deletions test/membrane/integration/bin_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,6 @@ defmodule Membrane.Core.BinTest do

pipeline = Testing.Pipeline.start_link_supervised!(spec: children)

assert_pipeline_play(pipeline)

assert_pipeline_notified(pipeline, :test_bin, {:handle_element_start_of_stream, :sink, _})

assert_buffers_flow_through(pipeline, buffers, :test_bin)
Expand All @@ -127,8 +125,6 @@ defmodule Membrane.Core.BinTest do

pipeline = Testing.Pipeline.start_link_supervised!(spec: links)

assert_pipeline_play(pipeline)

assert_pipeline_notified(
pipeline,
:test_bin,
Expand Down Expand Up @@ -282,8 +278,6 @@ defmodule Membrane.Core.BinTest do
end

defp assert_data_flows_through(pipeline, buffers, receiving_element \\ :sink) do
assert_pipeline_play(pipeline)

assert_start_of_stream(pipeline, ^receiving_element)

assert_buffers_flow_through(pipeline, buffers, receiving_element)
Expand Down
8 changes: 0 additions & 8 deletions test/membrane/integration/child_crash_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ defmodule Membrane.Integration.ChildCrashTest do
]
|> Enum.map(&get_pid_and_link(&1, pipeline_pid))

assert_pipeline_play(pipeline_pid)

ChildCrashTest.Pipeline.crash_child(filter_1_1_pid)

# assert all members of pipeline and pipeline itself down
Expand All @@ -54,8 +52,6 @@ defmodule Membrane.Integration.ChildCrashTest do
[{Membrane.Child, 1, :source}, :center_filter, :sink]
|> Enum.map(&get_pid_and_link(&1, pipeline_pid))

assert_pipeline_play(pipeline_pid)

Process.exit(source_pid, :crash)
# member of group is dead
assert_pid_dead(source_pid)
Expand Down Expand Up @@ -101,8 +97,6 @@ defmodule Membrane.Integration.ChildCrashTest do
]
|> Enum.map(&get_pid_and_link(&1, pipeline_pid))

assert_pipeline_play(pipeline_pid)

filter_1_pid = get_pid(:filter, bin_1_pid)

ChildCrashTest.Filter.crash(filter_1_pid)
Expand Down Expand Up @@ -164,8 +158,6 @@ defmodule Membrane.Integration.ChildCrashTest do
]
|> Enum.map(&get_pid_and_link(&1, pipeline_pid))

assert_pipeline_play(pipeline_pid)

ChildCrashTest.Pipeline.crash_child(filter_1_1_pid)

# assert all members of group are dead
Expand Down
2 changes: 0 additions & 2 deletions test/membrane/integration/child_removal_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ defmodule Membrane.Integration.ChildRemovalTest do
[:filter1, :filter2, :filter3]
|> Enum.map(&get_filter_pid(&1, pipeline_pid))

assert_pipeline_play(pipeline_pid)
assert_pipeline_notified(pipeline_pid, :filter1, :playing)
assert_pipeline_notified(pipeline_pid, :filter2, :playing)
assert_pipeline_notified(pipeline_pid, :filter3, :playing)
Expand Down Expand Up @@ -95,7 +94,6 @@ defmodule Membrane.Integration.ChildRemovalTest do
[:filter1, :filter2, :filter3]
|> Enum.map(&get_filter_pid(&1, pipeline_pid))

assert_pipeline_play(pipeline_pid)
assert_pipeline_notified(pipeline_pid, :filter1, :playing)
assert_pipeline_notified(pipeline_pid, :filter2, :playing)
assert_pipeline_notified(pipeline_pid, :filter3, :playing)
Expand Down
14 changes: 8 additions & 6 deletions test/membrane/integration/child_spawn_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ defmodule Membrane.Integration.ChildSpawnTest do
|> child(:sink, SinkThatNotifiesParent, get_if_exists: true)

Testing.Pipeline.execute_actions(pipeline_pid, spec: spec)
assert_pipeline_play(pipeline_pid)

refute_pipeline_notified(pipeline_pid, :sink, :message_from_sink)
end

Expand All @@ -95,8 +95,11 @@ defmodule Membrane.Integration.ChildSpawnTest do
child(:source, %Testing.Source{output: [1, 2, 3]})
|> child(:sink, Testing.Sink, get_if_exists: true)

Testing.Pipeline.execute_actions(pipeline_pid, spec: spec, setup: :complete)
assert_pipeline_play(pipeline_pid)
Testing.Pipeline.execute_actions(pipeline_pid, spec: spec)

for payload <- [1, 2, 3] do
assert_sink_buffer(pipeline_pid, :sink, %Buffer{payload: ^payload})
end
end

test "if child/3 doesn't spawn child with a given name if there is already a child with given name among the children
Expand All @@ -112,7 +115,7 @@ defmodule Membrane.Integration.ChildSpawnTest do
|> child(:sink, Testing.Sink)

Testing.Pipeline.execute_actions(pipeline_pid, spec: spec)
assert_pipeline_play(pipeline_pid)

assert_sink_buffer(pipeline_pid, :sink, %Buffer{payload: 1})
assert_sink_buffer(pipeline_pid, :sink, %Buffer{payload: 2})
assert_sink_buffer(pipeline_pid, :sink, %Buffer{payload: 3})
Expand All @@ -134,7 +137,7 @@ defmodule Membrane.Integration.ChildSpawnTest do
|> child(:sink, Testing.Sink, get_if_exists: true)

Testing.Pipeline.execute_actions(pipeline_pid, spec: spec)
assert_pipeline_play(pipeline_pid)

assert_sink_buffer(pipeline_pid, :sink, %Buffer{payload: 1})
assert_sink_buffer(pipeline_pid, :sink, %Buffer{payload: 2})
assert_sink_buffer(pipeline_pid, :sink, %Buffer{payload: 3})
Expand Down Expand Up @@ -193,7 +196,6 @@ defmodule Membrane.Integration.ChildSpawnTest do
pipeline_pid = Testing.Pipeline.start_supervised!()
spec = child(%Testing.Source{output: [1, 2, 3]}) |> child(Testing.Sink)
Testing.Pipeline.execute_actions(pipeline_pid, spec: spec)
assert_pipeline_play(pipeline_pid)

Testing.Pipeline.terminate(pipeline_pid)
end
Expand Down
2 changes: 0 additions & 2 deletions test/membrane/integration/defer_setup_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,6 @@ defmodule Membrane.Integration.DeferSetupTest do
|> child(:bin_2, %Bin{defer_play: false})
)

assert_pipeline_play(pipeline)

for bin <- [:bin_1, :bin_2] do
refute_child_playing(pipeline, bin)
end
Expand Down
1 change: 0 additions & 1 deletion test/membrane/integration/demands_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ defmodule Membrane.Integration.DemandsTest do

defp test_pipeline(pid) do
pattern_gen = fn i -> %Buffer{payload: <<i::16>> <> <<255>>} end
assert_pipeline_play(pid)

demand = 500
Pipeline.message_child(pid, :sink, {:make_demand, demand})
Expand Down
2 changes: 1 addition & 1 deletion test/membrane/integration/distributed_pipeline_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ defmodule Membrane.Integration.DistributedPipelineTest do
end

pipeline = Membrane.Testing.Pipeline.start_link_supervised!(module: Pipeline)
assert_pipeline_play(pipeline)

assert_end_of_stream(pipeline, :sink)
end

Expand Down
2 changes: 0 additions & 2 deletions test/membrane/integration/elements_compatibility_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,6 @@ defmodule Membrane.Integration.ElementsCompatibilityTest do
|> child(sink_module.__struct__(test_pid: self()))
)

assert_pipeline_play(pid)

state_dump =
receive do
{:state_dump, state_dump} -> state_dump
Expand Down
2 changes: 0 additions & 2 deletions test/membrane/integration/endpoint_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ defmodule Membrane.Core.EndpointTest do
end

defp assert_data_flows_through(pipeline, buffers, receiving_element) do
assert_pipeline_play(pipeline)

assert_start_of_stream(pipeline, ^receiving_element)

buffers
Expand Down
2 changes: 0 additions & 2 deletions test/membrane/integration/linking_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ defmodule Membrane.Integration.LinkingTest do
source_pid = get_child_pid(:source, bin_pid)
source_ref = Process.monitor(source_pid)

assert_pipeline_play(pipeline)
Process.exit(sink_pid, :kill)
assert_pipeline_crash_group_down(pipeline, :group_2)

Expand Down Expand Up @@ -286,7 +285,6 @@ defmodule Membrane.Integration.LinkingTest do
spec = [bin_spec, sink_spec, links_spec]
send(pipeline, {:start_spec, %{spec: spec}})
assert_receive(:spec_started)
assert_pipeline_play(pipeline)
end

defmodule SlowSetupSink do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ defmodule Membrane.FailWhenNoStreamFormatAreSent do
end

source_ref = Process.monitor(source_pid)
assert_pipeline_play(pipeline)

Pipeline.message_child(pipeline, :source, :send_buffer)
assert_receive {:DOWN, ^source_ref, :process, ^source_pid, {reason, _stack_trace}}
assert %Membrane.ElementError{message: action_error_msg} = reason
Expand Down
1 change: 0 additions & 1 deletion test/membrane/integration/sync_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ defmodule Membrane.Integration.SyncTest do

pipeline = Testing.Pipeline.start_link_supervised!(options)

assert_pipeline_play(pipeline)
send(pipeline, {:spawn_children, spec})

assert_start_of_stream(pipeline, :sink_a)
Expand Down
2 changes: 0 additions & 2 deletions test/membrane/integration/timer_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ defmodule Membrane.Integration.TimerTest do
custom_args: self()
)

assert_pipeline_play(pipeline)
assert_pipeline_notified(pipeline, :element, :tick)
assert_pipeline_notified(pipeline, :bin, :tick)
assert_receive :pipeline_tick
Expand All @@ -87,7 +86,6 @@ defmodule Membrane.Integration.TimerTest do
test "Stopping timer with `:no_interval`" do
pipeline = Testing.Pipeline.start_link_supervised!(spec: [child(:element, StopNoInterval)])

assert_pipeline_play(pipeline)
assert_pipeline_notified(pipeline, :element, :ok)
Testing.Pipeline.terminate(pipeline)
end
Expand Down
2 changes: 0 additions & 2 deletions test/membrane/testing/dynamic_source_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ defmodule Membrane.Testing.DynamicSourceTest do
]
)

assert_pipeline_play(pipeline)
assert_sink_buffer(pipeline, :sink_1, %Buffer{payload: 'a'})
assert_sink_buffer(pipeline, :sink_1, %Buffer{payload: 'b'})
assert_sink_buffer(pipeline, :sink_1, %Buffer{payload: 'c'})
Expand All @@ -63,7 +62,6 @@ defmodule Membrane.Testing.DynamicSourceTest do
]
)

assert_pipeline_play(pipeline)
assert_sink_buffer(pipeline, :sink_1, %Buffer{payload: <<0::16>>})
assert_sink_buffer(pipeline, :sink_1, %Buffer{payload: <<1::16>>})
assert_sink_buffer(pipeline, :sink_1, %Buffer{payload: <<2::16>>})
Expand Down
9 changes: 0 additions & 9 deletions test/membrane/testing/pipeline_assertions_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,6 @@ defmodule Membrane.Testing.PipelineAssertionsTest do
end
end

test "assert_pipeline_play works", %{state: state} do
Pipeline.handle_playing(context(), state)
assert_pipeline_play(self())

assert_raise ExUnit.AssertionError, fn ->
assert_pipeline_play(self(), 0)
end
end

describe "assert_pipeline_receive" do
test "does not flunk when pipeline receives a message", %{state: state} do
message = "I am an important message"
Expand Down
2 changes: 0 additions & 2 deletions test/membrane/testing/pipeline_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,6 @@ defmodule Membrane.Testing.PipelineTest do

pipeline = Pipeline.start_supervised!(spec: spec)

assert_pipeline_play(pipeline)

# getting children pids from pipeline
for bin <- [:bin_1, :bin_2, :bin_3] do
Pipeline.execute_actions(pipeline, notify_child: {bin, {:get_pid, bin}})
Expand Down