Oban recorded tests are failing

Hello guys.

I’m testing workers using Oban and Oban Testing module.
All my tests that are not using recorded option are working pretty well.
Unfortunately, I have only one test that is recorded and it’s failing.
The return is: {:error, "recording requires the Smart engine"}

I configured my environment to test using this doc: Testing Pro Workers — Oban Pro v1.1.6

I also found one thing that made me think that would fix this problem after upgrading when I saw on changelog: Changelog — Oban Pro v1.0.2

  • [Testing] Use the Smart engine in perform_job/3Testing recorded workers with perform_job/3 caused an error due to an engine mismatch. Now perform_job/3 defaults to the Smart engine more closely mimic production.

Nothing shows how to configure or mention the Smart engine in the testing guide.
Can someone help me understand what I’m missing for this test?

My engine is configured: config :lolo, Oban, engine: Oban.Pro.Engines.Smart

Which versions of Oban and Pro are you using? It sounds like one of the versions, likely Oban, is behind and that’s why the engine isn’t used correctly.

1 Like

Hello @sorentwo thanks for your asnwer.

I’m using these versions:

oban_pro 1.1.6 1.1.6 Up-to-date
oban_web 2.10.0 2.10.0 Up-to-date

In what file do you have this config? Can you show how you start your Oban child in the supervision tree?

2 Likes

I was inquiring about the Oban version more than Pro or Web. The specific fix for that issue was released with v2.15.4 in August.

1 Like

I’m using this on my config.exs.
The recorded job is working on my web application. It is not working only during my tests.

I got it. I think Oban in this case is a dependecy from oban_pro and oban_web right?
If it is, my version of oban on my mix lock is 2.16.3.

oban → 2.16.3
oban_met → 0.1.3
oban_pro → 1.1.6
oban_web → 2.10.0

Those versions are current, so that’s not the issue. Are you using Oban.Testing instead of Oban.Pro.Testing?

The Pro testing module sets the engine automatically and is generally superior to the OSS version. There are instructions on switching in the adoption guide.

I followed this guide too.

I defined my job as: use Oban.Pro.Worker, recorded: true, queue: :my_queue
My datacase quote has: use Oban.Pro.Testing, repo: MyApp.ObanRepo

One thing that I noticed debbuging the lib is my oban job during the test is using Oban.Engines.Basic even after I defined on config to use SmartEngine.

conf: %Oban.Config{
    dispatch_cooldown: 5,
    engine: Oban.Engines.Basic,
    get_dynamic_repo: nil,
    log: false,
    name: Oban,
    node: "Allans-MacBook-Pro",
    notifier: Oban.Notifiers.Postgres,
    peer: Oban.Peers.Postgres,
    plugins: [],
    prefix: "public",
    queues: [],
    repo: nil,
    shutdown_grace_period: 15000,
    stage_interval: 1000,
    testing: :disabled
  }

It looks like Ben was on the right track and there’s a mismatch between your config and what the application is using.

My supervisor starts with this tuple:

{Oban,
   [
     engine: Oban.Pro.Engines.Smart,
     peer: false,
     repo: Lolo.ObanRepo,
     testing: :manual,
     plugins: [],
     queues: []
   ]}

I’m using Smart when I start my tests too. For some reason it’s changing the engine durings tests maybe?

The config isn’t used when running a job with perform_job/3, only in non-testing modes. The testing module builds up a config internally for testing.

Confirm you’re using Pro’s testing module by calling it directly, e.g. Oban.Pro.Testing.perform_job(module, args)

2 Likes

Hey @sorentwo thank you.

Although there was Oban.Pro.Testing on data_case.ex
The test was using the full namespace Oban.Testing.perform_job.
I just removed the namespace and it is working right now.
Thank you for that.