jarlah

jarlah

Looking for feedback and/or contributors for testcontainers_elixir

Hi!

I have recently created, after having tried to get in touch with the creator of excontainers for quite some time, a new library called testcontainers_elixir, which I hope will be merged into the testcontainers family of repositories at some point. Im looking for any type of feedback and/or contributors. There is a lot of groundwork that needs to be done in the repository, so any help someone can give is precious.

It’s currently containing a very crude example of what I believe will be the core idea of the library. A macro function to create a container, that returns {:ok, container} if container was created successfully. No setup, no nothing. Just works. And it works wonderfully except for the fact I have just whipped up some code to get it working. A demo. A PoC.

I have added a project in the repo, and I have began thinking about how to get this working from top to bottom. Added some todos.

I want to solve the primary need, to create throw away testcontainers when running single tests. Shared containers and all that, I’m neglecting consciously.

I added this thread in testcontainers slack. So have some loose backing on that side.

What do you think ? Can you contribute ? Am I on the right track ? is GenServer really the best approach here for a reaper process ?

Thanks!

Most Liked

jarlah

jarlah

Update!!

Published two packages to Hex today:

  1. ex_docker_engine_api | Hex (there is excontainers and docker_engine_api but both of these are useless as I need something stable to depend on)
  2. testcontainers | Hex

The latter being the interesting one :wink:

Im crossing fingers that some might find it useful! I have committed to this project, and I’m ready for all the weird corner cases.

Maybe you want to join in on the fun and improve on it? You are welcome! :slight_smile:

jarlah

jarlah

Update

Just released a new feature

You can now use testcontainers with MySql adapter for ecto too :partying_face:

The plan is to increase the number of supported databases for use with ecto.

Right now the plan is to add more containers, among them mongodb, including ecto support for it. And other commonly used databases with Phoenix.

jarlah

jarlah

(Big?) Update

v1.2.3 is released.

It fixes a glaring issue about container cleanup, that caused parallell test runs to fail each other in random ways.

I needed to do some huge refactor of the library, internally, which didn’t added breaking changes in the api, luckily.

But for ExUnit and disposable containers inside the tests, you must now add

Testcontainers.start_link()

in test/test-helper.exs

This is not needed if using the Testcontainers.Ecto module, which can be dropped into application.ex as shown in the readme.

I considered making a minor version change, but this only fixes bugs and discrepancies.

jarlah

jarlah

I have successfully moved away from the silly idea of using macro function and the library is now using plain old functions to do the grunt work. I have also successfully managed to test an nginx container with the library, even to get the whole welcome from nginx index page asserted in the test.

So whats on todo now ? Wait for log statement logic. I have wait for port and wait for http. Waiting for log statement match is the next step. then everything from there is just mapping keywords in elixir to docker engine api request structs. Conceptually easy, but not trivial in practice of course :wink:

A big item on the todo list, is the “get docker base url” logic that I have currently glossed over in my library. Im just using a hard coded http+unix:// url which works on Mac and Linux, but not Windows. So if anyone want to get their hands dirty on elixir code you are welcome to join in. Code will be reviewed and we will learn something new :wink:

I didn’t even know how docker engine api worked before I start :wink:

jarlah

jarlah

Update:

560 lines of elixir code in the lib folder in the project now, and I can already start using it, albeit with git reference in mix. Im beginning to get confident about publishing it to Hex soon, just need to add some more tests. Any good name suggestions is appreciated, but if not I’ll just go for testcontainers_elixir. Dont need any fancy naming conventions.

There is only one macro file in the project now, and that is a ex_unit.ex macro file that contains macros for injecting exunits on_exit callback function into the Docker.Api.run method. Other than that the code is basically pretty much magic free. I haven’t yet added type specs everywhere because I really hate all the false positives. But it will come at some point.

Where Next?

Popular in RFCs Top

christhekeele
TL;DR: I’m planning on building a library, inspired by Vapor, to make configuring Elixir applications more straight-forward; in an approa...
New
tmbb
I’ve started working on a toy project to compile extended POSIX-compatible regular expressions into NimbleParsec combinators. These combn...
New
miolini
Hi :waving_hand: I’ve been working on CanvasCraft, a 2D drawing library for Elixir built on top of Skia via Rustler. It provides a decla...
New
noizu
Hello, I wrote a more comprehensive llama_cpp nif wrapper noizu-labs-ml/ex_llama: (github.com) inspired by the unfortunately doa jereg...
New
puemos
Hey everyone :waving_hand: Code: GitHub - puemos/overbooked: Overbooked is a self-hosted flexible workplace platform for indie co-wor...
New
Billzabob
Hello! I have an idea for an Elixir library I’d like to work on, but wanted to get some thoughts from the community first. It would allo...
New
KristerV
I got fed up with removing unused aliases manually so made a package for it: GitHub - KristerV/remove_unused_ex: Remove unused aliases an...
New
alisinabh
Hey everyone :wave: I was recently working on a hobby project that I have deployed on a platform that did not provide quick and easy acc...
New
ca1989
Hi all, this week I played a bit with Phoenix and Elm. I ended up with this POC: https://github.com/carlotm/elmex The repository cont...
New
laibulle
Hello, I am playing with quantitative finance with Elixir. This library is more a way for me to explore and learn in this area and especi...
New

Other popular topics Top

TunkShif
This post is an instruction guide to help you setup your Neovim for Elixir development from scratch. It includes general information on h...
273 38985 115
New
9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
itssasanka
Hi all, Trying to get some more clarity over utc_datetime and naive_datetime for Ecto: https://hexdocs.pm/ecto/Ecto.Schema.html#module-...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 45766 226
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
beno
I will often find my self writing things similar to: case some_value do nil -> something() "" -> something() _ -> someth...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New

We're in Beta

About us Mission Statement