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:

https://github.com/elixir-lang/ecto/issues/1319

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

_russellb
I want to try my hand at web scraping. What tools/libraries do I need to use. I’m hoping to turn this into something professional so don’...
New
Tee
can someone please explain to me how Enum.reduce works with maps
New
tduccuong
Hi, is there any work on GUI with Elixir, that is similar to Electron/Javascript? My idea is to bundle Phoenix and BEAM into a single se...
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
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
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
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
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 records...
New

Other popular topics Top

vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
aesmail
Hello guys, I have finally made it. I created an admin interface for a framework. It’s been on my todo list for years and with the curre...
New
Emily
I have VueJS GUIs with the project generated using Webpack. I have Elixir modules that will need to be used by the VueJS GUIs. I forese...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
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
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
AstonJ
Please see the new poll here: Which code editor or IDE do you use? (Poll) (2022 Edition) It’s been a while since we first asked this, I...
208 31142 143
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
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
dogweather
I wrote this comment on r/haskell, and it’s not popular there. :wink: But I think I’m on to something… Haskell reminds me of Java, and e...
New

We're in Beta

About us Mission Statement