andreyuhai
I am trying to insert another Oban job after one finishes by listening to [:oban, :job, :stop].
I’d like to assert that the next job was queued after one succeeded, so in my test I do something like this ![]()
test "schedules job after another" do
# ...
{:ok, result} =
perform_job(Workers.MyWorker, %{
record_id: some_record_id
})
assert_enqueued(
[worker: Workers.SecondWorker, args: %{result_id: result.id}],
1000
)
end
And my telemetry event handler looks like this
def handle_event(
[:oban, :job, :stop],
_measure,
meta = %{worker: worker, result: {:ok, result}},
_
) do
Workers.SecondWorker.new(%{result_id: result.id}) |> Oban.insert()
end
However even though I can see the job inserted after inspecting the result of Oban.insert (though it doesn’t have an ID) my test still fails and I couldn’t really figure out why.
Trending in Questions
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
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
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
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
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
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
apply_graft/2 doesn’t rewrite an add_many sub-workflow’s deps on an add step. Grafted jobs cancel with “upstream job was deleted”
Version...
New
Other Trending Topics
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
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
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixirconf-us
- #blog-post
- #ai
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
andreyuhai
If I change the Oban config to be
then it works but I don’t know whether there’s any other way of making this work because now some other tests fail.
If I wrap only my test case with
with_testing_mode(:manual...then I getal2o3cr
IIRCI did NOT recall correctly, see @LostKobrakai’s note below.:telemetryhandlers run in a separate process, you may be encountering DB sandbox issues.Also beware: telemetry doesn’t provide any delivery guarantees and aggressively (silently + permanently for the VM’s lifetime) removes listeners that crash even once. If
SecondWorkeris doing anything important, you may want to consider an alternative approach like Oban Pro’s workflows.LostKobrakai
They do not, as they don’t want to introduce message passing.
andreyuhai
I was guessing that those are GenServers and somehow they come back up, but yes, I’ve already encountered that during my tests, so we’ll probably have to switch to Pro to be able to use Workflows. Thank you!
I wonder how other people use it though, I mean if there’s no guarantee and the listeners might get removed. Is it because it doesn’t hurt much (well maybe it does, I have no idea
) losing some metrics?
al2o3cr
Since a crashing handler crashes the calling process, I assume the design principle is “prefer uptime over metrics” which isn’t unreasonable.
It can be kinda painful if you mess up, for instance, a listener that tracks
Oban.Jobcrashes and sends them to Sentry so that you don’t get any reports from production after the very first one. Ask me how I learned THAT oneLostKobrakai
The point here is much more about this:
The code emitting telemetry events can’t handle problems of listeners – those can be libraries, which have no relationship to your project or metric setup. So it’s the job of listeners to have their **** together and deal with any issues they encounter.
trisolaran
Correct, because in
:inlinemode, which is what I assume your original config was using, no jobs are ever enqueued in the DBandreyuhai
But then as I mentioned, even if I wrap it with
with_testing_mode(:manual...I get that argument error I shared above.trisolaran
Most likely because, as the error message suggests,
perform_jobis returning aresultstruct withid=nil.Take a look at what happens in your worker or share the code so someone can help you.
andreyuhai
It wasn’t actually about the result
perform_jobreturns but that happens when Oban tries to complete the job, at least that’s what I understood from stacktrace.Also when I’ve inspected the actual
Oban.Jobthat was passed toperform/1fromperform_job, I see that theidisnil.Not sure that’s because of
). I mean
perform_jobbut I do not think so (or maybeperform_jobdoesn’t actually insert anything as far as I understood by looking at the module.I’m also using
perform_jobin other tests but I’ve never encountered the same error.Edit
Somehow using
perform_jobwithinwith_testing_mode(:manual...causes some problemsThe above snippet somehow throws the ArgumentError I shared above.
I’ve also tried to use
Oban.insert/1instead of usingperform_job/1hoping that it would insert the job and once my job is handled it would enqueue another onebut somehow this way my first job didn’t even get processed. At least I didn’t see the
IO.inspects that I did to ensure it was working the way I assumed it would.how I could finally make it work was by directly calling
perform/1on my workerBut at that point, is this test useful or necessary? Because I am calling
perform/1directly and I already know that if the job is succesfull the next thing it will do is to schedule another one. Maybe that’s the topic of another question about testing in general.