schireson / pytest-mock-resources

Pytest Fixtures that let you actually test against external resource (Postgres, Mongo, Redshift...) dependent code.
https://pytest-mock-resources.readthedocs.io/en/latest/quickstart.html
MIT License
183 stars 19 forks source link

Allow defining run_args #185

Open devanubis opened 1 year ago

devanubis commented 1 year ago

Is your feature request related to a problem? Please describe. Defining custom run_args / run_kwargs for a container would be nice.

I've ran into some issues with using timescale/timescaledb-ha (specifically https://github.com/timescale/timescaledb-docker-ha/issues/366) and since the problem is that I can't work around that issue with environment variables, maybe instead adding run parameters here could help.

Describe the solution you'd like DockerContainerConfig.run_kwargs / run_args to be added and used in wait_for_container() to customise the container's run command.

Describe alternatives you've considered The problem was only intermittent when using psychopg2 to set up the timescale container, so short term I think I'll go back to using that (but thanks again for #183)

I would also hope that TimescaleDB might bring their -ha image into line with their base image, but that's probably a slow process...

If I had time I'd submit a PR, so if my workaround works with 2.6.10 or I rollback to 2.6.7 I'll carry on for now but would like to submit a PR soon-ish (most likely mid-late March with my current schedule)

DanCardin commented 1 year ago

Per your linked issue, where you mention template1: for what it's worth, you can disable change template1 or disable template_database, if either of those are causing issues. I dont know (anything really) about timescaledb.

run_args should be relatively straightforward to support. Primarily just adding it to the base container config and defaulting to '', and then string splitting on space to deal with how commands work

run_kwargs would be roughly as straightfoward, but wouldn't really make sense in the context of the fallback-uses-env-var-values feature.

I could probably get to run_args being a thing sooner than mid-march, but i'm happy to leave it if you want to contribute