gavares
I’m trying to use Commanded with Phoenix to create an eventsourced application. I’ve pieced things together from the conduit repo and the commanded docs but I’m getting a failure and stacktrace when I try to run my tests against my aggregate.
There is quite a bit of configuration, support code, and application code so I’m not sure which of that would be helpful to post here. Once my tests start, I’m getting error message:
** (UndefinedFunctionError) function Ecto.Adapters.SQL.Sandbox.child_spec/1 is undefined or private
stacktrace:
Ecto.Adapters.SQL.Sandbox.child_spec({Postgrex.Protocol, [types: Postgrex.DefaultTypes, username: "postgres", password: "password", database: "accounts_test", hostname: "localhost", pool: Ecto.Adapters.SQL.Sandbox, pool_size: 2]})
(db_connection) lib/db_connection.ex:389: DBConnection.start_link/2
(accounts) test/support/storage.ex:24: Accounts.Storage.reset_readstore/0
(accounts) test/support/storage.ex:7: Accounts.Storage.reset!/0
(ex_unit) lib/ex_unit/on_exit_handler.ex:142: ExUnit.OnExitHandler.exec_callback/1
(ex_unit) lib/ex_unit/on_exit_handler.ex:128: ExUnit.OnExitHandler.on_exit_runner_loop/0
I’ve looked at db_connection.ex:389 and it’s not calling child_spec/1 so I’m very confused why this is happening. I’ve been trying to debug this for about 4 hours now and I’m at a loss.
The last bit of my code from the stacktrace above:
defp reset_readstore do
config = Application.get_env(:accounts, Accounts.Repo)
{:ok, conn} = Postgrex.start_link(config)
Postgrex.query!(conn, truncate_readstore_tables(), [])
end
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,
I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
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
Documentation
While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
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
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
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
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself.
My main conc...
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
- #ai
- #elixirconf-us
- #blog-post
- #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)
gcauchon
I don’t think you can simply respawn
Postgrexunder your application supervision tree like you are trying to.The postgres adapter is managed by
Ecto.Adapters.Postgresl(ecto_sql), which is supervised byEcto.Repo(ecto), which is supervised by you application.And there is fair amount of config involved to setup the
Ecto.Adapters.SQL.Sandboxadapter defined inconfig/test.exswhen running tests.gavares
The place where I call
reset_readstoreis in mydata_case.exfile and I stop everything just before I callreset_readstore:So my understanding is that everything is shutdown by
data_case.exand then I have to re-open the store in order to cleanup the database tables.axelson
Is there a particular reason you’re trying to cleanup the database tables yourself? The Ecto Sandbox is able to take of that for you (by running tests each in their own transaction, either sync or async). If you relied on the Sandbox to do the cleanup than you should be able to remove a bunch of your test configuration/setup.
gavares
Thanks @axelson, that’s really helpful. The cleanup code I have is taken from the commanded docs and I found similar code in the conduit repo that I am basing my app off of. If Sandbox can handle that logic for me, so much the better. I’ll give that a try.
gavares
@axelson, thanks for the help. Removing my manual cleanup code solved my problem.
axelson
I’m glad you got it working! I wonder if it would make sense to submit a PR for that portion of the commanded docs. My guess is that commanded is trying to be database adapter agnostic, but at least a mention of the Ecto Sandbox would probably fit in that section.
gavares
@axelson, I had the same thought. I’ll submit something to update the docs. One thing I’ve noticed, setting the pool to Sandbox for eventstore still seems to leave events in the database after my tests complete and seems to be causing some of my tests to fail since the state isn’t getting properly reset between test runs.
I wonder if EventStore doesn’t work properly with Sandbox.
LostKobrakai
EventStore doesn’t use ecto and therefore cannot be controlled using the ecto sandbox. It uses postgrex directly and therefore needs manual action for cleanup.
sahina
@LostKobrakai commanded is v1.0 now but all the example application i see like are using older version of commanded. do you know a sample v1.0 commanded project?
These are pre 1.0
https://github.com/slashdotdash/segment-challenge
Thanks
slashdotdash
The GitHub repo for the “Building Conduit” eBook has been updated to use Commanded and EventStore v1.0 if you are still looking.