NobbZ

NobbZ

For some python projects at work we found that there are pytest-{postgres,mysql,redis} and probably more.

These tools take the burden off of you to maintain a Dev database locally which you need to configure your in Dev applications accordingly.

Those are basically plugins for pytest, which use the fixture mechanism of pytest to provide temporary “installations” of the tool in question, “persisting” it’s data into temporary folders and removing after the suite has run.

Even though this has an obvious runtime cost to initialise the tooling for each test run, it really made onboarding the junior quite easy. We just told them to install mysql package for their Ubuntu WSL and told them to run make test which wrapped the actual test run with proper command line arguments. No need to walk them through configuring a local mysql or having remember to run some docker(-compose) whenever changing projects.

Has anyone seen something similar for elixir or is there any interest in it?

Showing Posts 1 to 9

dimitarvp

dimitarvp

I am sorry, what exactly do those packages do? Didn’t get it. What tool? What temporary installations? Why once per test? Could you clarify?

webuhu

webuhu

I archive this behavior by using Nix.
At least it works perfectly with running PostgreSQL in a temporary directory.

→ GitHub - webuhu/elixir_nix_example · GitHub

The probably interesting PostgreSQL part under:
https://github.com/cw789/elixir_nix_example/blob/main/pkg/temporary_postgresql_db.nix

So it means within WSL - install Nix - run nix-shell command x…
If you run the command a second time, runtime cost isn’t anymore much higher.

NobbZ

NobbZ OP

Yeah, using nix such a thing is easy, I know, though even I wrap most of my stuff in flakes nowadays, I try to make it that potential contributors don’t need nix installed.

webuhu

webuhu

That would be wonderful. Difficult onboarding is always an issue.

NobbZ

NobbZ OP

They start the tool they are made for, eg mysql, and remove its runtime folders afterwards. It does not affect any potentially running instances of that software that might already be on the system.

And it’s not per test, but per run.

So only the first test hitting the database is actually slow as it needs to wait for everything beeing set up.

As I said already it comes with a low cost for setting things up, and might also enable to test behaviour against different database versions.

webuhu

webuhu

So I’m not aware of anything like this deticated for Elixir and not using Docker.
But I think without any container or virtual machine sandboxing it is difficult to not affect any other running instances.
But I’m of course interested.

dimitarvp

dimitarvp

I’m still not sure I get it.

Are you talking about something like the PGDATA environment variable that allows you to specify where will PostgreSQL store its data? I’ve had projects where that was used to kinda sorta enforce some isolation.

NobbZ

NobbZ OP

We used the MySQL version of those plugins, that basically starts a mysql demon with a configuration pointing the data dir to somewhere in tmp, listening on specified ports or domain sockets.

It manages the full database application lifecycle.

dallagi

dallagi

If I understood your requirement correctly, you may be interested in excontainers, a library I developed to tackle exactly this problem.

Unfortunately it has not seen much adoption yet, but in case you decide to give it a try I’d be happy to hear about any problem you may encounter or any feedback you may have :slight_smile:

— All posts loaded —

Where Next? Top

Trending in Discussions Top

wmnnd
Hey folks, I wanted to share with you a project I’ve been working on for a while: It’s an Open Source (AGPLv3) newsletter tool. Think Ma...
New
axelson
Hi there! :wave: @frigidcode and I (but mostly him) have been running an Elixir Book club, we’re almost done with Designing Elixir Syste...
New
alexslade
Fly’s CEO posted this recently - Turn And Face The Strange · The Fly Blog It says that Fly is going all-in on sprites, which is a worry ...
New
sntran
In my third year of college, around 2010, I found Erlang. A few years later, I found Elixir. I liked the ideas at once: many small proces...
New
Ganna
Hi everyone, I have 8 years of production experience with Erlang/OTP and I’m just starting to get to know Elixir. What would you learn f...
New
johnkirkham
A note on form. Joe Armstrong, co-creator of the Erlang programming language, died in April 2019. What follows is a work of narrative non...
New
gtcode
I’ve been tinkering with Lynx (by José) via hold_ledger. I used AI to write the code, a separate specification, the tests, and the Lean p...
New

Other Trending Topics Top

dominicletz
Hey there, I haven’t seen a list of useful Elixir specific skills for the popular AI tools yet so I’m starting one here with my first. ...
New
mudasobwa
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
KristerV
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
webofbits
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself. My main conc...
#ai
New
OndrejValenta
(I just needed to vent somewhere and LinkedIn is full of hope, or hype, I’m not sure which exactly) AI dream has many faces, but general...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews