menu

Questions & Answers

Laravel running tests in parallel with elastic

I have a web application for which I am trying to setup parallel testing. The project has 2 databases Postgres for storing information and ElasticSearch used for search queries. These 2 are in sync, when an entity(one from the ones that are indexed by Elastic) is saved on the backend it is automatically synced to Elastic.

I have some unit tests that require Elastic sync for testing and the indices need to be refreshed before every test. The refresh is done via a trait using the 'elastic:migrate:refresh' method.

This system gets messed when trying to run tests in parallel, because indices need to be unique per testing process.

Has anyone done something similar, or have experience with this?

Comments:
2023-01-19 23:30:03
I think there is no solution at all for this, if they must be in sync, you are done, unless you can do something like Redis that have multiple "dbs", so you chose one for each process, but I have no idea if elasticsearch has that
2023-01-19 23:30:03
Well, laravel manages by itself the regular database so there must be a solution for elastic as well. Somehow to generate unique indices per process
2023-01-19 23:30:03
That may work, but as I have said, I never worked with ElasticSearch so I have no idea what config you have, etc.
Answers(0) :