From fde624763f608e9995709db21fbc9ed120325fb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Wala?= Date: Thu, 15 Jun 2023 12:37:45 +0200 Subject: [PATCH 1/7] Improvements in docs, fix inconsistent component/peer type format --- README.md | 14 +++++----- lib/jellyfish/client.ex | 6 ++--- lib/jellyfish/component.ex | 37 ++++++++------------------- lib/jellyfish/component/hls.ex | 3 ++- lib/jellyfish/component/rtsp.ex | 3 ++- lib/jellyfish/notifier.ex | 15 ++++++----- lib/jellyfish/peer.ex | 45 +++++++++------------------------ lib/jellyfish/peer/webrtc.ex | 3 ++- lib/jellyfish/room.ex | 12 ++++----- mix.exs | 5 +++- protos | 2 +- 11 files changed, 57 insertions(+), 88 deletions(-) diff --git a/README.md b/README.md index 2a6d8f3..9a81cf7 100644 --- a/README.md +++ b/README.md @@ -23,10 +23,6 @@ def deps do end ``` -## Testing - -When calling `mix test` it will automatically start the Jellyfish container under the hood. But tests on CI are run with the use of docker-compose, to run it locally in the same way as on CI you can use command `mix integration_test`. - ## Usage Make API calls to Jellyfish (authentication required, for more information see [Jellyfish docs](https://jellyfish-dev.github.io/jellyfish-docs/getting_started/authentication)) @@ -34,10 +30,10 @@ and receive server notifications: ```elixir # start process responsible for receiving notifications -{:ok, _pid} = Jellyfish.Notifier.start(server_address: "address-of-your-server.com", server_api_key: "your-jellyfish-token") +{:ok, _pid} = Jellyfish.Notifier.start(server_address: "localhost:5002", server_api_key: "your-jellyfish-token") # create HTTP client instance -client = Jellyfish.Client.new(server_address: "address-of-your-server.com", server_api_key: "your-jellyfish-token") +client = Jellyfish.Client.new(server_address: "localhost:5002", server_api_key: "your-jellyfish-token") # Create room {:ok, %Jellyfish.Room{id: room_id}} = Jellyfish.Room.create(client, max_peers: 10) @@ -49,7 +45,7 @@ room_id {:ok, %Jellyfish.Peer{id: peer_id}, peer_token} = Jellyfish.Room.add_peer(client, room_id, Jellyfish.Peer.WebRTC) receive do - {:jellyfish, %Jellyfish.Server.ControlMessage.PeerConnected{room_id: ^room_id, peer_id: ^peer_id} -> + {:jellyfish, %Jellyfish.ServerMessage.PeerConnected{room_id: ^room_id, peer_id: ^peer_id}} -> # handle the notification end @@ -59,6 +55,10 @@ end List of structs representing server notifications can be found in [generated Protobuf file](lib/protos/jellyfish/server_notifications.pb.ex). +## Testing + +When calling `mix test` it will automatically start the Jellyfish container under the hood. But tests on CI are run with the use of docker-compose, to run it locally in the same way as on CI you can use command `mix integration_test`. + ## Copyright and License Copyright 2023, [Software Mansion](https://swmansion.com/?utm_source=git&utm_medium=readme&utm_campaign=jellyfish) diff --git a/lib/jellyfish/client.ex b/lib/jellyfish/client.ex index 6cc42d7..fad43e0 100644 --- a/lib/jellyfish/client.ex +++ b/lib/jellyfish/client.ex @@ -31,7 +31,7 @@ defmodule Jellyfish.Client do @typedoc """ Options needed to open connection to Jellyfish server. - * `:server_address` - url or IP address of the Jellyfish server instance. + * `:server_address` - address of the Jellyfish server instance. * `:server_api_token` - token used for authorizing HTTP requests and WebSocket connection. It's the same token as the one configured in Jellyfish. * `:secure?` - if `true`, use HTTPS and WSS instead of HTTP and WS, `false` by default. @@ -39,8 +39,8 @@ defmodule Jellyfish.Client do When an option is not explicily passed, value set in `config.exs` is used: ``` # in config.exs - config :jellyfish_server_sdk, - server_address: "you-jellyfish-server-address.com", + config :jellyfish_server_sdk, + server_address: "localhost:5002", server_api_token: "your-jellyfish-token", secure?: true ``` diff --git a/lib/jellyfish/component.ex b/lib/jellyfish/component.ex index 51eaa7c..81863e5 100644 --- a/lib/jellyfish/component.ex +++ b/lib/jellyfish/component.ex @@ -3,7 +3,7 @@ defmodule Jellyfish.Component do Defines `t:Jellyfish.Component.t/0`. Component is a server-side entity that can publish, subscribe to and process tracks. - For more information refer to [Jellyfish documentation](https://www.membrane.stream) + For more information refer to [Jellyfish documentation](https://jellyfish-dev.github.io/jellyfish-docs/introduction/basic_concepts). """ alias Jellyfish.Component.{HLS, RTSP} @@ -22,23 +22,14 @@ defmodule Jellyfish.Component do @typedoc """ Type of the component. - - For more information refer to [Jellyfish documentation](https://jellyfish-dev.github.io/jellyfish-docs/). """ - @type type :: :hls | :rtsp + @type type :: HLS | RTSP @typedoc """ Component-specific options. - - For the list of available options, refer to [Jellyfish documentation](https://jellyfish-dev.github.io/jellyfish-docs/). """ @type options :: HLS.t() | RTSP.t() - @typedoc """ - Component options module. - """ - @type options_module :: HLS | RTSP - @typedoc """ Stores information about the component. """ @@ -47,8 +38,6 @@ defmodule Jellyfish.Component do type: type() } - @valid_type_strings ["hls", "rtsp"] - @doc false @spec from_json(map()) :: t() def from_json(response) do @@ -68,20 +57,14 @@ defmodule Jellyfish.Component do end @doc false - @spec type_from_options(struct()) :: type() - def type_from_options(component) do - case component do - %HLS{} -> :hls - %RTSP{} -> :rtsp - _other -> raise "Invalid component options struct" - end - end + @spec type_from_string(String.t()) :: type() + def type_from_string("hls"), do: HLS + def type_from_string("rtsp"), do: RTSP + def type_from_string(_type), do: raise("Invalid component type string") @doc false - @spec type_from_string(String.t()) :: type() - def type_from_string(string) do - if string in @valid_type_strings, - do: String.to_atom(string), - else: raise("Invalid component type string") - end + @spec string_from_options(struct()) :: String.t() + def string_from_options(%HLS{}), do: "hls" + def string_from_options(%RTSP{}), do: "rtsp" + def string_from_options(_struct), do: raise("Invalid component struct") end diff --git a/lib/jellyfish/component/hls.ex b/lib/jellyfish/component/hls.ex index 7f53ae4..740dcc6 100644 --- a/lib/jellyfish/component/hls.ex +++ b/lib/jellyfish/component/hls.ex @@ -2,7 +2,8 @@ defmodule Jellyfish.Component.HLS do @moduledoc """ Options for the HLS component. - For the description of these options refer to [Jellyfish documentation](https://jellyfish-dev.github.io/jellyfish-docs/getting_started/components/hls) + For the description of these options refer to [Jellyfish + documentation](https://jellyfish-dev.github.io/jellyfish-docs/getting_started/components/hls). """ @enforce_keys [] diff --git a/lib/jellyfish/component/rtsp.ex b/lib/jellyfish/component/rtsp.ex index 21d7579..c096cf6 100644 --- a/lib/jellyfish/component/rtsp.ex +++ b/lib/jellyfish/component/rtsp.ex @@ -2,7 +2,8 @@ defmodule Jellyfish.Component.RTSP do @moduledoc """ Options for the RTSP component. - For the description of these options refer to [Jellyfish documentation](https://jellyfish-dev.github.io/jellyfish-docs/getting_started/components/rtsp) + For the description of these options refer to [Jellyfish + documentation](https://jellyfish-dev.github.io/jellyfish-docs/getting_started/components/rtsp). """ @enforce_keys [:source_uri] diff --git a/lib/jellyfish/notifier.ex b/lib/jellyfish/notifier.ex index 0d5ab3c..dd0339f 100644 --- a/lib/jellyfish/notifier.ex +++ b/lib/jellyfish/notifier.ex @@ -4,16 +4,17 @@ defmodule Jellyfish.Notifier do WebSocket connection and receiving notifications form Jellyfish server. ``` - iex> {:ok, pid} = Jellyfish.Notifier.start(server_address: "address-of-jellyfish-server.com", server_api_token: "your-jellyfish-token") + iex> {:ok, pid} = Jellyfish.Notifier.start(server_address: "localhost:5002", server_api_token: "your-jellyfish-token") {:ok, #PID<0.301.0>} # here add a room and a peer using functions from `Jellyfish.Room` module # you should receive a notification after the peer established connection iex> flush() - {:jellyfish, - {:peer_connected, "21604fbe-8ac8-44e6-8474-98b5f50f1863", - "ae07f94e-0887-44c3-81d5-bfa9eac96252"}} + {:jellyfish, %Jellyfish.ServerMessage.PeerConnected{ + room_id: "21604fbe-8ac8-44e6-8474-98b5f50f1863", + peer_id: "ae07f94e-0887-44c3-81d5-bfa9eac96252" + }} :ok ``` """ @@ -48,9 +49,9 @@ defmodule Jellyfish.Notifier do Starts the Notifier process and connects to Jellyfish. Received notifications are send to the calling process in - a form of `{:jellyfish, msg}`, where `msg` is - `type` or `{type, room_id}` or `{type, room_id, (peer/component)_id}`. - Refer to [Jellyfish docs](https://jellyfish-dev.github.io/jellyfish-docs/) to learn more about server notifications. + a form of `{:jellyfish, msg}`, where `msg` is one of the structs defined in + `lib/proto/jellyfish/server_notifications.pb.ex`, + for example `{:jellyfish, %Jellyfish.ServerMessage.RoomCrashed{room_id: "some_id"}}` For information about options, see `t:Jellyfish.Client.connection_options/0`. """ diff --git a/lib/jellyfish/peer.ex b/lib/jellyfish/peer.ex index e28b5a3..b05f29d 100644 --- a/lib/jellyfish/peer.ex +++ b/lib/jellyfish/peer.ex @@ -4,7 +4,7 @@ defmodule Jellyfish.Peer do Peer is an entity that connects to the server to publish, subscribe to or publish and subscribe to tracks published by components and other peers. - For more information refer to [Jellyfish documentation](https://www.membrane.stream) + For more information refer to [Jellyfish documentation](https://jellyfish-dev.github.io/jellyfish-docs/introduction/basic_concepts). """ alias Jellyfish.Exception.StructureError @@ -24,17 +24,11 @@ defmodule Jellyfish.Peer do @typedoc """ Type of the peer. - - For more information refer to [Jellyfish documentation](https://jellyfish-dev.github.io/jellyfish-docs/). """ - @type type :: :webrtc - - @valid_type_strings ["webrtc"] + @type type :: WebRTC @typedoc """ Status of the peer. - - For more information refer to [Jellyfish documentation](https://jellyfish-dev.github.io/jellyfish-docs/). """ @type status :: :disconnected | :connected @@ -42,16 +36,9 @@ defmodule Jellyfish.Peer do @typedoc """ Peer-specific options. - - For the list of available options, refer to [Jellyfish documentation](https://jellyfish-dev.github.io/jellyfish-docs/). """ @type options :: WebRTC.t() - @typedoc """ - Peer options module. - """ - @type options_module :: WebRTC - @typedoc """ Stores information about the peer. """ @@ -82,27 +69,19 @@ defmodule Jellyfish.Peer do end @doc false - @spec type_from_options(struct()) :: type() - def type_from_options(peer) do - case peer do - %WebRTC{} -> :webrtc - _other -> raise "Invalid peer options struct" - end - end + @spec type_from_string(String.t()) :: type() + def type_from_string("webrtc"), do: WebRTC + def type_from_string(_type), do: raise("Invalid peer type string") @doc false - @spec type_from_string(String.t()) :: type() - def type_from_string(string) do - if string in @valid_type_strings, - do: String.to_atom(string), - else: raise("Invalid peer type string") - end + @spec string_from_options(struct()) :: String.t() + def string_from_options(%WebRTC{}), do: "webrtc" + def string_from_options(_struct), do: raise("Invalid component struct") @doc false @spec status_from_string(String.t()) :: status() - def status_from_string(string) do - if string in @valid_status_strings, - do: String.to_atom(string), - else: raise("Invalid peer status string") - end + def status_from_string(status) when status in @valid_status_strings, + do: String.to_atom(status) + + def status_from_string(_status), do: raise("Invalid peer status string") end diff --git a/lib/jellyfish/peer/webrtc.ex b/lib/jellyfish/peer/webrtc.ex index 8dcb394..cba361b 100644 --- a/lib/jellyfish/peer/webrtc.ex +++ b/lib/jellyfish/peer/webrtc.ex @@ -2,7 +2,8 @@ defmodule Jellyfish.Peer.WebRTC do @moduledoc """ Options for the WebRTC peer. - For the description of these options refer to [Jellyfish documentation](https://jellyfish-dev.github.io/jellyfish-docs/getting_started/peers/webrtc) + For the description of these options refer to [Jellyfish + documentation](https://jellyfish-dev.github.io/jellyfish-docs/getting_started/peers/webrtc). """ @enforce_keys [] diff --git a/lib/jellyfish/room.ex b/lib/jellyfish/room.ex index 7a0125b..0880bc6 100644 --- a/lib/jellyfish/room.ex +++ b/lib/jellyfish/room.ex @@ -15,7 +15,7 @@ defmodule Jellyfish.Room do iex> {:ok, peer, peer_token} = Jellyfish.Room.add_peer(client, room.id, Jellyfish.Peer.WebRTC) {:ok, - %Jellyfish.Peer{id: "5a731f2e-f49f-4d58-8f64-16a5c09b520e", type: :webrtc}, + %Jellyfish.Peer{id: "5a731f2e-f49f-4d58-8f64-16a5c09b520e", type: Jellyfish.Peer.WebRTC}, "3LTQ3ZDEtYTRjNy0yZDQyZjU1MDAxY2FkAAdyb29tX2lkbQAAACQ0M"} iex> :ok = Jellyfish.Room.delete(client, room.id) @@ -51,7 +51,7 @@ defmodule Jellyfish.Room do * `:max_peers` - maximum number of peers present in a room simultaneously. If set to `nil` or unspecified, the number of peers is unlimited. """ - @type options :: [{:max_peers, non_neg_integer() | nil}] + @type options :: [max_peers: non_neg_integer() | nil] @typedoc """ Stores information about the room. @@ -128,7 +128,7 @@ defmodule Jellyfish.Room do @doc """ Add a peer to the room with `room_id`. """ - @spec add_peer(Client.t(), id(), Peer.options() | Peer.options_module()) :: + @spec add_peer(Client.t(), id(), Peer.options() | Peer.type()) :: {:ok, Peer.t(), peer_token()} | {:error, atom() | String.t()} def add_peer(client, room_id, peer) do peer = if is_atom(peer), do: struct!(peer), else: peer @@ -137,7 +137,7 @@ defmodule Jellyfish.Room do Tesla.post( client.http_client, "/room/#{room_id}/peer", - %{"type" => Peer.type_from_options(peer) |> Atom.to_string()} + %{"type" => Peer.string_from_options(peer)} ), {:ok, %{"peer" => peer, "token" => token}} <- Map.fetch(body, "data"), result <- Peer.from_json(peer) do @@ -165,7 +165,7 @@ defmodule Jellyfish.Room do @doc """ Add component to the room with `room_id`. """ - @spec add_component(Client.t(), id(), Component.options() | Component.options_module()) :: + @spec add_component(Client.t(), id(), Component.options() | Component.type()) :: {:ok, Component.t()} | {:error, atom() | String.t()} def add_component(client, room_id, component) do component = if is_atom(component), do: struct!(component), else: component @@ -175,7 +175,7 @@ defmodule Jellyfish.Room do client.http_client, "/room/#{room_id}/component", %{ - "type" => Component.type_from_options(component) |> Atom.to_string(), + "type" => Component.string_from_options(component), "options" => Map.from_struct(component) |> Map.new(fn {k, v} -> {snake_case_to_camel_case(k), v} end) diff --git a/mix.exs b/mix.exs index e7e32da..eec0bec 100644 --- a/mix.exs +++ b/mix.exs @@ -97,7 +97,10 @@ defmodule Membrane.Template.Mixfile do extras: ["README.md", "LICENSE"], formatters: ["html"], source_ref: "v#{@version}", - nest_modules_by_prefix: [Membrane.Template] + nest_modules_by_prefix: [Jellyfish, Jellyfish.ServerMessage, Jellyfish.Exception], + groups_for_modules: [ + "Server notifications": ~r/^Jellyfish\.ServerMessage[.a-zA-Z]*$/ + ] ] end diff --git a/protos b/protos index da12bef..662095c 160000 --- a/protos +++ b/protos @@ -1 +1 @@ -Subproject commit da12befd695ce6fe0e212acf70a1d1f97572e2ef +Subproject commit 662095c9a8ca30d197458758ec9d1ad279c72f4d From 9c0efadc30d78f7d013f84405bf98c1a9c3d024b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Wala?= Date: Thu, 15 Jun 2023 12:51:35 +0200 Subject: [PATCH 2/7] Rewrite test/docker config to mimic the one in `jellyfish-dev/jellyfish_videoroom` --- .circleci/config.yml | 2 +- config/config.exs | 2 +- docker-compose-dev.yaml | 25 +++++++++++++++++++ ...se.yaml => docker-compose-integration.yaml | 0 test/test_helper.exs | 2 +- 5 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 docker-compose-dev.yaml rename docker-compose.yaml => docker-compose-integration.yaml (100%) diff --git a/.circleci/config.yml b/.circleci/config.yml index 04b81fb..534de67 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -16,7 +16,7 @@ jobs: executor: machine_executor_amd64 steps: - checkout - - run: docker compose run test + - run: docker compose -f docker-compose-integration.yaml run test - codecov/upload workflows: diff --git a/config/config.exs b/config/config.exs index 035ba34..2e9f8d4 100644 --- a/config/config.exs +++ b/config/config.exs @@ -1,7 +1,7 @@ import Config config :jellyfish_server_sdk, - divo: "docker-compose.yaml", + divo: "docker-compose-integration.yaml", divo_wait: [dwell: 1_500, max_tries: 50] import_config "#{config_env()}.exs" diff --git a/docker-compose-dev.yaml b/docker-compose-dev.yaml new file mode 100644 index 0000000..95f4b24 --- /dev/null +++ b/docker-compose-dev.yaml @@ -0,0 +1,25 @@ +version: "3" + +services: + test: + image: hexpm/elixir:1.14.4-erlang-25.3.2-alpine-3.16.5 + command: sh -c "cd app/ && apk add git && mix local.hex --force && mix local.rebar --force && mix deps.get && mix test --warnings-as-errors" + environment: + - MIX_ENV=integration_test + volumes: + - .:/app + networks: + - network + depends_on: + - jellyfish + + jellyfish: + extends: + file: docker-compose-dev.yaml + service: jellyfish + networks: + - network + +networks: + network: + driver: bridge diff --git a/docker-compose.yaml b/docker-compose-integration.yaml similarity index 100% rename from docker-compose.yaml rename to docker-compose-integration.yaml diff --git a/test/test_helper.exs b/test/test_helper.exs index 17bc672..0bffcaa 100644 --- a/test/test_helper.exs +++ b/test/test_helper.exs @@ -1,5 +1,5 @@ if Mix.env() != :integration_test do - Divo.Suite.start() + Divo.Suite.start(services: [:jellyfish]) end ExUnit.start(capture_log: true) From 70a43a7d7594697bcab18f8d1f216d2af0a4627f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Wala?= Date: Thu, 15 Jun 2023 13:00:22 +0200 Subject: [PATCH 3/7] Fix tests --- lib/jellyfish/component.ex | 2 +- lib/jellyfish/peer.ex | 2 +- test/jellyfish/room_test.exs | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/jellyfish/component.ex b/lib/jellyfish/component.ex index 81863e5..934e75a 100644 --- a/lib/jellyfish/component.ex +++ b/lib/jellyfish/component.ex @@ -66,5 +66,5 @@ defmodule Jellyfish.Component do @spec string_from_options(struct()) :: String.t() def string_from_options(%HLS{}), do: "hls" def string_from_options(%RTSP{}), do: "rtsp" - def string_from_options(_struct), do: raise("Invalid component struct") + def string_from_options(_struct), do: raise("Invalid component options struct") end diff --git a/lib/jellyfish/peer.ex b/lib/jellyfish/peer.ex index b05f29d..37f2583 100644 --- a/lib/jellyfish/peer.ex +++ b/lib/jellyfish/peer.ex @@ -76,7 +76,7 @@ defmodule Jellyfish.Peer do @doc false @spec string_from_options(struct()) :: String.t() def string_from_options(%WebRTC{}), do: "webrtc" - def string_from_options(_struct), do: raise("Invalid component struct") + def string_from_options(_struct), do: raise("Invalid peer options struct") @doc false @spec status_from_string(String.t()) :: status() diff --git a/test/jellyfish/room_test.exs b/test/jellyfish/room_test.exs index fb9e44e..3659268 100644 --- a/test/jellyfish/room_test.exs +++ b/test/jellyfish/room_test.exs @@ -113,10 +113,10 @@ defmodule Jellyfish.RoomTest do test "when request is valid", %{client: client, room_id: room_id} do assert {:ok, component} = Room.add_component(client, room_id, @component_opts) - assert %Jellyfish.Component{type: :hls} = component + assert %Jellyfish.Component{type: Component.HLS} = component assert {:ok, component} = Room.add_component(client, room_id, @component_opts_module) - assert %Jellyfish.Component{type: :hls} = component + assert %Jellyfish.Component{type: Component.HLS} = component end test "when request is invalid", %{client: client} do @@ -148,10 +148,10 @@ defmodule Jellyfish.RoomTest do test "when request is valid", %{client: client, room_id: room_id} do assert {:ok, peer, _peer_token} = Room.add_peer(client, room_id, @peer_opts) - assert %Jellyfish.Peer{type: :webrtc} = peer + assert %Jellyfish.Peer{type: Peer.WebRTC} = peer assert {:ok, peer, _peer_token} = Room.add_peer(client, room_id, @peer_opts_module) - assert %Jellyfish.Peer{type: :webrtc} = peer + assert %Jellyfish.Peer{type: Peer.WebRTC} = peer end test "when request is invalid", %{client: client} do From 18200583287c7c1ba1a97299b85710d55580d560 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Wala?= Date: Thu, 15 Jun 2023 13:10:58 +0200 Subject: [PATCH 4/7] Docker fixes --- docker-compose-dev.yaml | 45 ++++++++++++++++++--------------- docker-compose-integration.yaml | 38 +++++++++++----------------- mix.exs | 4 +-- 3 files changed, 41 insertions(+), 46 deletions(-) diff --git a/docker-compose-dev.yaml b/docker-compose-dev.yaml index 95f4b24..0fe35ee 100644 --- a/docker-compose-dev.yaml +++ b/docker-compose-dev.yaml @@ -1,25 +1,28 @@ version: "3" services: - test: - image: hexpm/elixir:1.14.4-erlang-25.3.2-alpine-3.16.5 - command: sh -c "cd app/ && apk add git && mix local.hex --force && mix local.rebar --force && mix deps.get && mix test --warnings-as-errors" - environment: - - MIX_ENV=integration_test - volumes: - - .:/app - networks: - - network - depends_on: - - jellyfish - jellyfish: - extends: - file: docker-compose-dev.yaml - service: jellyfish - networks: - - network - -networks: - network: - driver: bridge + image: "ghcr.io/jellyfish-dev/jellyfish:${TAG:-edge}" + container_name: jellyfish + restart: on-failure + healthcheck: + test: > + curl --fail -H "authorization: Bearer development" http://localhost:5002/room || exit 1 + interval: 3s + retries: 2 + timeout: 2s + start_period: 30s + environment: + VIRTUAL_HOST: "localhost" + USE_INTEGRATED_TURN: "true" + INTEGRATED_TURN_IP: "${INTEGRATED_TURN_IP:-127.0.0.1}" + INTEGRATED_TURN_LISTEN_IP: "0.0.0.0" + INTEGRATED_TURN_PORT_RANGE: "50000-50050" + INTEGRATED_TCP_TURN_PORT: "49999" + SERVER_API_TOKEN: "development" + PORT: 5002 + SECRET_KEY_BASE: "super-secret-key" + ports: + - "5002:5002" + - "49999:49999" + - "50000-50050:50000-50050/udp" diff --git a/docker-compose-integration.yaml b/docker-compose-integration.yaml index 9b1902f..95f4b24 100644 --- a/docker-compose-integration.yaml +++ b/docker-compose-integration.yaml @@ -2,32 +2,24 @@ version: "3" services: test: - image: membraneframeworklabs/docker_membrane:latest - command: bash -c "cd app/ && mix deps.get && mix coveralls.json --warnings-as-errors" + image: hexpm/elixir:1.14.4-erlang-25.3.2-alpine-3.16.5 + command: sh -c "cd app/ && apk add git && mix local.hex --force && mix local.rebar --force && mix deps.get && mix test --warnings-as-errors" environment: - MIX_ENV=integration_test volumes: - .:/app - links: + networks: + - network + depends_on: - jellyfish + jellyfish: - image: "ghcr.io/jellyfish-dev/jellyfish:${TAG:-edge}" - container_name: jellyfish - restart: on-failure - healthcheck: - test: > - curl --fail -H "authorization: Bearer development" http://localhost:5002/room || exit 1 - interval: 3s - retries: 30 - timeout: 2s - environment: - VIRTUAL_HOST: "localhost" - USE_INTEGRATED_TURN: "true" - INTEGRATED_TURN_IP: "${INTEGRATED_TURN_IP:-127.0.0.1}" - INTEGRATED_TURN_PORT_RANGE: "50000-65355" - INTEGRATED_TCP_TURN_PORT: "49999" - SERVER_API_TOKEN: "development" - PORT: 5002 - SECRET_KEY_BASE: "super-secret-key" - ports: - - "5002:5002" + extends: + file: docker-compose-dev.yaml + service: jellyfish + networks: + - network + +networks: + network: + driver: bridge diff --git a/mix.exs b/mix.exs index eec0bec..8abf1fd 100644 --- a/mix.exs +++ b/mix.exs @@ -107,8 +107,8 @@ defmodule Membrane.Template.Mixfile do def aliases do [ integration_test: [ - "cmd docker pull ghcr.io/jellyfish-dev/jellyfish:edge", - "cmd docker compose run test" + "cmd docker compose -f docker-compose-integration.yaml pull", + "cmd docker compose -f docker-compose-integration.yaml run test" ] ] end From 75b27e352b364a752605b15bc84ba5420642e500 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Wala?= Date: Thu, 15 Jun 2023 13:22:14 +0200 Subject: [PATCH 5/7] Remove unnecessary ExDoc configuration --- mix.exs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/mix.exs b/mix.exs index 8abf1fd..426c0b4 100644 --- a/mix.exs +++ b/mix.exs @@ -97,10 +97,7 @@ defmodule Membrane.Template.Mixfile do extras: ["README.md", "LICENSE"], formatters: ["html"], source_ref: "v#{@version}", - nest_modules_by_prefix: [Jellyfish, Jellyfish.ServerMessage, Jellyfish.Exception], - groups_for_modules: [ - "Server notifications": ~r/^Jellyfish\.ServerMessage[.a-zA-Z]*$/ - ] + nest_modules_by_prefix: [Jellyfish, Jellyfish.Exception] ] end From b052442e90fe35d532553eb5015b2ab4dac5b42f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Wala?= Date: Thu, 15 Jun 2023 13:25:43 +0200 Subject: [PATCH 6/7] Fix test coverage raport generation --- docker-compose-integration.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose-integration.yaml b/docker-compose-integration.yaml index 95f4b24..f344836 100644 --- a/docker-compose-integration.yaml +++ b/docker-compose-integration.yaml @@ -3,7 +3,7 @@ version: "3" services: test: image: hexpm/elixir:1.14.4-erlang-25.3.2-alpine-3.16.5 - command: sh -c "cd app/ && apk add git && mix local.hex --force && mix local.rebar --force && mix deps.get && mix test --warnings-as-errors" + command: sh -c "cd app/ && apk add git && mix local.hex --force && mix local.rebar --force && mix deps.get && mix coveralls.json --warnings-as-errors" environment: - MIX_ENV=integration_test volumes: From 82e434450c66d020a418f397286876c640956930 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Wala?= Date: Fri, 16 Jun 2023 11:07:09 +0200 Subject: [PATCH 7/7] Apply requested changes --- lib/jellyfish/room.ex | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/jellyfish/room.ex b/lib/jellyfish/room.ex index 0880bc6..f14285d 100644 --- a/lib/jellyfish/room.ex +++ b/lib/jellyfish/room.ex @@ -15,8 +15,11 @@ defmodule Jellyfish.Room do iex> {:ok, peer, peer_token} = Jellyfish.Room.add_peer(client, room.id, Jellyfish.Peer.WebRTC) {:ok, - %Jellyfish.Peer{id: "5a731f2e-f49f-4d58-8f64-16a5c09b520e", type: Jellyfish.Peer.WebRTC}, - "3LTQ3ZDEtYTRjNy0yZDQyZjU1MDAxY2FkAAdyb29tX2lkbQAAACQ0M"} + %Jellyfish.Peer{ + id: "5a731f2e-f49f-4d58-8f64-16a5c09b520e", + status: :disconnected, + type: Jellyfish.Peer.WebRTC + }, "3LTQ3ZDEtYTRjNy0yZDQyZjU1MDAxY2FkAAdyb29tX2lkbQAAACQ0M"} iex> :ok = Jellyfish.Room.delete(client, room.id) :ok