svilen

svilen

Author of Concurrent Data Processing in Elixir

I’m using Hound with ChromeDriver and I’ve read that it is possible to run async tests (e.g. multiple browsers executing the test cases in parallel). However, I can’t find any examples/tutorials how to do this.

There’s a question on StackOverflow that was kind of a starting point, but I was still getting DBConnection.OwnershipError exceptions or other timeout errors. Then I saw this answer in the forum saying that Wallaby/Hound support async tests through a plug found in Ecto.

Could someone provide a short example how to get this working? Thanks a lot in advance!

Elixir 1.4 / Phoenix 1.3rc

Showing Posts 1 to 7

svilen

svilen OP

Author of Concurrent Data Processing in Elixir

@josevalim Thanks for the quick response, that was very helpful! I’m surprised Hound’s README doesn’t have a link to it. However, I’m still struggling to get this to work the way I think it should be.

I’ve got two tests, and when ran individually, they take ~15 seconds each (or ~30 seconds with mix test --only integration). After I added async: true I can see two Chrome browsers starting off, but strangely the total time with the async options and changes is still ~30 seconds, same as before, which seems wrong.

How could this be, is there something I’m missing? I followed the guide in the link carefully, and only made 1 change in the setup of my IntegrationCase file, due to an error:

defmodule MyApp.Web.IntegrationCase do
  use ExUnit.CaseTemplate

  using do
    quote do
      use Hound.Helpers
      import MyApp.Web.Router.Helpers
      import MyApp.Web.IntegrationCase

      @endpoint MyApp.Web.Endpoint

      hound_session()
    end
  end

  setup do
    :ok = Ecto.Adapters.SQL.Sandbox.checkout(MyApp.Repo)
    metadata = Phoenix.Ecto.SQL.Sandbox.metadata_for(MyApp.Repo, self())
    Hound.start_session(metadata: metadata)
    # Added :ok since `start_session/2` returns a string.
    :ok
  end
end
josevalim

josevalim

Creator of Elixir

Tests in the same module do not run concurrently. Only tests in separate modules/files. I.e. the granularity of concurrency is per module and not per test. That’s because tests in the same module/file are usually exercising the same area of the codebase and would not benefit of concurrency.

svilen

svilen OP

Author of Concurrent Data Processing in Elixir

I see — to clarify, the tests are indeed split in two separate files, and each file has its own module, e.g.:

defmodule LoginTest do
  use MyApp.Web.IntegrationCase, async: true
  # ...
end

However, they do exercise the same main web application, just doing different things (one tests logging in, the other tests creating data). Would that mean that I cannot run them concurrently?

tme_317

tme_317

Hi @svilen,

Wondering if you were able to get Hound to work with an async test suite using ChromeDriver? I’ve struggled for days trying to get this to work before punting and running everything synchronously and was reminded about it this morning: Async Hound tests failing sporadically with ChromeDriver - #2 by myobie

Thanks!

svilen

svilen OP

Author of Concurrent Data Processing in Elixir

@tme_317 No, sorry, I had to put this aside and leave them running sequentially.

myobie

myobie

I recently used Hound as part of a GenStage pipeline (and spawned about 15 of this particular stage to run concurrently) and this is the code that worked well for me. I think you could create a GenServer and do the same (spawn a process for each test so they are fully isolated).

— All posts loaded —

Where Next? Top

Trending in Questions Top

stjefim
Hello! Suppose you are building workflow (order / task / payment) processing system with the following requirements: Each workflow con...
New
water
I’m aware of 2 such projects, are there others? git: GitHub - team-alembic/realworld: A fullstack Phoenix LiveView application with back...
New
itzmidinesh
Hi all, I’m working on a Phoenix project where I need to make external HTTP requests and I’m trying to choose between Req and HTTPoison....
New
peck
Hi everyone. My team and I have been working on a fairly modest app based around video streaming and chat, but we’ve landed a customer t...
New
leoschweizer
Hi, we run different LLM models across a cluster, with each node loading a configurable subset. Model-specific queues let nodes consume ...
New
csmr
Hi all, I’m new here and would like to hear peoples views on my Elixir/Phoenix based game-engine! :smiley: Mutonex gamedesign was finish...
New
Stef-Verniers
Hello I’ve been coding in Elixir for almost two years now because of my current job where we implemented Elixir in our application. But ...
New

Other Trending Topics Top

dominicletz
Hey there, I haven’t seen a list of useful Elixir specific skills for the popular AI tools yet so I’m starting one here with my first. ...
New
mudasobwa
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
KristerV
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
webofbits
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself. My main conc...
#ai
New
OndrejValenta
(I just needed to vent somewhere and LinkedIn is full of hope, or hype, I’m not sure which exactly) AI dream has many faces, but general...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews