-
Notifications
You must be signed in to change notification settings - Fork 296
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(postgres): Add seed feature to postgres #576
base: main
Are you sure you want to change the base?
Conversation
This duplicated |
I believe the overhead is not worth it, duplication is fine as we probably
don't want to be in the business of maintaining that code in core. Core
should stay clean/lean
…On Mon, May 20, 2024, 7:17 PM Jb DOYON ***@***.***> wrote:
This duplicated transfer_seed function from mysql makes me think it could
be done via a more reusable "Mixin" class, or something, but that's up for
discussion if the complexity overhead is worth the removal of duplication.
—
Reply to this email directly, view it on GitHub
<#576 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACECGJB454KBY5DEQ5TYI43ZDKHCTAVCNFSM6AAAAABIASPHN6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMRRGQ3TCNBXGQ>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
in fact if you can remove transfer_seed from the generic class that would be great, we are planning to remove that eventually. i dont know how the mysql tests ever passed, without even looking at any test executions - you have to do the following dance if you want to place files into the container before the entrypoint executes (and this would go into core if we ever make it generic enough, like the
and then after you start the container, you can copy the files into it asynchronously from python, do whatever you have to do, and then create the file you are using an IPC signal in step 3 above. you can see this implementation in the kafka container |
I'll do anything that makes this feature more maintainable. Just want to make sure I understand your message. The implementation provided here + mysql is indeed "racing" between our That's bad because unreliable, on principle, as depending on winning a race is a recipe for hard to pin down bugs. But I expect worked fine here (in practice) because the start-up time of these dbs is in the multiple seconds, plenty of time to copy across a folder, so we always "won that race", enough that the feature worked. I do see that the proposed solution you posted is nicer, in that it avoids the race. Paraphrasing, it seems to override the entrypoint to replace it with our own waiter script, giving time for put_archive to complete, blocking the script until some "sentinel" files are created, marking time to continue by executing the original entrypoint. I like that solution, and I think I should be able to port this over to here, maybe even in a way that can be moved to the core class? Will investigate. |
And yes remove the transfer_seed and DbContainer "bits" too |
I think we are on the same page. here is the specific code i was referring to: testcontainers-python/modules/kafka/testcontainers/kafka/__init__.py Lines 78 to 82 in 9d2ceb6
|
Okay I think I have an experimental version of the wait-for-sentinel system for mysql, to polish as PR soon, then use in postgres too. Logic is mostly now in One thing to note on the reference implementation: the Kafka solution linked is reusing the Instead I've locally got the So, yeah, I'll send it soon, but I thought some of these points were worth discussing now, not having to wait for the PR itself. |
Issue currently is the tests for postgres fail: The container exits on postgres (not mysql, for identical both entrypoint and command...) with error: sh: 8: source: not found sh: 8: _main: not found I'm still tracking it down, because it's weird that /bin/sh says "source" does not exist (but not with mysql) but the _main should be available from the sourced entrypoint script.
Okay, just sent back the rewritten solution per above thread, using (for now) a DbContainer-level command override, like Kafka does, and with per-image seed mount location, and startup command prefix. It works fine for mysql, but the postgres image one exits (see the last commit's message). Seems that for mysql/postgres, the actual command ( I'm fully open to moving this dbcontainer-level thing up to DockerContainer, just not sure how that would conceptually fit. Sending this for a look over, while I try to understand the exact issue around postgres entrypoint causing exits, to be fixed. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #576 +/- ##
=======================================
Coverage ? 72.75%
=======================================
Files ? 11
Lines ? 613
Branches ? 87
=======================================
Hits ? 446
Misses ? 141
Partials ? 26 ☔ View full report in Codecov by Sentry. |
Just noticed #459, seems the dbcontainer class is to be deprecated. I mean bnoth the seed feature for postgres of current PR; but also for the mysql one that was already merged. |
Ref #541, implement the feature for postgres
Fix mysql "seed" feature's docstring (whoops)