Open cakemanny opened 2 months ago
Thank you for contributing! I will hopefully have more time to look at it soon, but one note about testing - it would be better if everything could be done directly from python. If possible, it would be better not to depend on make
and docker-compose
. For example, I'd consider spawning a container with subprocess.run(["docker", "run"...
,
But I think that an even leaner approach which doesn't depend on docker would be to just use nsenter
without actually spwaning a container and relying on docker. For example, running the regular test program inside a filesystem namespace (and maybe others).
Hi, just to give you an update, I think I'm unlikely to continue working on this. I think I want something a bit safer than what is guaranteed by kubo/injector. So I'm focusing rather on trying out other ideas.
Regarding the suggestions for the tests. I investigated a little. Using nsenter
with a root filesystem change requires running the tests as the root user and in order to run a process there the binary needs to be statically linked (or all shared libraries need to be copied/linked in, I guess).
I imagine the docker approach may be simpler but I recall finding managing docker containers from a test to be rather flakey. Though perhaps the testcontainers library would be helpful in this case.
You're free to take what you like and delete the parts that you don't, in case any of this was useful.
This adds support for injecting libraries into processes in containers. Which is needed for https://github.com/kmaork/hypno/issues/18.
It's draft right now for a few reasons. I've not hooked the tests into the github actions workflows. In fact I'm not sure if I've gone in the right direction with the tests, i.e. using docker compose ? It looks a bit ugly but I suspect it's less awkward than trying to control containers from within the pytest tests.
Secondly, I've not yet tried incorporating your suggestion
I think that it shouldn't be too hard to iterate on with the tests set up though.
Also, if you like some of this and dislike other bits I'm completely unattached to it.