sorentwo/oban

Oban.Pro.Testing - Upgrade from 1.3.2 `ensure_queues_started` "process not alive"

Closed this issue · 6 comments

Environment

  • Oban Version: Pro 1.3.3+
  • PostgreSQL Version: 14.2
  • Elixir & Erlang/OTP Versions (elixir --version): Elixir 1.15.7 (compiled with Erlang/OTP 26)

Current Behavior

Some tests are failing in locally and in CI after an upgrade to oban_pro 1.3.3 (and 1.3.5).

Here is how the test setup looks:

        oban_name = :"test-oban-#{System.unique_integer([:positive])}"

        oban_opts = [
          name: oban_name,
          repo: @repo,
          stage_interval: 10,
          queues: [
            upload_download: [limit: 5, paused: false],
            test: [limit: 5, paused: false],
            delete: [limit: 5, paused: false],
            archive: [limit: 5, paused: false]
          ],
          testing: :manual
        ]

        start_supervised_oban!(oban_opts)

This is throwing a "Process not alive" error

     ** (exit) exited in: GenServer.call({:via, Registry, {Oban.Registry, {:"test-oban-3908", {:producer, "upload_download"}}}}, :check, 5000)
         ** (EXIT) no process: the process is not alive or there's no process currently associated with the given name, possibly because its application isn't started
     stacktrace:
       (elixir 1.15.7) lib/gen_server.ex:1063: GenServer.call/3
       (elixir 1.15.7) lib/enum.ex:984: Enum."-each/2-lists^foreach/1-0-"/2
       (oban_pro 1.3.5) lib/oban/pro/testing.ex:757: Oban.Pro.Testing.start_supervised_oban!/1

This doesn't happen in 1.3.2 and lower, the tests pass.

My assumption is that this is the change that broke the tests.

Pasted image 20240314100332

You're right, that's the change that caused your issue. I've pushed a patch for your use case, but be aware, that when you set the testing mode to :manual, Oban overrides the config so it doesn't start any queues. If you change your config to queues: [] then the process will start, and it will behave the same as before since the queues weren't actually started.

One more note—start_supervised_oban already generates a unique name for every instance via make_ref to prevent interference, so you don't need to specify your own unique name.

Thanks Parker. I don't see a patch but I am updating the code in our test helper with the info you provided.

Where are the queues started when using :manual mode? I'm missing a connection.

The commit message is linked to the close action in this issue.

Queues aren’t started in manual mode, hence the manual part, and that’s where the disconnect is.

Nothing here that I can see is linked to a commit. Maybe you think I have access that I don't have.

image

"completed" is linked to the issues list filtered by completed the link

Queues aren’t started in manual mode, hence the manual part, and that’s where the disconnect is.

I couldn't find any documentation on this so if you have any more specific information it would be greatly appreciated. The tests run successfully so there must be queues started but I am not starting them.

I believe there is a level of abstraction that I am not quite understanding.

My apologies, I thought the commit message was available either way. Here it is for reference:

Starting a supervised Oban in manual mode with tests specified would fail because in :manual testing mode the queues option is overridden to be empty.

Queues are set to an empty list when testing is set to :manual or :inline. There's a little about that in the testing guide, though it doesn't explicitly state that queues don't run:

Both testing modes prevent Oban from running any database queries in the background. This simultaneously prevents Sandbox errors from plugin queries and prevents queues from executing jobs unexpectedly.

You can confirm that the queues list is empty by calling Oban.config(name) and looking at the queues list. That's a good thing for testing, since it lets you use helpers like assert_enqueued and drain_queue.

Perfect, thanks!