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

Blokh
Hey guys, I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly Do you guys have any suggestions what is the best prac...
New
kszambelanczyk
Hello! Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app. I creat...
New
Onor.io
I have what I’ve heard referred to as a “lookup table” in my database. This is a way of assigning codes to common values. One common lo...
New
Trolleger
What approach to take when sending live updates to “random” users Hi! I have a question, I have a little chat app, and when I create a DM...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
matt-savvy
Anyone here using Honeybadger? My Honeybadger account is being overwhelmed with noise from some bots. Seeing a lot of Bandit.HTTPError...
New
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
wintermeyer
There are three potential reasons for members of this forum to have a look at https://vutuv.de You are tired or annoyed of LinkedIn. Yo...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews