thbar

thbar

Proper way to test Membrane pipelines?

Hi there,

As I’m starting to implement Membrane pipelines (initially as one-off scripts like the one below), I wonder what are the good pipeline testing strategies?

I am more interested by pipelines testing (where the SUT = System Under Test is the pipeline itself, which is supervised in the example) than by individual components, where I have pretty good ideas on how to do that.

With this example:

Mix.install([
  :membrane_hackney_plugin,
  :membrane_mp3_mad_plugin,
  :membrane_portaudio_plugin
])

defmodule MyPipeline do
  use Membrane.Pipeline

  @impl true
  def handle_init(_ctx, mp3_url) do
    spec =
      child(%Membrane.Hackney.Source{
        location: mp3_url,
        hackney_opts: [follow_redirect: true]
      })
      |> child(Membrane.MP3.MAD.Decoder)
      |> child(Membrane.PortAudio.Sink)

    {[spec: spec], %{}}
  end
end

mp3_url =
  "https://raw.githubusercontent.com/membraneframework/membrane_demo/master/simple_pipeline/sample.mp3"

Membrane.Pipeline.start_link(MyPipeline, mp3_url)

What testing can be done?

I realise that ultimately I will use a “test sink” for these tests, and also mock out the HTTP source, but you see the general idea.

I will look into the Membrane codebase, but happy to bounce ideas here.

Most Liked

mat-hek

mat-hek

Membrane Core Team

:wave: When testing pipelines, I try to avoid mocking and create E2E tests whenever possible :wink: I use snapshot testing extensively as well. In this case, I’d set up a simple HTTP server based on Bandit or inets that would serve the mp3 and a virtual sound card that would capture the output and save it to a file. At first, you can manually play the file and ensure it’s correct. Then, you can use it as a snapshot to compare automatically. I think If we had an HTTP source based on Req, it would be easier to test, as Req seems to have great testing features built-in :thinking:

Testing source and sink are actually useful for making artificial pipelines to test particular elements by feeding them with specific inputs and asserting on outputs. If you replace elements in a real pipeline with them, remember that you only test a part of the original pipeline.

Where Next?

Popular in Questions Top

rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New

Other popular topics Top

KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 36654 110
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
chrismccord
Phoenix 1.4.0 released Phoenix 1.4 is out! This release ships with exciting new features, most notably with HTTP2 support, improved deve...
688 31494 112
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
sergio
Kind of like when jquery came out, it was super necessary. Existing drag and drop libraries have a bunch of baggage to support old browse...
New

We're in Beta

About us Mission Statement