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

Fix the bug with pipeline persisting in Zombie mode after self-terminating with terminate: :normal action #538

Merged
merged 5 commits into from
Mar 17, 2023
Merged
Show file tree
Hide file tree
Changes from 4 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
2 changes: 2 additions & 0 deletions lib/membrane/core/parent/lifecycle_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ defmodule Membrane.Core.Parent.LifecycleController do

@spec handle_terminate(Parent.state()) :: {:continue | :stop, Parent.state()}
def handle_terminate(state) do
state = %{state | terminating?: true}

if Enum.empty?(state.children) do
{:stop, state}
else
Expand Down
10 changes: 10 additions & 0 deletions test/membrane/core/pipeline_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,16 @@ defmodule Membrane.Core.PipelineTest do
end)
end

test "Pipeline should be able to terminate itself with terminate: :normal action when it has already spawned children" do
pid = Testing.Pipeline.start_supervised!(module: TestPipeline)
Process.monitor(pid)
spec = child(:source, %Testing.Source{output: [1, 2, 3]}) |> child(:sink, Testing.Sink)
Testing.Pipeline.execute_actions(pid, spec: spec)
assert_end_of_stream(pid, :sink)
Testing.Pipeline.execute_actions(pid, terminate: :normal)
assert_receive {:DOWN, _ref, :process, ^pid, :normal}
end

test "Pipeline should be able to spawn its children in a nested specification" do
pid = Testing.Pipeline.start_link_supervised!(module: TestPipeline)
opts1 = []
Expand Down
10 changes: 5 additions & 5 deletions test/membrane/element_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,16 @@ defmodule Membrane.ElementTest do
[pipeline: pipeline]
end

test "play", %{pipeline: pipeline} do
test "play", %{} do
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
test "causes handle_start_of_stream/3 to be called", %{} do
varsill marked this conversation as resolved.
Show resolved Hide resolved
TestFilter.assert_callback_called(:handle_start_of_stream)
end

test "does not trigger calling callback handle_event/3", %{pipeline: pipeline} do
test "does not trigger calling callback handle_event/3", %{} do
TestFilter.refute_callback_called(:handle_event)
end

Expand All @@ -94,11 +94,11 @@ defmodule Membrane.ElementTest do
end

describe "End of stream" do
test "causes handle_end_of_stream/3 to be called", %{pipeline: pipeline} do
test "causes handle_end_of_stream/3 to be called", %{} do
TestFilter.assert_callback_called(:handle_end_of_stream)
end

test "does not trigger calling callback handle_event/3", %{pipeline: pipeline} do
test "does not trigger calling callback handle_event/3", %{} do
TestFilter.refute_callback_called(:handle_event)
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ defmodule Membrane.Integration.ElementsCompatibilityTest do
use ExUnit.Case, async: true

import Membrane.ChildrenSpec
import Membrane.Testing.Assertions
alias Membrane.Testing.Pipeline

defmodule StreamFormat do
Expand Down