chrismcg

chrismcg

Ecto 2.0, concurrent acceptance tests, and channels

I’ve upgraded an Phoenix 1.1.4 app to use Ecto 2.0 and wanted to try adding acceptance tests before upgrading to 1.2. I followed the instructions in the Wallaby repo and got concurrent tests going with the Phoenix.Ecto.SQL.Sandbox plug. However I’ve run into a problem I’m not sure how to solve other than by switching back to sequential tests.

The page my acceptance tests loads connects to a channel (UserChannel), and in the authorized? function there I query the database as part of authorisation. This triggers a ** (RuntimeError) cannot find ownership process for #PID<0.xxx.0>. I assume this is because of the way the the process handling the channel is started?

The web request and the websocket request both have the extra metadata in the UA string that phoenix_ecto uses to allow them access to the connection but I don’t see how to pass this through to the created channel processes.

My app starts or finds a named GenServer when a channel is joined, and that also talks to the database to manage state. Is there a way I can add this process to the ones allowed access to the connection too?

For now I’ve set async: false and put the Repo into shared mode.

Most Liked

hubertlepicki

hubertlepicki

Check out this issue:

I thnk this works in the way that there’s a plug that shares the connection used in test with the one used in request handlers. But Phoenix handles the requests in different processes (and even different process subtree) than channels. So the ownership is not extended automatically to any other processes.

This is an issue not only with channels, but also with any other processes you may spawn on your own. Like background workers, email sending stuff etc. So yeah, it will not be suitable for everyone, but can be useful in many cases where you do not use channels/other processes.

Where Next?

Popular in Questions Top

shahryarjb
Hello, I get Persian date from my client and convert it to normal calendar like this: def jalali_string_to_miladi_english_number(persi...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 record...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
sacepums
Hey guys. I'm new to elixir and im really stocked about it. But I ran into a bit of problem - I need to convert a date sting, for examp...
New
myronmarston
The Elixir Typespec docs show the following syntax for keyword lists in typespecs: # ... | [key: type] # keyword lis...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New

Other popular topics Top

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
sergio
I couldn’t find any guides that worked well with Phoenix 1.6.0 and esbuild. I hope this helps people test the waters and eases you into t...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
vac
Hi, I'm quite new in Elixir and I'm trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and ...
New
chensan
I have a User schema with a :from_id field set to type :string: defmodule TweetBot.Repo.Migrations.CreateUsers do use Ecto.Migration ...
New
johnnyicon
Hi all, I've just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I'm trying to use Postg...
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
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID&lt;0.412.0&gt; terminating ** (Postgrex.Error) FATAL...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New

We're in Beta

About us Mission Statement